Disable MUC history and remove lines ignore

This commit is contained in:
Alexei Sorokin 2016-07-28 18:57:34 +03:00
parent 0c69f961c3
commit 002fd865c4
2 changed files with 30 additions and 34 deletions

View File

@ -10,4 +10,3 @@ jid = becario@daemons.cf
password = goodPassword password = goodPassword
muc = testeando@salas.daemons.cf muc = testeando@salas.daemons.cf
nick = pasarelita nick = pasarelita
lines = 20

View File

@ -77,12 +77,10 @@ class IRCBot(SingleServerIRCBot):
class XMPPBot: class XMPPBot:
def __init__(self, jabber, remotejid, chanmuc, lines): def __init__(self, jabber, remotejid, chanmuc):
self.jabber = jabber self.jabber = jabber
self.remotejid = remotejid self.remotejid = remotejid
self.chanmuc = chanmuc self.chanmuc = chanmuc
self.lines = lines
self.counter = 0
def register_handlers(self): def register_handlers(self):
self.jabber.RegisterHandler('message', self.xmpp_message) self.jabber.RegisterHandler('message', self.xmpp_message)
@ -97,7 +95,6 @@ class XMPPBot:
if type in ['message', 'groupchat', None] and \ if type in ['message', 'groupchat', None] and \
fromjid == self.remotejid: fromjid == self.remotejid:
if self.counter >= self.lines:
m = text.replace('\r', '') m = text.replace('\r', '')
m = m.replace('\n', '') m = m.replace('\n', '')
n = event.getFrom().getResource() n = event.getFrom().getResource()
@ -130,8 +127,6 @@ class XMPPBot:
inter.irc(m[i:i + buffer].encode('latin-1', inter.irc(m[i:i + buffer].encode('latin-1',
'replace')) 'replace'))
self.counter += 1
except Exception as e: except Exception as e:
print e print e
pass pass
@ -186,7 +181,10 @@ class XMPPBot:
'mismatch!\n') 'mismatch!\n')
sys.exit(1) 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): while cl.Process(1):
pass pass
@ -248,7 +246,6 @@ if __name__ == '__main__':
cl = xmpp.Client(jid.getDomain(), debug=[]) cl = xmpp.Client(jid.getDomain(), debug=[])
muc = parser.get('XMPP', 'muc') muc = parser.get('XMPP', 'muc')
m_nick = parser.get('XMPP', 'nick') m_nick = parser.get('XMPP', 'nick')
lines = int(parser.get('XMPP', 'lines'))
channel = str(parser.get('IRC', 'channel')) channel = str(parser.get('IRC', 'channel'))
i_nick = parser.get('IRC', 'nick') i_nick = parser.get('IRC', 'nick')
@ -260,7 +257,7 @@ if __name__ == '__main__':
try: try:
ircb0t = IRCBot(channel, i_nick, server, port, chanmuc) ircb0t = IRCBot(channel, i_nick, server, port, chanmuc)
xmppbot = XMPPBot(cl, muc, chanmuc, lines) xmppbot = XMPPBot(cl, muc, chanmuc)
inter = Intermedia() inter = Intermedia()
z = Thread(target=ircb0t.start, args=()) z = Thread(target=ircb0t.start, args=())
w = Thread(target=xmppbot.start, args=(cl,)) w = Thread(target=xmppbot.start, args=(cl,))