News:

Please help making MegaGlest rock-stable by testing the pre-release snapshots.

Main Menu

[Hexchat plugin] - Alert when someone joins #megaglest-lobby

Started by kagu, 22 March 2014, 23:48:28

kagu

This works only for Ubuntu since it uses "notify-send", maybe there is a general notification system but I don't know.

Usage:
1. Copy code and save it somewhere as mgalert.py
2. In Hexchat: Menu > Window > Plugins and Scripts
3. In Plugins and Scripts: Load > mgalert.py

If you have installed megaglest in home directory it should display an icon.


#https://www.gnu.org/copyleft/gpl.html
__module_name__ = "MG Alert"
__module_version__ = "1.0"
__module_description__ = "Makes an alert when someone joins megaglest-lobby"

import hexchat, subprocess, getpass

def join_cb(word, word_eol, userdata):
channel = word_eol[2]
channel = channel[:16]
if channel == "#megaglest-lobby":
user = str.split(word[0] , "!")
user = user[0][1:len(user[0])]
prefix = user[:3]
if prefix == "MG_":
user = str.split(user, "_")
user = user[1]
subprocess.call(['notify-send', '-i', '/home/'+getpass.getuser()+'/megaglest/megaglest.ico','Megaglest',user+' has joined.'])

hexchat.hook_server("join", join_cb)
Megaglest Chat
Please support:
1. CEGUI 2. In-process games 3. Registered Players
Playtime:
Every Sunday 21:00 - 01:00 CET

andy_5995

Thanks Kagu

Error if no module name is defined, so I added this to the top:

__module_name__ = "MG_Alert"

And also told it to play a sound:

subprocess.call(['play', '/home/andy/Music/Local/chat_alert.ogg'])

When I load it, it works, but doesn't show up in the addons list. Guess that's a Hexchat bug or I am just frickin' off my nut again.