Don't JOIN until 376 verb
This commit is contained in:
parent
ffcb71be30
commit
f41d26d63b
2 changed files with 7 additions and 5 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
data
|
|
@ -39,7 +39,6 @@ class SyncBot(Tox):
|
||||||
self.irc.connect((IRC_HOST, IRC_PORT))
|
self.irc.connect((IRC_HOST, IRC_PORT))
|
||||||
self.irc.send("NICK %s\r\n" % NICK)
|
self.irc.send("NICK %s\r\n" % NICK)
|
||||||
self.irc.send("USER %s %s bla :%s\r\n" % (IDENT, IRC_HOST, REALNAME))
|
self.irc.send("USER %s %s bla :%s\r\n" % (IDENT, IRC_HOST, REALNAME))
|
||||||
self.irc.send("JOIN %s\r\n" % CHANNEL)
|
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
print('connecting...')
|
print('connecting...')
|
||||||
|
@ -93,7 +92,7 @@ class SyncBot(Tox):
|
||||||
CHANNEL, line, re.S)
|
CHANNEL, line, re.S)
|
||||||
if rx:
|
if rx:
|
||||||
print('IRC> %s: %s' % rx.groups())
|
print('IRC> %s: %s' % rx.groups())
|
||||||
msg = '%s> %s' % rx.groups()
|
msg = '%s\ %s' % rx.groups()
|
||||||
content = rx.group(2)
|
content = rx.group(2)
|
||||||
|
|
||||||
if content == '^syncbot' or \
|
if content == '^syncbot' or \
|
||||||
|
@ -101,7 +100,7 @@ class SyncBot(Tox):
|
||||||
self.irc_send('PRIVMSG %s :%s\r\n' %
|
self.irc_send('PRIVMSG %s :%s\r\n' %
|
||||||
(CHANNEL, self.get_address()))
|
(CHANNEL, 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])
|
||||||
self.sent = action
|
self.sent = action
|
||||||
self.ensure_exe(self.group_action_send,
|
self.ensure_exe(self.group_action_send,
|
||||||
|
@ -114,6 +113,8 @@ class SyncBot(Tox):
|
||||||
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])
|
||||||
|
if l[1] == "376":
|
||||||
|
self.irc.send("JOIN %s\r\n" % CHANNEL)
|
||||||
|
|
||||||
self.do()
|
self.do()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
@ -147,13 +148,13 @@ class SyncBot(Tox):
|
||||||
if message != self.sent:
|
if message != self.sent:
|
||||||
name = self.group_peername(groupnumber, friendgroupnumber)
|
name = self.group_peername(groupnumber, friendgroupnumber)
|
||||||
print('TOX> %s: %s' % (name, message))
|
print('TOX> %s: %s' % (name, message))
|
||||||
self.irc_send('PRIVMSG %s :%s> %s\r\n' % (CHANNEL, name, message))
|
self.irc_send('PRIVMSG %s :%s\ %s\r\n' % (CHANNEL, name, message))
|
||||||
|
|
||||||
def on_group_action(self, groupnumber, friendgroupnumber, action):
|
def on_group_action(self, groupnumber, friendgroupnumber, action):
|
||||||
if action != self.sent:
|
if action != self.sent:
|
||||||
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' %
|
||||||
(CHANNEL, name, action))
|
(CHANNEL, name, action))
|
||||||
|
|
||||||
def on_friend_request(self, pk, message):
|
def on_friend_request(self, pk, message):
|
||||||
|
|
Loading…
Reference in a new issue