def run(self): return threado.run(self.main())
# Join the XMPP rooms src = yield conn.muc.join(src_roomname, "bot") dst = yield conn.muc.join(dst_roomname, "bot") # Forward body elements from the src room to the dst room, # but filter away stuff by the bot itself to avoid nasty loops. own_jid = src.nick_jid yield src | room_filter(own_jid) | dst | threado.dev_null() @threado.stream def room_filter(inner, own_jid): while True: # Receive one XML element from the pipe input element = yield inner # Prevent endless feedback loops sender = jid.JID(element.get_attr("from")) if sender == own_jid: continue # Forward the body elements for body in element.named("message").children("body"): inner.send(body) username = "******" password = "******" src_roomname = "src_xmpproom" dst_roomname = "dst_xmpproom" threado.run(main(username, password, src_roomname, dst_roomname))
def run(self): return threado.run(self._run(), throw_on_signal=services.Stop())
from idiokit import threado from idiokit import xmpp @threado.stream def main(inner, jid, password, roomname): # Join the XMPP network conn = yield xmpp.connect(jid, password) # Join the XMPP room room = yield conn.muc.join(roomname, "bot") # Create an XML body element and send it to the room body = xmpp.Element("body") body.text = "EHLO World" room.send(body) # Exit the room yield room.exit("Gotta go / feel the funky flow / yo") username = "******" password = "******" roomname = "xmpproom" threado.run(main(username, password, roomname))
xmppuser = '******' % (re.sub('@','%',username)) xmppmucs = "conference.clarifiednetworks.com" room = "%s@%s" % (collabinstance,xmppmucs) myxmpp = yield xmpp.connect(xmppuser,password) myxmpp.core.presence() room = yield myxmpp.muc.join(room,"/collablogger") print 'joined room' collab = CLIWiki('https://www.clarifiednetworks.com/collab/%s/' % (collabinstance)) collab.authenticate(username=username,password=password) attachFilename = "log.txt" basePage = "CollabChatLog" txt2collab = Txt2Collab(collab,basePage,attachFilename, timestampformat="%Y-%m-%d") srcjid_filter = "conference.clarifiednetworks.com" yield inner.sub(room |roomparser(srcjid_filter)| logger(txt2collab,0,delay) ) if __name__ == "__main__": import getpass username = raw_input("Collab & XMPP Username (without the @domain): ") password = getpass.getpass() threado.run(main(username, password))