Skip to content

Instantly share code, notes, and snippets.

@Darkhogg
Last active August 29, 2015 14:22
Show Gist options
  • Save Darkhogg/333ca79ee42dfd7c15d5 to your computer and use it in GitHub Desktop.
Save Darkhogg/333ca79ee42dfd7c15d5 to your computer and use it in GitHub Desktop.
HexChat script for Werebot

Werebot HexChat Helper

This simple Python script will make a few repetitive tasks easy when playing Werebot. What it does is:

  • Sends any Werebot commands directly to the bot, which prevents the disclosure of your role by accidentaly sending a command at the wrong time and makes it easier to use commands at night (i.e., when the channel is fully muted).
  • Automatically joins any of the official Werebot channels when the bot invites you, particularly useful for auto-joining the werewolf channel.

To install it, you will need both HexChat and Python 2.7 installed. Download and install them from https://hexchat.github.io/downloads.html. When installing HexChat, be sure to select and install the Python 2.7 plugin.

Afterwards, download the werebot-helper.py file and save it to the appropriate location:

  • Windows: %APPDATA%\HexChat\addons\
  • Linux and Mac: ~/.config/hexchat/addons/

You will need to restart HexChat. To check that the script is correctly installed, check that HexChat displays a message with the name and version of the script (werebot-helper vX.Y.Z) right after starting.

from __future__ import print_function, division
import hexchat
__module_name__ = "werebot-helper"
__module_version__ = "1.0.0"
__module_description__ = "Werebot Helper Script"
channels = {
'#werebot': 'Werebot',
'#werebot.lair': 'Werebot',
'#werebot.talk': 'Werebot',
'#weretest': 'Weretest',
'#weretest.lair': 'Weretest',
'#weretest.talk': 'Weretest',
}
def on_send_msg(word, word_eol, userdata):
ctx = hexchat.get_context()
chan = ctx.get_info('channel')
if chan in channels:
botname = channels[chan]
if word_eol[0].startswith('!'):
hexchat.command('msg {} {}'.format(botname, word_eol[0]))
return hexchat.EAT_ALL
def on_invited(word, word_eol, userdata):
ctx = hexchat.get_context()
inviter = word[1]
channel = word[0]
if channel in channels and channels[channel] == inviter:
hexchat.command('join {}'.format(channel))
hexchat.prnt('\x02{}\x02 \x1dv{}\x1d'.format(__module_name__, __module_version__))
hexchat.hook_command('', on_send_msg, priority=hexchat.PRI_HIGH)
hexchat.hook_print('Invited', on_invited)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment