Better way of handling group message sent by ourself.
This commit is contained in:
parent
95b1ea5480
commit
b5ad3dccd5
@ -31,7 +31,6 @@ class SyncBot(Tox):
|
|||||||
print('ID: %s' % self.get_address())
|
print('ID: %s' % self.get_address())
|
||||||
|
|
||||||
self.readbuffer = ""
|
self.readbuffer = ""
|
||||||
self.sent = None
|
|
||||||
self.tox_group_id = None
|
self.tox_group_id = None
|
||||||
|
|
||||||
self.irc_init()
|
self.irc_init()
|
||||||
@ -102,19 +101,18 @@ class SyncBot(Tox):
|
|||||||
msg = '[%s]: %s' % rx.groups()
|
msg = '[%s]: %s' % rx.groups()
|
||||||
content = rx.group(2)
|
content = rx.group(2)
|
||||||
|
|
||||||
if content.startswith('^'):
|
if content[1:].startswith('ACTION '):
|
||||||
self.handle_command(content)
|
|
||||||
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])
|
||||||
self.sent = action
|
|
||||||
self.ensure_exe(self.group_action_send,
|
self.ensure_exe(self.group_action_send,
|
||||||
(self.tox_group_id, action))
|
(self.tox_group_id, action))
|
||||||
elif self.tox_group_id != None:
|
elif self.tox_group_id != None:
|
||||||
self.sent = msg
|
|
||||||
self.ensure_exe(self.group_message_send,
|
self.ensure_exe(self.group_message_send,
|
||||||
(self.tox_group_id, msg))
|
(self.tox_group_id, msg))
|
||||||
|
|
||||||
|
if content.startswith('^'):
|
||||||
|
self.handle_command(content)
|
||||||
|
|
||||||
l = line.rstrip().split()
|
l = line.rstrip().split()
|
||||||
if l[0] == "PING":
|
if l[0] == "PING":
|
||||||
self.irc_send("PONG %s\r\n" % l[1])
|
self.irc_send("PONG %s\r\n" % l[1])
|
||||||
@ -150,8 +148,8 @@ class SyncBot(Tox):
|
|||||||
print('Joined groupchat.')
|
print('Joined groupchat.')
|
||||||
|
|
||||||
def on_group_message(self, groupnumber, friendgroupnumber, message):
|
def on_group_message(self, groupnumber, friendgroupnumber, message):
|
||||||
if message != self.sent:
|
name = self.group_peername(groupnumber, friendgroupnumber)
|
||||||
name = self.group_peername(groupnumber, friendgroupnumber)
|
if name != NAME:
|
||||||
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))
|
||||||
@ -161,7 +159,8 @@ class SyncBot(Tox):
|
|||||||
(CHANNEL, name, message))
|
(CHANNEL, name, message))
|
||||||
|
|
||||||
def on_group_action(self, groupnumber, friendgroupnumber, action):
|
def on_group_action(self, groupnumber, friendgroupnumber, action):
|
||||||
if action != self.sent:
|
name = self.group_peername(groupnumber, friendgroupnumber)
|
||||||
|
if name != NAME:
|
||||||
name = self.group_peername(groupnumber, friendgroupnumber)
|
name = self.group_peername(groupnumber, friendgroupnumber)
|
||||||
print('TOX> %s: %s' % (name, action))
|
print('TOX> %s: %s' % (name, action))
|
||||||
self.irc_send('PRIVMSG %s :\x01ACTION [%s]: %s\x01\r\n' %
|
self.irc_send('PRIVMSG %s :\x01ACTION [%s]: %s\x01\r\n' %
|
||||||
@ -180,7 +179,6 @@ class SyncBot(Tox):
|
|||||||
self.ensure_exe(self.send_message, (friendid, message))
|
self.ensure_exe(self.send_message, (friendid, message))
|
||||||
|
|
||||||
def send_both(self, content):
|
def send_both(self, content):
|
||||||
self.sent = content
|
|
||||||
self.ensure_exe(self.group_message_send, (self.tox_group_id, content))
|
self.ensure_exe(self.group_message_send, (self.tox_group_id, content))
|
||||||
self.irc_send('PRIVMSG %s :%s\r\n' % (CHANNEL, content))
|
self.irc_send('PRIVMSG %s :%s\r\n' % (CHANNEL, content))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user