[Frugalware-darcs] vmexam: python/irssi/prefix: import

VMiklos vmiklos at frugalware.org
Fri Jun 22 00:51:11 CEST 2007


Darcsweb-Url: http://darcs.frugalware.org/darcsweb/darcsweb.cgi?r=vmexam;a=darcs_commitdiff;h=20070621225056-e2957-1b998fe52b795b5bc6ec3b21c46b0a26ece4d1dd.gz;

[python/irssi/prefix: import
VMiklos <vmiklos at frugalware.org>**20070621225056] {
addfile ./python/irssi/prefix.py
hunk ./python/irssi/prefix.py 1
+"""
+	prefix each message
+
+	type /py load prefix to load it
+
+	changelog:
+	- 0.2: rewritten in python
+	- 0.1: initial perl script by Gabor Adam TOTH
+"""
+
+__author__ = "Miklos Vajna <vmiklos at frugalware.org>"
+__version__ = "0.2"
+__date__ = "Fri, 22 Jun 2007 00:44:12 +0200"
+__copyright__ = "Copyright (c) 2007 Miklos Vajna"
+__license__ = "GPL"
+
+import irssi, re
+
+def send(msg, server, witem):
+	prefix = irssi.settings_get_str("prefix")
+	targets = irssi.settings_get_str("prefix_targets")
+	cmdchars = irssi.settings_get_str("cmdchars")
+	if re.match("^([%s]|%s)" % (cmdchars, prefix), msg):
+		return
+	if not check_target(witem.name, targets):
+		return
+	signal = irssi.signal_get_emitted()
+	msg = "%s%s" % (prefix, msg)
+	irssi.signal_stop()
+	irssi.signal_emit(signal, msg, server, witem)
+
+def check_target(target, targets):
+	target = target.lower()
+	targets = targets.lower().split(' ')
+	if target in targets or targets[0] == "*":
+		return True
+
+irssi.settings_add_str(__name__, 'prefix', '')
+irssi.settings_add_str(__name__, 'prefix_targets', '*')
+irssi.signal_add("send command", send)
}


More information about the Frugalware-darcs mailing list