1
0
mirror of http://aero2k.de/t/repos/urlbot-native.git synced 2017-09-06 15:25:38 +02:00

add simple sleekXMPP bot for testing

This commit is contained in:
urlbot
2014-12-02 13:55:11 +01:00
parent 8e93cb0a17
commit 2484f32b5b
2 changed files with 46 additions and 0 deletions

46
bot-sleek.py Executable file
View File

@@ -0,0 +1,46 @@
#!/usr/bin/python3
from sleekxmpp import ClientXMPP
from local_config import conf
import time
t = -time.time()
class bot(ClientXMPP):
def __init__(self, jid, password, room, nick):
ClientXMPP.__init__(self, jid, password)
self.room = room
self.nick = nick
self.add_event_handler('session_start', self.session_start)
self.add_event_handler('message', self.message)
def session_start(self, event):
self.get_roster()
self.send_presence()
self.plugin['xep_0045'].joinMUC(
self.room,
self.nick,
wait=True
)
def message(self, event):
print((t + time.time()) + ': ' + str(msg))
# if msg['type'] in ['chat', 'normal']:
# msg.reply('pong[%s]' % msg).send()
if '__main__' == __name__:
xmpp = bot(
jid=conf('jid'),
password=conf('password'),
room=conf('room'),
nick=conf('bot_user')
)
xmpp.connect()
xmpp.register_plugin('xep_0045')
xmpp.process()