-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathrasabot.py
More file actions
executable file
·41 lines (35 loc) · 1.08 KB
/
rasabot.py
File metadata and controls
executable file
·41 lines (35 loc) · 1.08 KB
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
40
41
#!/usr/bin/python
import os
import requests
import vodaucwa
def messageReceived(message):
uri = message.uri
text = message.message.encode('utf-8')
try:
session = requests.Session()
session.trust_env = False
r = session.post("%s/webhooks/rest/webhook" % os.environ['bot_core_endpoint'], json={
"sender": uri,
"message": text
})
print r.text
j = r.json()
out = []
for msg in j:
if "text" in msg:
out.append(msg["text"])
mout = "\n".join(out)
message.reply(mout.encode('utf-8'))
except Exception, e:
message.reply("Oops. Something went wrong. Please try again later. (%s)" % str(e))
print e
def main():
bot = vodaucwa.LyncBot()
bot.setMessageCallback(messageReceived)
username = os.environ['bot_skype_username']
password = os.environ['bot_skype_password']
discoveryurl = os.environ['bot_skype_discovery_url']
bot.authenticate(discoveryurl, username, password)
bot.loop()
if __name__ == '__main__':
main()