From 33518e0b2d691f5a9f7cc9008109e47e02d2b1de Mon Sep 17 00:00:00 2001 From: AZ Huang Date: Mon, 2 Dec 2013 14:50:28 +0800 Subject: [PATCH] Add function to invite others to group chat. --- tox-irc-sync.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tox-irc-sync.py b/tox-irc-sync.py index 93a21ed..5deaf86 100644 --- a/tox-irc-sync.py +++ b/tox-irc-sync.py @@ -16,7 +16,7 @@ IRC_HOST = "irc.freenode.net" IRC_PORT = 6667 NAME = NICK = IDENT = REALNAME = "SyncBot" -CHANNEL = '#tox-dev' +CHANNEL = '#tox-ontopic' class SyncBot(Tox): def __init__(self): @@ -25,6 +25,7 @@ class SyncBot(Tox): self.connect() self.set_name("SyncBot") + self.set_status_message("Send me a message with the word 'invite'") print('ID: %s' % self.get_address()) self.readbuffer = "" @@ -93,11 +94,6 @@ class SyncBot(Tox): except KeyboardInterrupt: self.save_to_file('data') - def on_friend_request(self, pk, message): - print('Friend request from %s: %s' % (pk, message)) - self.add_friend_norequest(pk) - print('Accepted.') - def on_group_invite(self, friendid, pk): if not self.joined: self.joined = True @@ -110,5 +106,14 @@ class SyncBot(Tox): print('TOX> %s: %s' % (name, message)) self.irc.send('PRIVMSG %s :%s> %s\r\n' % (CHANNEL, name, message)) + def on_friend_request(self, pk, message): + print('Friend request from %s: %s' % (pk, message)) + self.add_friend_norequest(pk) + print('Accepted.') + + def on_friend_message(self, friendid, message): + if message == 'invite': + self.invite_friend(friendid, self.tox_group_id) + t = SyncBot() t.loop()