I'm using the latest moul-scripts forked from H-uru/moul-scripts with my bots for Magic Worlds and the FMT.
I found a mistake in the file xKIChat.py. Here is an excerpt of Python.log:
(08/16 16:44:18) KIHandler - Traceback (most recent call last):
(08/16 16:44:18) File ".\python\ki\__init__.py", line 1279, in OnRTChat
(08/16 16:44:18) self.chatMgr.AddChatLine(player, messagemodif, cFlags, forceKI=not self.sawTheKIAtLeastOnce)
(08/16 16:44:18) File ".\python\ki\xKIChat.py", line 560, in AddChatLine
(08/16 16:44:18) chatHeaderFormatted = U"{}{}{}:".format(pretext, separator, unicode(player.getPlayerName()))
(08/16 16:44:18) UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 27: ordinal not in range(128)
The code in xKIChat.py, line 560 is:
- Code: Select all
if player is not None:
separator = "" if pretext.endswith(" ") else " "
chatHeaderFormatted = U"{}{}{}:".format(pretext, separator, unicode(player.getPlayerName()))
chatMessageFormatted = U" {}".format(message)
This occurs when a player plays in a foreign language (the player plays in German language) and he is AFK.
As you know, when you send him a private message, the program returns the message:
in English : (I'm on the surface, be back in a minute) ..........> from the file \dat\KIEnglish.loc
in German : (Ich bin an der Oberfläche, komme gleich zurück) ...........> from the file \dat\KIGerman.loc
You can see special letters : ä and ü which causes the error message quoted above.
I modified the script as follows to prevent the crash of my bots:
- Code: Select all
if player is not None:
separator = "" if pretext.endswith(" ") else " "
try:
chatHeaderFormatted = U"{}{}{}:".format(pretext, separator, unicode(player.getPlayerName()))
except:
chatHeaderFormatted = " "
chatMessageFormatted = U" {}".format(message)
But I think there must be a better solution to this problem.