-
Notifications
You must be signed in to change notification settings - Fork 1
/
skypebot.py
39 lines (34 loc) · 1.21 KB
/
skypebot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import Skype4Py
class SkypeBot:
"""
This class handles communication with Skype via Skype4Py
"""
def __init__(self, plugins):
self.skype = Skype4Py.Skype(Events=self)
self.skype.FriendlyName = "Skype Bot"
self.skype.Attach()
self.plugins = plugins
def AttachmentStatus(self, status):
if status == Skype4Py.apiAttachAvailable:
self.skype.Attach()
def MessageStatus(self, msg, status):
try:
print("INCOMING> %s" % msg.Body)
except UnicodeEncodeError:
print("INCOMING> %s" % msg.Body.encode('utf-8').decode('utf-8'))
# msg.MarkAsSeen()
if status == Skype4Py.cmsReceived:
for plugin in self.plugins:
r = plugin.plugin_process_request(msg)
if r['status']:
msg.Chat.SendMessage(r['message'])
def send(self, topic, message):
"""
Manual send to CONFERENCES to handle command line interface
:param topic: topic of the conference (it's name)
:param message: thing to say
:return:
"""
for chat in self.skype.Chats:
if chat.Topic == topic:
chat.SendMessage(message)