I am trying to create a basic Skype skin using Skype4Py
, and have encountered a pretty serious error. I am working on 64-bit Windows 7 with 32-bit Python 2.7.8. Installed with the latest version of Skype4Py.
My main requirement is that the bot has an overview of 5
different Skype chats: four separate chats with four users and one general chat, in which all four users participate. To this end, I wrote two different functions that process individual responses and group chat:
class SkypeBot(object): def __init__(self): self.skype = Skype4Py.Skype(Events=self) self.skype.Attach() self.active_chat = find_conference_chat() def MessageStatus(self, msg, status): if status == Skype4Py.cmsReceived: if msg.Chat.Name == self.active_chat.Name: msg.Chat.SendMessage(respond_to_group(msg)) else: msg.Chat.SendMessage(respond_to_individual(msg)) bot = SkypeBot()
The above code (there is much more, but its core is written) must respond to every message that any user sends either in private or in a group chat.
However, there is a problem. This code usually works fine. The bot responds to each individual user, as well as group chat. Then, every once in a while (every 10 chats), the bot stops responding to individual messages. The MessageStatus
function just didn't work, which made me think that there might be some other event that I need to catch. Therefore, I added one common spectacle of events to the bot:
def Notify(self, notification): print "NOTIFICATION:" print notification print "=========================="
The sole purpose of this code was to see if I was missing any event. So I waited a little, and when the bot did not answer, I checked the printout of the function.
- Typically, a bot receives several notifications when a message arrives: a chat notification is sent there, a chat event notification, and some others. The notification received via chatmessage is the one that ultimately raises the
MessageStatus
event. - In the case when the bot did not respond, only one notification passed. This notice is
CHAT **** ACTIVITY_TIMESTAMP ******
. There were no notifications that chat mail was received, so no message was received to respond.
When I manually clicked on my Skype client and focused my window on the received message, MessageStatus
evend finally quit, and the bot answered, but it was too late.
My question consists of several parts:
- Is my generic code correct? If, if
Skype4Py
worked flawlessly, does my code work fine? - Has anyone else encountered this error when some event did not fire?
- If you encounter a similar error, will you solve it? If not, will you at least learn how to reproduce this problem sequentially? I canβt even debug it, because it appears suddenly and out of nowhere ...