Skip to content

Instantly share code, notes, and snippets.

@antonva
Created December 24, 2013 03:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antonva/8108297 to your computer and use it in GitHub Desktop.
Save antonva/8108297 to your computer and use it in GitHub Desktop.
import weechat as w
import re
# Registstration variables.
SCRIPT_NAME = "greentext"
SCRIPT_AUTHOR = "Anton Vilhelm Asgeirsson <anton@antonvilhelm.is>"
SCRIPT_VERSION = "0.0.1"
SCRIPT_LICENSE = "MULTIPASS"
SCRIPT_DESC = "Change messages starting with '>' to green text."
# Registration function.
w.register(
SCRIPT_NAME,
SCRIPT_AUTHOR,
SCRIPT_VERSION,
SCRIPT_LICENSE,
SCRIPT_DESC,
"",""
)
def greentext_cb(data, modifier, modifier_data, string):
try:
nick, msg = string.split('\t')
except ValueError, e:
return string
if msg[0] == '>':
return "%s\t%s%s" % (nick, w.color('green'), msg)
else:
return string
w.prnt("", "%s>Implying that greentext has loaded." % w.color('green'))
w.hook_modifier("weechat_print", "greentext_cb", "")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment