Skype4Py MessageStatus not firing consistently
Asked Answered
H

1

6

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.

  • Usually, the bot recieves several notifications when a message arrives: there's the chatmessage recieved notification, the chat activity timestamp notification and some others. The chatmessage recieved notification is the one that eventually triggers the MessageStatus event.
  • In the case when the bot did not respond, only one notification came through. It was the notification 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:

  • Is my general code correct? Should, if Skype4Py worked flawlessly, my code work OK?
  • Did anyone else encounter this error where a certain event did not fire?
  • If you encountered a similar error, have you solved it? If not, did you at least discover how to consistently reproduce this problem? I can't even debug it because it appears suddenly and out of nowhere...
Heavy answered 20/11, 2014 at 9:3 Comment(0)
H
1

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.

Hoag answered 28/2, 2015 at 1:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.