Merge pull request #5 from 4DA/master

Update on_group_invite according to new PyTox and parameterize bot tox name
This commit is contained in:
AZ Huang 2014-12-23 23:36:34 +08:00
commit 58a89710bd

View file

@ -63,6 +63,7 @@ class AV(ToxAV):
sys.stdout.flush() sys.stdout.flush()
self.send_video(idx, width, height, data) self.send_video(idx, width, height, data)
bot_toxname = 'SyncBot'
class SyncBot(Tox): class SyncBot(Tox):
def __init__(self): def __init__(self):
@ -71,7 +72,7 @@ class SyncBot(Tox):
self.av = AV(self, 10) self.av = AV(self, 10)
self.connect() self.connect()
self.set_name('SyncBot') self.set_name(bot_toxname)
self.set_status_message("Send me a message with the word 'invite'") self.set_status_message("Send me a message with the word 'invite'")
print('ID: %s' % self.get_address()) print('ID: %s' % self.get_address())
@ -188,10 +189,10 @@ class SyncBot(Tox):
self.request = True self.request = True
self.ensure_exe(self.send_message, (self.bid, 'invite')) self.ensure_exe(self.send_message, (self.bid, 'invite'))
def on_group_invite(self, friendid, pk): def on_group_invite(self, friendid, type, data):
if not self.joined: if not self.joined:
self.joined = True self.joined = True
self.tox_group_id = self.join_groupchat(friendid, pk) self.tox_group_id = self.join_groupchat(friendid, data)
print('Joined groupchat.') print('Joined groupchat.')
def on_group_message(self, groupnumber, friendgroupnumber, message): def on_group_message(self, groupnumber, friendgroupnumber, message):