Author Topic: [Hexchat plugin] - Alert when someone joins #megaglest-lobby  (Read 2211 times)

kagu

  • Administrator
  • Horseman
  • ********
  • Posts: 203
    • View Profile
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)
« Last Edit: 23 March 2014, 00:08:32 by alket »
Megaglest Chat
Please support:
1. CEGUI 2. In-process games 3. Registered Players
Playtime:
Every Sunday 21:00 - 01:00 CET

andy_5995

  • Moderator
  • Ornithopter
  • ********
  • Posts: 457
  • Debian Linux user
    • View Profile
    • Andy Alt's home page
Re: [Hexchat plugin] - Alert when someone joins #megaglest-lobby
« Reply #1 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.