mirror of
https://github.com/gryf/weechat-highlightxmpp.git
synced 2025-12-18 03:50:22 +01:00
Release 0.3.
Force message type to 'chat', ignore deprecation warnings, update some notes.
This commit is contained in:
24
README
Normal file
24
README
Normal 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
|
||||
@@ -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
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -18,21 +19,31 @@
|
||||
#######
|
||||
#
|
||||
# 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):
|
||||
# /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
|
||||
import warnings
|
||||
import weechat as w
|
||||
|
||||
# the XMPP module currently has a lot of deprecations
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore")
|
||||
import xmpp
|
||||
|
||||
info = (
|
||||
'highlightxmpp',
|
||||
'Jacob Peddicord <jpeddicord@ubuntu.com>',
|
||||
'0.2',
|
||||
'0.3',
|
||||
'GPL3',
|
||||
"Relay highlighted & private IRC messages over XMPP (Jabber)",
|
||||
'',
|
||||
@@ -69,15 +80,22 @@ def connect_xmpp():
|
||||
|
||||
def send_xmpp(data, signal, msg, trial=1):
|
||||
global client
|
||||
|
||||
# ignore XMPP's deprecation warnings
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore")
|
||||
|
||||
# connect to xmpp if we need to
|
||||
if not connect_xmpp():
|
||||
return w.WEECHAT_RC_OK
|
||||
jid_to = w.config_get_plugin('to')
|
||||
|
||||
# send to self if no target set
|
||||
if not jid_to:
|
||||
jid_to = w.config_get_plugin('jid')
|
||||
|
||||
# send the message
|
||||
msg = xmpp.protocol.Message(jid_to, msg)
|
||||
msg = xmpp.protocol.Message(jid_to, msg, typ='chat')
|
||||
try:
|
||||
client.send(msg)
|
||||
except IOError:
|
||||
@@ -87,7 +105,6 @@ def send_xmpp(data, signal, msg, trial=1):
|
||||
if trial > 3:
|
||||
w.prnt('', "XMPP: Could not send to server.")
|
||||
else:
|
||||
w.prnt('', "XMPP: Sending failed. Trying again...")
|
||||
sleep(0.5)
|
||||
send_xmpp(data, signal, msg, trial + 1)
|
||||
return w.WEECHAT_RC_OK
|
||||
|
||||
Reference in New Issue
Block a user