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