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:
46
bot-sleek.py
Executable file
46
bot-sleek.py
Executable 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()
|
||||||
Reference in New Issue
Block a user