0
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
#!/usr/bin/env python |
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
import logging |
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
import sys |
5
5:754ae6ae2c54
rollbot: ability to specify a config file (YAML) with jid, password and nick
Anton Shestakov <av6@dwimlabs.net>
previous changes: 4:4b0145336c46
line |
diff
|
from argparse import ArgumentParser, FileType, SUPPRESS |
0
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
|
5
5:754ae6ae2c54
rollbot: ability to specify a config file (YAML) with jid, password and nick
Anton Shestakov <av6@dwimlabs.net>
previous changes: 4:4b0145336c46
line |
diff
|
import yaml |
0
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
import sleekxmpp |
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
|
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
|
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
if sys.version_info < (3, 0): |
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
reload(sys) |
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
sys.setdefaultencoding('utf8') |
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
else: |
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
raw_input = input |
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
|
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
|
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
class RollBot(sleekxmpp.ClientXMPP): |
2
2:11e99d62ba12
rollbot: join rooms when invited
Anton Shestakov <av6@dwimlabs.net>
previous changes: 1:e7b3233bb582
line |
diff
|
def __init__(self, jid, password, nick): |
0
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
sleekxmpp.ClientXMPP.__init__(self, jid, password) |
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
|
2
2:11e99d62ba12
rollbot: join rooms when invited
Anton Shestakov <av6@dwimlabs.net>
previous changes: 1:e7b3233bb582
line |
diff
|
self.nick = nick |
6
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
self.prefix = '!' |
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
self.commands = [] |
2
2:11e99d62ba12
rollbot: join rooms when invited
Anton Shestakov <av6@dwimlabs.net>
previous changes: 1:e7b3233bb582
line |
diff
|
|
0
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
self.add_event_handler('session_start', self.start) |
6
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
self.add_event_handler('message', self.message) |
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
self.add_event_handler('groupchat_message', self.muc_message) |
2
2:11e99d62ba12
rollbot: join rooms when invited
Anton Shestakov <av6@dwimlabs.net>
previous changes: 1:e7b3233bb582
line |
diff
|
self.add_event_handler('groupchat_invite', self.muc_invite) |
2:11e99d62ba12
rollbot: join rooms when invited
Anton Shestakov <av6@dwimlabs.net>
previous changes: 1:e7b3233bb582
line |
diff
|
self.add_event_handler('groupchat_direct_invite', self.muc_direct_invite) |
0
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
|
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
def start(self, event): |
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
self.get_roster() |
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
self.send_presence() |
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
|
6
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
def message(self, msg): |
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
if msg['type'] not in ('chat', 'normal'): |
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
return |
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
|
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
rbody = self.respond(msg['body'].strip()) |
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
if rbody: |
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
msg.reply(rbody) |
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
msg.send() |
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
|
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
def muc_message(self, msg): |
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
if msg['mucnick'] == self.nick: |
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
return |
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
|
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
mbody = msg['body'].lstrip() |
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
if mbody.startswith(self.nick): |
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
mbody = mbody[len(self.nick):] |
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
elif mbody.startswith(self.prefix): |
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
mbody = mbody[len(self.prefix):] |
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
else: |
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
return |
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
|
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
mbody = mbody.lstrip(':, \t') |
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
rbody = self.respond(mbody) |
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
if rbody: |
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
rbody = '%s: %s' % (msg['mucnick'], rbody) |
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
msg.reply(rbody) |
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
msg.send() |
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
|
2
2:11e99d62ba12
rollbot: join rooms when invited
Anton Shestakov <av6@dwimlabs.net>
previous changes: 1:e7b3233bb582
line |
diff
|
def muc_invite(self, invite): |
2:11e99d62ba12
rollbot: join rooms when invited
Anton Shestakov <av6@dwimlabs.net>
previous changes: 1:e7b3233bb582
line |
diff
|
room = invite['from'] |
2:11e99d62ba12
rollbot: join rooms when invited
Anton Shestakov <av6@dwimlabs.net>
previous changes: 1:e7b3233bb582
line |
diff
|
password = '' # https://github.com/fritzy/SleekXMPP/issues/409 |
2:11e99d62ba12
rollbot: join rooms when invited
Anton Shestakov <av6@dwimlabs.net>
previous changes: 1:e7b3233bb582
line |
diff
|
self.plugin['xep_0045'].joinMUC(room, self.nick, password=password, wait=True) |
2:11e99d62ba12
rollbot: join rooms when invited
Anton Shestakov <av6@dwimlabs.net>
previous changes: 1:e7b3233bb582
line |
diff
|
|
2:11e99d62ba12
rollbot: join rooms when invited
Anton Shestakov <av6@dwimlabs.net>
previous changes: 1:e7b3233bb582
line |
diff
|
def muc_direct_invite(self, invite): |
2:11e99d62ba12
rollbot: join rooms when invited
Anton Shestakov <av6@dwimlabs.net>
previous changes: 1:e7b3233bb582
line |
diff
|
room = invite['groupchat_invite']['jid'] |
2:11e99d62ba12
rollbot: join rooms when invited
Anton Shestakov <av6@dwimlabs.net>
previous changes: 1:e7b3233bb582
line |
diff
|
password = invite['groupchat_invite']['password'] |
2:11e99d62ba12
rollbot: join rooms when invited
Anton Shestakov <av6@dwimlabs.net>
previous changes: 1:e7b3233bb582
line |
diff
|
self.plugin['xep_0045'].joinMUC(room, self.nick, password=password, wait=True) |
2:11e99d62ba12
rollbot: join rooms when invited
Anton Shestakov <av6@dwimlabs.net>
previous changes: 1:e7b3233bb582
line |
diff
|
|
6
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
def respond(self, message, prefix=None): |
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
response = '' |
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
for command in self.commands: |
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
response = command.parse(message) |
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
if response: |
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
break |
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
return response |
6:bddc9023ac66
rollbot: try and respond to various commands (none yet) when addressed
Anton Shestakov <av6@dwimlabs.net>
previous changes: 5:754ae6ae2c54
line |
diff
|
|
0
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
|
5
5:754ae6ae2c54
rollbot: ability to specify a config file (YAML) with jid, password and nick
Anton Shestakov <av6@dwimlabs.net>
previous changes: 4:4b0145336c46
line |
diff
|
def lookup(key, args, config, default=None): |
5:754ae6ae2c54
rollbot: ability to specify a config file (YAML) with jid, password and nick
Anton Shestakov <av6@dwimlabs.net>
previous changes: 4:4b0145336c46
line |
diff
|
if hasattr(args, key): |
5:754ae6ae2c54
rollbot: ability to specify a config file (YAML) with jid, password and nick
Anton Shestakov <av6@dwimlabs.net>
previous changes: 4:4b0145336c46
line |
diff
|
return getattr(args, key) |
5:754ae6ae2c54
rollbot: ability to specify a config file (YAML) with jid, password and nick
Anton Shestakov <av6@dwimlabs.net>
previous changes: 4:4b0145336c46
line |
diff
|
return config.get(key, default) |
5:754ae6ae2c54
rollbot: ability to specify a config file (YAML) with jid, password and nick
Anton Shestakov <av6@dwimlabs.net>
previous changes: 4:4b0145336c46
line |
diff
|
|
0
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
|
5
5:754ae6ae2c54
rollbot: ability to specify a config file (YAML) with jid, password and nick
Anton Shestakov <av6@dwimlabs.net>
previous changes: 4:4b0145336c46
line |
diff
|
def main(): |
5:754ae6ae2c54
rollbot: ability to specify a config file (YAML) with jid, password and nick
Anton Shestakov <av6@dwimlabs.net>
previous changes: 4:4b0145336c46
line |
diff
|
parser = ArgumentParser(argument_default=SUPPRESS) |
5:754ae6ae2c54
rollbot: ability to specify a config file (YAML) with jid, password and nick
Anton Shestakov <av6@dwimlabs.net>
previous changes: 4:4b0145336c46
line |
diff
|
|
5:754ae6ae2c54
rollbot: ability to specify a config file (YAML) with jid, password and nick
Anton Shestakov <av6@dwimlabs.net>
previous changes: 4:4b0145336c46
line |
diff
|
parser.add_argument('-c', '--config', help='configuration file (YAML)', type=FileType('r')) |
5:754ae6ae2c54
rollbot: ability to specify a config file (YAML) with jid, password and nick
Anton Shestakov <av6@dwimlabs.net>
previous changes: 4:4b0145336c46
line |
diff
|
|
5:754ae6ae2c54
rollbot: ability to specify a config file (YAML) with jid, password and nick
Anton Shestakov <av6@dwimlabs.net>
previous changes: 4:4b0145336c46
line |
diff
|
group = parser.add_argument_group('main configuration', 'options that can be specified in the configuration file') |
5:754ae6ae2c54
rollbot: ability to specify a config file (YAML) with jid, password and nick
Anton Shestakov <av6@dwimlabs.net>
previous changes: 4:4b0145336c46
line |
diff
|
group.add_argument('-j', '--jid', help='JID to use') |
5:754ae6ae2c54
rollbot: ability to specify a config file (YAML) with jid, password and nick
Anton Shestakov <av6@dwimlabs.net>
previous changes: 4:4b0145336c46
line |
diff
|
group.add_argument('-p', '--password', help='password to use') |
5:754ae6ae2c54
rollbot: ability to specify a config file (YAML) with jid, password and nick
Anton Shestakov <av6@dwimlabs.net>
previous changes: 4:4b0145336c46
line |
diff
|
group.add_argument('-n', '--nick', help='MUC nickname') |
3
3:12c6cbab21e4
rollbot: add --quiet in addition to --debug
Anton Shestakov <av6@dwimlabs.net>
previous changes: 2:11e99d62ba12
line |
diff
|
|
3:12c6cbab21e4
rollbot: add --quiet in addition to --debug
Anton Shestakov <av6@dwimlabs.net>
previous changes: 2:11e99d62ba12
line |
diff
|
group = parser.add_mutually_exclusive_group() |
3:12c6cbab21e4
rollbot: add --quiet in addition to --debug
Anton Shestakov <av6@dwimlabs.net>
previous changes: 2:11e99d62ba12
line |
diff
|
group.add_argument('-q', '--quiet', help='set logging to ERROR', action='store_const', dest='loglevel', const=logging.ERROR, default=logging.INFO) |
3:12c6cbab21e4
rollbot: add --quiet in addition to --debug
Anton Shestakov <av6@dwimlabs.net>
previous changes: 2:11e99d62ba12
line |
diff
|
group.add_argument('-d', '--debug', help='set logging to DEBUG', action='store_const', dest='loglevel', const=logging.DEBUG, default=logging.INFO) |
0
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
|
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
args = parser.parse_args() |
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
|
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
logging.basicConfig(level=args.loglevel, format='%(asctime)s %(levelname)-8s %(message)s') |
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
|
5
5:754ae6ae2c54
rollbot: ability to specify a config file (YAML) with jid, password and nick
Anton Shestakov <av6@dwimlabs.net>
previous changes: 4:4b0145336c46
line |
diff
|
if hasattr(args, 'config'): |
5:754ae6ae2c54
rollbot: ability to specify a config file (YAML) with jid, password and nick
Anton Shestakov <av6@dwimlabs.net>
previous changes: 4:4b0145336c46
line |
diff
|
config = yaml.safe_load(args.config) |
5:754ae6ae2c54
rollbot: ability to specify a config file (YAML) with jid, password and nick
Anton Shestakov <av6@dwimlabs.net>
previous changes: 4:4b0145336c46
line |
diff
|
else: |
5:754ae6ae2c54
rollbot: ability to specify a config file (YAML) with jid, password and nick
Anton Shestakov <av6@dwimlabs.net>
previous changes: 4:4b0145336c46
line |
diff
|
config = {} |
5:754ae6ae2c54
rollbot: ability to specify a config file (YAML) with jid, password and nick
Anton Shestakov <av6@dwimlabs.net>
previous changes: 4:4b0145336c46
line |
diff
|
|
5:754ae6ae2c54
rollbot: ability to specify a config file (YAML) with jid, password and nick
Anton Shestakov <av6@dwimlabs.net>
previous changes: 4:4b0145336c46
line |
diff
|
jid = lookup('jid', args, config) |
5:754ae6ae2c54
rollbot: ability to specify a config file (YAML) with jid, password and nick
Anton Shestakov <av6@dwimlabs.net>
previous changes: 4:4b0145336c46
line |
diff
|
password = lookup('password', args, config) |
5:754ae6ae2c54
rollbot: ability to specify a config file (YAML) with jid, password and nick
Anton Shestakov <av6@dwimlabs.net>
previous changes: 4:4b0145336c46
line |
diff
|
nick = lookup('nick', args, config, default='rollbot') |
5:754ae6ae2c54
rollbot: ability to specify a config file (YAML) with jid, password and nick
Anton Shestakov <av6@dwimlabs.net>
previous changes: 4:4b0145336c46
line |
diff
|
|
5:754ae6ae2c54
rollbot: ability to specify a config file (YAML) with jid, password and nick
Anton Shestakov <av6@dwimlabs.net>
previous changes: 4:4b0145336c46
line |
diff
|
rollbot = RollBot(jid, password, nick) |
1
1:e7b3233bb582
rollbot: be nice and auto authorize contacts, then subscribe back to them
Anton Shestakov <av6@dwimlabs.net>
previous changes: 0:ce9855302692
line |
diff
|
rollbot.auto_authorize = True |
1:e7b3233bb582
rollbot: be nice and auto authorize contacts, then subscribe back to them
Anton Shestakov <av6@dwimlabs.net>
previous changes: 0:ce9855302692
line |
diff
|
rollbot.auto_subscribe = True |
0
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
rollbot.register_plugin('xep_0030') # Service Discovery |
2
2:11e99d62ba12
rollbot: join rooms when invited
Anton Shestakov <av6@dwimlabs.net>
previous changes: 1:e7b3233bb582
line |
diff
|
rollbot.register_plugin('xep_0045') # Multi-User Chat |
0
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
rollbot.register_plugin('xep_0092') # Software Version |
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
rollbot.register_plugin('xep_0199') # XMPP Ping |
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
rollbot.register_plugin('xep_0202') # Entity Time |
2
2:11e99d62ba12
rollbot: join rooms when invited
Anton Shestakov <av6@dwimlabs.net>
previous changes: 1:e7b3233bb582
line |
diff
|
rollbot.register_plugin('xep_0249') # Direct MUC Invitations |
0
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
|
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
if rollbot.connect(): |
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
logging.info('RollBot connected') |
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
rollbot.process(block=True) |
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
logging.info('RollBot disconnected') |
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
else: |
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
logging.fatal("RollBot couldn't connect") |
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
|
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
|
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
if __name__ == '__main__': |
0:ce9855302692
rollbot: connect and send presence
Anton Shestakov <av6@dwimlabs.net>
previous changes:
line |
diff
|
main() |