Release 0.3.

Force message type to 'chat', ignore deprecation warnings,
update some notes.
This commit is contained in:
Jacob Peddicord
2011-07-31 22:04:33 -04:00
parent fec4a9b403
commit 8fd37e7ee7
2 changed files with 68 additions and 27 deletions

24
README Normal file
View File

@@ -0,0 +1,24 @@
When loaded, this plugin will send you a message over XMPP (Jabber) when a
highlighted message or a private message is received. Great for running under
a detatched terminal where you're not always looking at your IRC window.
Changelog:
* 0.3:
- Fixed message type to 'chat'; should fix problems with offline send
and XML embedded in the message on some receivers
- Updated notes for using an XMPP resource
- Removed "failed to send" notification, as it's normal flow
You must configure this plugin before using:
JID messages are sent from:
/set plugins.var.python.highlightxmpp.jid someid@jabber.org
alternatively, to use a specific resource:
/set plugins.var.python.highlightxmpp.jid someid@jabber.org/resource
Password for the above JID:
/set plugins.var.python.highlightxmpp.password abcdef
JID messages are sent *to* (if not set, defaults to the same jid as above):
/set plugins.var.python.highlightxmpp.to myid@jabber.org

View File

@@ -1,6 +1,7 @@
# HighlightXMPP for IRC. Requires WeeChat >= 0.3.0. # HighlightXMPP 0.3 for IRC. Requires WeeChat >= 0.3.0 and Python >= 2.6.
# Repo: https://github.com/jpeddicord/weechat-highlightxmpp
# #
# Copyright (c) 2009-2010 Jacob Peddicord <jpeddicord@ubuntu.com> # Copyright (c) 2009-2011 Jacob Peddicord <jpeddicord@ubuntu.com>
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@@ -18,21 +19,31 @@
####### #######
# #
# You must configure this plugin before using: # You must configure this plugin before using:
#
# JID messages are sent from: # JID messages are sent from:
# /set plugins.var.python.highlightxmpp.jid someid@jabber.org # /set plugins.var.python.highlightxmpp.jid someid@jabber.org
# alternatively, to use a specific resource:
# /set plugins.var.python.highlightxmpp.jid someid@jabber.org/resource
#
# Password for the above JID: # Password for the above JID:
# /set plugins.var.python.highlightxmpp.password abcdef # /set plugins.var.python.highlightxmpp.password abcdef
# JID messages are sent *to* (if not set, defaults to the same jid): #
# /set plugins.var.python.highlightxmpp.jid myid@jabber.org # JID messages are sent *to* (if not set, defaults to the same jid as above):
# /set plugins.var.python.highlightxmpp.to myid@jabber.org
from time import sleep from time import sleep
import warnings
import weechat as w import weechat as w
import xmpp
# the XMPP module currently has a lot of deprecations
with warnings.catch_warnings():
warnings.simplefilter("ignore")
import xmpp
info = ( info = (
'highlightxmpp', 'highlightxmpp',
'Jacob Peddicord <jpeddicord@ubuntu.com>', 'Jacob Peddicord <jpeddicord@ubuntu.com>',
'0.2', '0.3',
'GPL3', 'GPL3',
"Relay highlighted & private IRC messages over XMPP (Jabber)", "Relay highlighted & private IRC messages over XMPP (Jabber)",
'', '',
@@ -69,15 +80,22 @@ def connect_xmpp():
def send_xmpp(data, signal, msg, trial=1): def send_xmpp(data, signal, msg, trial=1):
global client global client
# ignore XMPP's deprecation warnings
with warnings.catch_warnings():
warnings.simplefilter("ignore")
# connect to xmpp if we need to # connect to xmpp if we need to
if not connect_xmpp(): if not connect_xmpp():
return w.WEECHAT_RC_OK return w.WEECHAT_RC_OK
jid_to = w.config_get_plugin('to') jid_to = w.config_get_plugin('to')
# send to self if no target set # send to self if no target set
if not jid_to: if not jid_to:
jid_to = w.config_get_plugin('jid') jid_to = w.config_get_plugin('jid')
# send the message # send the message
msg = xmpp.protocol.Message(jid_to, msg) msg = xmpp.protocol.Message(jid_to, msg, typ='chat')
try: try:
client.send(msg) client.send(msg)
except IOError: except IOError:
@@ -87,7 +105,6 @@ def send_xmpp(data, signal, msg, trial=1):
if trial > 3: if trial > 3:
w.prnt('', "XMPP: Could not send to server.") w.prnt('', "XMPP: Could not send to server.")
else: else:
w.prnt('', "XMPP: Sending failed. Trying again...")
sleep(0.5) sleep(0.5)
send_xmpp(data, signal, msg, trial + 1) send_xmpp(data, signal, msg, trial + 1)
return w.WEECHAT_RC_OK return w.WEECHAT_RC_OK