MegaGlest Forum

MegaGlest => MegaGlest => Topic started by: kagu on 22 March 2014, 23:48:28

Title: [Hexchat plugin] - Alert when someone joins #megaglest-lobby
Post by: kagu on 22 March 2014, 23:48:28
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.

Code: [Select]
#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)
Title: Re: [Hexchat plugin] - Alert when someone joins #megaglest-lobby
Post by: andy_5995 on 17 January 2020, 20:48:40
Thanks Kagu

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

Code: [Select]
__module_name__ = "MG_Alert"
And also told it to play a sound:

Code: [Select]
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.