Some refactor.
This commit is contained in:
parent
cb691413de
commit
6b26cc188e
@ -95,12 +95,8 @@ class SyncBot(Tox):
|
|||||||
msg = '[%s]: %s' % rx.groups()
|
msg = '[%s]: %s' % rx.groups()
|
||||||
content = rx.group(2)
|
content = rx.group(2)
|
||||||
|
|
||||||
if content == '^syncbot' or \
|
if content.startswith('^'):
|
||||||
content == '^echobot':
|
self.handle_command(content)
|
||||||
self.irc_send('PRIVMSG %s :%s\r\n' %
|
|
||||||
(CHANNEL, self.get_address()))
|
|
||||||
self.ensure_exe(self.group_message_send,
|
|
||||||
(self.tox_group_id, self.get_address()))
|
|
||||||
elif content[1:].startswith('ACTION '):
|
elif content[1:].startswith('ACTION '):
|
||||||
action = '[%s]: %s' % (rx.group(1),
|
action = '[%s]: %s' % (rx.group(1),
|
||||||
rx.group(2)[8:-1])
|
rx.group(2)[8:-1])
|
||||||
@ -152,6 +148,7 @@ class SyncBot(Tox):
|
|||||||
print('TOX> %s: %s' % (name, message))
|
print('TOX> %s: %s' % (name, message))
|
||||||
if message.startswith('^'):
|
if message.startswith('^'):
|
||||||
self.irc_send('PRIVMSG %s :%s\r\n' % (CHANNEL, message))
|
self.irc_send('PRIVMSG %s :%s\r\n' % (CHANNEL, message))
|
||||||
|
self.handle_command(cmd)
|
||||||
else:
|
else:
|
||||||
self.irc_send('PRIVMSG %s :[%s]: %s\r\n' %
|
self.irc_send('PRIVMSG %s :[%s]: %s\r\n' %
|
||||||
(CHANNEL, name, message))
|
(CHANNEL, name, message))
|
||||||
@ -175,5 +172,12 @@ class SyncBot(Tox):
|
|||||||
else:
|
else:
|
||||||
self.ensure_exe(self.send_message, (friendid, message))
|
self.ensure_exe(self.send_message, (friendid, message))
|
||||||
|
|
||||||
|
def handle_command(self, cmd):
|
||||||
|
if cmd[1:] in ['syncbot', 'echobot']:
|
||||||
|
self.ensure_exe(self.group_message_send,
|
||||||
|
(self.tox_group_id, self.get_address()))
|
||||||
|
self.irc_send('PRIVMSG %s :%s\r\n' %
|
||||||
|
(CHANNEL, self.get_address()))
|
||||||
|
|
||||||
t = SyncBot()
|
t = SyncBot()
|
||||||
t.loop()
|
t.loop()
|
||||||
|
Loading…
Reference in New Issue
Block a user