Send multiline XMPP msgs as multiple msgs in IRC
This commit is contained in:
parent
3d22bbe87d
commit
7da0839dc0
22
hybridbot.py
22
hybridbot.py
@ -105,10 +105,11 @@ class XMPPBot(sleekxmpp.ClientXMPP):
|
|||||||
fromjid = event['from'].bare
|
fromjid = event['from'].bare
|
||||||
nick = event['mucnick']
|
nick = event['mucnick']
|
||||||
|
|
||||||
text = text.replace('\r', '').replace('\n', '')
|
if text:
|
||||||
|
text = text.replace('\r\n', '\n').replace('\r', '\n').split('\n')
|
||||||
|
|
||||||
if text and nick != m_nick:
|
if text and len(text) > 0 and nick != m_nick:
|
||||||
if text == '.users':
|
if len(text) == 1 and text[0] == '.users':
|
||||||
users = self.chanmuc.chan_users()
|
users = self.chanmuc.chan_users()
|
||||||
users = ', '.join(users)
|
users = ', '.join(users)
|
||||||
|
|
||||||
@ -118,7 +119,7 @@ class XMPPBot(sleekxmpp.ClientXMPP):
|
|||||||
self.jabber.send_message(mto=muc, mbody=users,
|
self.jabber.send_message(mto=muc, mbody=users,
|
||||||
mtype='groupchat')
|
mtype='groupchat')
|
||||||
|
|
||||||
elif text == '.help':
|
elif len(text) == 1 and text[0] == '.help':
|
||||||
message = 'The only command I have is \'.users\''+ \
|
message = 'The only command I have is \'.users\''+ \
|
||||||
'. Also, my owner is ' + owner + '.'
|
'. Also, my owner is ' + owner + '.'
|
||||||
|
|
||||||
@ -126,11 +127,16 @@ class XMPPBot(sleekxmpp.ClientXMPP):
|
|||||||
mtype='groupchat')
|
mtype='groupchat')
|
||||||
|
|
||||||
else:
|
else:
|
||||||
text = '[' + nick + '] ' + text
|
for i in range(0, len(text)):
|
||||||
|
m = '[' + nick + '] ' + text[i]
|
||||||
|
|
||||||
buffer = 460
|
# Slow down a bit.
|
||||||
for i in range(0, len(text), buffer):
|
if i > 0:
|
||||||
inter.irc(text[i:i + buffer])
|
time.sleep(0.5)
|
||||||
|
|
||||||
|
buffer = 460
|
||||||
|
for j in range(0, len(m), buffer):
|
||||||
|
inter.irc(m[j:j + buffer])
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
Loading…
Reference in New Issue
Block a user