2014-12-04 66 views
1

所以,我努力使自己的Skype機器人爲我的團隊,但我無法弄清楚如何獲取最新的消息對我的生活。我很快諮詢了互聯網和計算器,因爲我經常遇到一些小問題,但是在Skype4Py文檔中幾乎沒有特定功能的文檔,並且沒有關於計算器的信息。這是我的代碼,請幫忙?Skype4Py得到一個消息

#Importing! 
import time, sys 
import Skype4Py 

#Set skypeclient and connect, while also setting my desired user 
skypeClient = Skype4Py.Skype() 
skypeClient.Attach() 
user = sys.argv[1] 

#Loop! 
while 1: 
    """ 
    Here I am stumped. I have tried skypeClient.Chat.GetRecentMessages(), 
    skypeClient.Chat.Chat.GetRecentMessages 
    and that wouldn't even work for my purposes if it did work! 
    """ 

回答

2

使用

def Commands(Message, Status): 
    if Status == 'SENT' or (Status == 'RECEIVED'): 
     running = 1 
     message = Message.Body.lower() 
     handle = Message.FromHandle.upper() 
     if running == 1: 
      if message == 'WHATEVER': 

然後後來,

skype = Skype4Py.Skype() 
skype.OnMessageStatus = Commands 
skype.Attach() 
while True: 
    pass 

爲我工作!