Created
October 27, 2017 18:55
-
-
Save rezemika/cf37d68df4e02a44735a7696e9880880 to your computer and use it in GitHub Desktop.
Weechat join notificator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To place in ~/.weechat/python/autoload/ | |
import weechat | |
import pynotify | |
APP_NAME = "JoinNotificator" | |
AUTHOR = "rezemika" | |
__version__ = "0.1.0" | |
weechat.register( | |
APP_NAME, | |
AUTHOR, | |
__version__, | |
"GPLv3", | |
"A simple script which send a notification when someone joins on a channel.", | |
"shutdown", | |
'' | |
) | |
MONITORED_CHANNELS = [ | |
"##zestedesavoir", | |
] | |
MONITORED_USERS = [ | |
"nickname1", | |
"nickname2", | |
] | |
pynotify.init(APP_NAME) | |
def shutdown(): | |
return | |
def join_hook(data, signal, signal_data): | |
server = signal.split(",")[0] | |
msg = weechat.info_get_hashtable("irc_message_parse", {"message": signal_data}) | |
nick = msg["nick"] | |
channel = msg["channel"] | |
if channel in MONITORED_CHANNELS and nick in MONITORED_USERS: | |
formated_msg = "{nick} a rejoint le canal {channel} !".format( | |
nick=nick, | |
channel=channel | |
) | |
n = pynotify.Notification( | |
APP_NAME, | |
formated_msg | |
) | |
n.set_urgency(pynotify.URGENCY_NORMAL) | |
n.set_timeout(30000) | |
n.show() | |
weechat.prnt('', formated_msg) | |
return weechat.WEECHAT_RC_OK | |
weechat.hook_signal("*,irc_in2_join", "join_hook", "") | |
weechat.prnt("", APP_NAME + " is loaded!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment