forked from uscki/robot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSmoBot.py
More file actions
19 lines (18 loc) · 700 Bytes
/
SmoBot.py
File metadata and controls
19 lines (18 loc) · 700 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import EventBus
from EventBus import ChatEvent
from bot import Bot
from UsckiAPI import UsckiAPI
import re
class SmoBot(Bot):
def loop(self):
chatevent = EventBus.await(ChatEvent)
m = re.match('waar woont ([\w ]+)\?*', chatevent.message, flags = re.I)
if m:
smobo = UsckiAPI('Smobo', get={'query': m.group(1)})
ad = smobo['//smobo:person/smobo:address1/text()']
names = smobo['//smobo:person/smobo:fullname/text()']
if len(ad) == 1:
chatevent.reply('%s woont op de %s' % (names[0], ad[0]))
else:
names = ' of '.join(names)
chatevent.reply('bedoel je %s?' % names)