0

I'm trying to make a simple skype bot that I can run and if a message is sent in a specific chat, that it sends one of three messages which rotate. However I'm trying to figure out how to make it check when a message is sent into the chat.

Have so far:

import Skype4Py as skype
skypeClient = skype.Skype()
skypeClient.Attach()
def sendGroupChatMessage(topic="Topic"):
    messageSent = False
    messagenum = 0
    for elem in skypeClient.ActiveChats:
        if (messagenum == 0):
            elem.SendMessage("I see")
            messagenum = 1
            messageSent = True
        elif (messagenum == 1):
            elem.SendMessage("That's amazing")
            messagenum = 2
            messageSent = True
        elif (messagenum == 2):
            elem.SendMessage("It's not your fault")
            messagenum = 0
            messageSent = True
    if not messageSent:
        for chat in skypeClient.BookmarkedChats:
            if chat.Topic == topic:
                chat.SendMessage("SomeMessageHere")
                messageSent = True

    return messageSent

if skypeClient.OnMessageStatus == 'RECEIVED':
    sendGroupChatMessage()
user3666197
  • 1
  • 6
  • 50
  • 92

1 Answers1

3

You have to register event MessageStatus.
http://skype4py.sourceforge.net/doc/html/Skype4Py.skype.SkypeEvents-class.html
There you can find more informations.

Example code, what's resending message to sender (just echo):

import Skype4Py

skype = Skype4Py.Skype()
skype.Attach()

def onMsg(msg, status):
  if status == Skype4Py.cmsReceived:
    msg.Chat.SendMessage(msg.Body)

skype.RegisterEventHandler('MessageStatus', onMsg)
while 1: pass