From 1babaeab015f81ab3bb18abb36ce001c8593f6da Mon Sep 17 00:00:00 2001 From: Stefan Krulj Date: Fri, 12 Oct 2012 00:14:43 +0200 Subject: [PATCH] gajim accepts file transfer --- brathuhn.py | 9 ++++++--- config.py | 4 ++++ main.py | 11 +++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/brathuhn.py b/brathuhn.py index e6f166e..ecdc64c 100644 --- a/brathuhn.py +++ b/brathuhn.py @@ -153,13 +153,15 @@ def __presenceCB(conn,msg): if msg.getType()=='unavailable': nick=msg.getNick() if nick==None: - del users[msg.getFrom()] + if msg.getFrom() in users: + del users[msg.getFrom()] #Disconnect if not msg.getFrom() in users: for listener in status_listeners: listener(msg.getFrom(),msg,STATUS_OFFLINE) else: - del users[msg.getFrom()] + if msg.getFrom() in users: + del users[msg.getFrom()] #Rename if not msg.getFrom() in users: for listener in status_listeners: @@ -202,7 +204,7 @@ def __ignore_first(conn,msg): __messageCB(conn,msg) -jid=xmpp.protocol.JID(node=NAME,domain=SRV,resource='bot') +jid=xmpp.protocol.JID(node=NAME,domain=SRV,resource=RESOURCE) cl=xmpp.Client(jid.getDomain(),debug=[]) def connect_and_join(): @@ -239,6 +241,7 @@ def connect_and_join(): #add the help command addCommand("help","Prints this help message",__help) + addPrivateCommand("help","Prints this help message (in private chat)",__help) #join the room cl.send(msg) diff --git a/config.py b/config.py index c09ce55..e77722a 100644 --- a/config.py +++ b/config.py @@ -7,6 +7,10 @@ cp.read(["/etc/brathuhn/config.cfg","brathuhn.cfg",os.path.expanduser('~/.brathu NAME = cp.get("Account","NAME") SRV = cp.get("Account","SRV") PWD = cp.get("Account","PWD") +try: + RESOURCE = cp.get("Account","RESOURCE") +except: + RESOURCE = 'bot' ROOM = cp.get("Conference","ROOM") PWD_ROOM = cp.get("Conference","PWD_ROOM") diff --git a/main.py b/main.py index c29c63e..aadd7b1 100755 --- a/main.py +++ b/main.py @@ -3,6 +3,8 @@ import brathuhn +import stream_ft,xmpp + import kraken import get_quote import logger @@ -12,6 +14,15 @@ import tantrum import tell import last_active +def foo(msg,args): + cim = stream_ft.create_init_message(brathuhn.room_nick,msg.getFrom(),"brathuhn.py") + brathuhn.cl.send(cim) + +brathuhn.addPrivateCommand("foo","asdasdasd",foo) + brathuhn.connect_and_join() + +brathuhn.cl.RegisterHandler('iq',stream_ft.ft_listener) + brathuhn.loop()