I'm trying to make a basic Skype bot using Skype4Py
and have encountered a rather serious error. I am working on a 64 bit windows 7 with the 32bit Python 2.7.8. installed, along with the latest version of Skype4Py.
My main demand is that the bot has an overview of 5
different Skype chats: four individual chats with four users and one common chat in which all four users participate. To that end, I have written two different functions handling individual responses and the 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's much more to it, but the core of it is written down) is supposed to answer each message that any user sends either privately or in the group chat.
However, there's a problem. Usually, this code works just fine. The bot responds to each individual user as well as the group chat. Then, every once in a while (once every 10 chats), the bot stops responding to individual messages. The function MessageStatus
simply does not fire, which made me think that there may be some other event I need to catch. So I added one general event catcher to the bot:
def Notify(self, notification):
print "NOTIFICATION:"
print notification
print "=========================="
The only purpose of this code was to see if I am missing any event. So I waited for a bit, and when the bot did not respond, I checked the printout of the function.
MessageStatus
event.CHAT **** ACTIVITY_TIMESTAMP ******
. There was no notification that a chatmessage was recieved, so no message to respond do.When I manually clicked on my Skype client and focused my window on the message recieved, the MessageStatus
evend finally fired and the bot responded, but that was way too late.
My question has several parts:
Skype4Py
worked flawlessly, my code work OK?Unfortunately, this is probably a bug in the Skype API. This help post indicates that support for the API is being revoked, saying:
Important: As communicated in this blog post, due to technology improvements we are making to the Skype experience, some features of the API will stop working with Skype for desktop. For example, delivery of chat messages using the API will cease to work. However, we will be extending support for two of the most widely used features – call recording and compatibility with hardware devices – until we determine alternative options or retire the current solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With