Disable MUC history and remove lines ignore
This commit is contained in:
parent
0c69f961c3
commit
002fd865c4
@ -10,4 +10,3 @@ jid = becario@daemons.cf
|
||||
password = goodPassword
|
||||
muc = testeando@salas.daemons.cf
|
||||
nick = pasarelita
|
||||
lines = 20
|
||||
|
63
hybridbot.py
63
hybridbot.py
@ -77,12 +77,10 @@ class IRCBot(SingleServerIRCBot):
|
||||
|
||||
|
||||
class XMPPBot:
|
||||
def __init__(self, jabber, remotejid, chanmuc, lines):
|
||||
def __init__(self, jabber, remotejid, chanmuc):
|
||||
self.jabber = jabber
|
||||
self.remotejid = remotejid
|
||||
self.chanmuc = chanmuc
|
||||
self.lines = lines
|
||||
self.counter = 0
|
||||
|
||||
def register_handlers(self):
|
||||
self.jabber.RegisterHandler('message', self.xmpp_message)
|
||||
@ -97,40 +95,37 @@ class XMPPBot:
|
||||
if type in ['message', 'groupchat', None] and \
|
||||
fromjid == self.remotejid:
|
||||
|
||||
if self.counter >= self.lines:
|
||||
m = text.replace('\r', '')
|
||||
m = m.replace('\n', '')
|
||||
n = event.getFrom().getResource()
|
||||
m = text.replace('\r', '')
|
||||
m = m.replace('\n', '')
|
||||
n = event.getFrom().getResource()
|
||||
|
||||
if text and n != m_nick:
|
||||
if m == '.users':
|
||||
users = self.chanmuc.chan_users()
|
||||
users = ', '.join(users)
|
||||
if text and n != m_nick:
|
||||
if m == '.users':
|
||||
users = self.chanmuc.chan_users()
|
||||
users = ', '.join(users)
|
||||
|
||||
if users:
|
||||
users = '[ IRC Users ] ' + users
|
||||
if users:
|
||||
users = '[ IRC Users ] ' + users
|
||||
|
||||
m = xmpp.protocol.Message(to=muc, body=users,
|
||||
typ='groupchat')
|
||||
inter.xmpp(m)
|
||||
|
||||
elif m == '.help':
|
||||
message = 'The only command I have is \'.users\''+ \
|
||||
'. Also, my owner is ' + owner + '.'
|
||||
|
||||
m = xmpp.protocol.Message(to=muc, body=message,
|
||||
typ='groupchat')
|
||||
m = xmpp.protocol.Message(to=muc, body=users,
|
||||
typ='groupchat')
|
||||
inter.xmpp(m)
|
||||
|
||||
else:
|
||||
m = '[' + n + '] ' + m
|
||||
elif m == '.help':
|
||||
message = 'The only command I have is \'.users\''+ \
|
||||
'. Also, my owner is ' + owner + '.'
|
||||
|
||||
buffer = 460
|
||||
for i in range(0, len(m), buffer):
|
||||
inter.irc(m[i:i + buffer].encode('latin-1',
|
||||
'replace'))
|
||||
m = xmpp.protocol.Message(to=muc, body=message,
|
||||
typ='groupchat')
|
||||
inter.xmpp(m)
|
||||
|
||||
self.counter += 1
|
||||
else:
|
||||
m = '[' + n + '] ' + m
|
||||
|
||||
buffer = 460
|
||||
for i in range(0, len(m), buffer):
|
||||
inter.irc(m[i:i + buffer].encode('latin-1',
|
||||
'replace'))
|
||||
|
||||
except Exception as e:
|
||||
print e
|
||||
@ -186,7 +181,10 @@ class XMPPBot:
|
||||
'mismatch!\n')
|
||||
sys.exit(1)
|
||||
|
||||
cl.send(xmpp.Presence(to='%s/%s' % (muc, m_nick)))
|
||||
p = xmpp.Presence(to='%s/%s' % (muc, m_nick))
|
||||
p.setTag('x', namespace=xmpp.NS_MUC).addChild('history', {'maxchars': '0','maxstanzas': '0'})
|
||||
|
||||
cl.send(p)
|
||||
|
||||
while cl.Process(1):
|
||||
pass
|
||||
@ -248,7 +246,6 @@ if __name__ == '__main__':
|
||||
cl = xmpp.Client(jid.getDomain(), debug=[])
|
||||
muc = parser.get('XMPP', 'muc')
|
||||
m_nick = parser.get('XMPP', 'nick')
|
||||
lines = int(parser.get('XMPP', 'lines'))
|
||||
|
||||
channel = str(parser.get('IRC', 'channel'))
|
||||
i_nick = parser.get('IRC', 'nick')
|
||||
@ -260,7 +257,7 @@ if __name__ == '__main__':
|
||||
|
||||
try:
|
||||
ircb0t = IRCBot(channel, i_nick, server, port, chanmuc)
|
||||
xmppbot = XMPPBot(cl, muc, chanmuc, lines)
|
||||
xmppbot = XMPPBot(cl, muc, chanmuc)
|
||||
inter = Intermedia()
|
||||
z = Thread(target=ircb0t.start, args=())
|
||||
w = Thread(target=xmppbot.start, args=(cl,))
|
||||
|
Loading…
Reference in New Issue
Block a user