Package: feed2omb Version: 0.9.2-1 Severity: wishlist Tags: patch Hi,
after some playing with this nice piece of the software, i see that the XMPP support is very basic only. For my purposes i did two improvements: 1) connect (and authenticate) only once, not after any message (see the attached stay-connected.patch) 2) allow send messages to the XMPP MUC room (see the attached post-to-muc.patch) The second one adds two configuration options (the sample.config patched too), to allow set the room JID and the nick name for access into MUC. regards -- Slavko http://slavino.sk
Description: prevent closing XMPP connection between messages Author: Slavko <li...@slavino.sk> --- The information above should follow the Patch Tagging Guidelines, please checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here are templates for supplementary fields that you might want to add: Origin: <vendor|upstream|other>, <url of original patch> Bug: <url in upstream bugtracker> Bug-Debian: http://bugs.debian.org/<bugnumber> Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber> Forwarded: <no|not-needed|url proving that it has been forwarded> Reviewed-By: <name and email of someone who approved the patch> Last-Update: <YYYY-MM-DD> --- feed2omb-0.9.2.orig/feed2omb.py +++ feed2omb-0.9.2/feed2omb.py @@ -423,10 +423,16 @@ for thisconfig in args: #currently! jid = xmpp.protocol.JID(config['xmpp_jid']) - client = xmpp.Client(jid.getDomain(), debug=[]) - con = client.connect() - client.auth(jid.getNode(), config['xmpp_password'], - resource="feed2omb") + # check client variable existence + try: + client + except NameError: + # create client and connect, only if not connected + client = xmpp.Client(jid.getDomain(), debug=[]) + con = client.connect() + client.auth(jid.getNode(), config['xmpp_password'], + resource="feed2omb") + client.send(xmpp.protocol.Message(config['xmpp_to'], text))
Description: allow post messages into XMPP MUC room Author: Slavko <li...@slavino.sk> --- The information above should follow the Patch Tagging Guidelines, please checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here are templates for supplementary fields that you might want to add: Origin: <vendor|upstream|other>, <url of original patch> Bug: <url in upstream bugtracker> Bug-Debian: http://bugs.debian.org/<bugnumber> Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber> Forwarded: <no|not-needed|url proving that it has been forwarded> Reviewed-By: <name and email of someone who approved the patch> Last-Update: <YYYY-MM-DD> --- feed2omb-0.9.2.orig/feed2omb.py +++ feed2omb-0.9.2/feed2omb.py @@ -432,9 +432,21 @@ for thisconfig in args: con = client.connect() client.auth(jid.getNode(), config['xmpp_password'], resource="feed2omb") - - client.send(xmpp.protocol.Message(config['xmpp_to'], - text)) + # if post to room, join the room, only once too + if 'xmpp_room' in config and config['xmpp_room'] != "" and \ + 'xmpp_nick' in config and config['xmpp_nick'] != "": + client.send(xmpp.Presence(to="%s/%s" % (config['xmpp_room'], config['xmpp_nick']))) + + # send message to room or to the JID + if 'xmpp_room' in config and config['xmpp_room'] != "" and \ + 'xmpp_nick' in config and config['xmpp_nick'] != "": + msg = xmpp.protocol.Message(body=text) + msg.setTo(config['xmpp_room']) + msg.setType('groupchat') + client.send(msg) + else: + client.send(xmpp.protocol.Message(config['xmpp_to'], + text)) #Record that we have sent this entry... if sentmode == 'timestamp': --- feed2omb-0.9.2.orig/sample.config +++ feed2omb-0.9.2/sample.config @@ -29,6 +29,11 @@ xmpp_password = 1234 #Where to send the XMPP messages xmpp_to = d...@another.example.com +#Room where to send the XMPP messages +xmpp_room = deb...@xmpp.slavino.sk + +#Nick for room access +xmpp_nick = feedbot #The maximum length of message. Defaults to 140. maxlen = 140
signature.asc
Description: PGP signature