Archive for July 6th, 2004

The XChat script below catches instances of “bug 20000″ (for example) and replaces them with “http://bugzilla.mozilla.org/show_bug.cgi?id=20000″.

__module_name__ = “bugzilla”
__module_version__ = “0.1″
__module_description__ = “Bugzilla Url Converter”
__module_author__ = “Marc Liddell”

BUGZILLA_URL = lambda num: “http://bugzilla.mozilla.org/show_bug.cgi?id=” + num.group(1)

import xchat, re

def echoBug(word, word_eol, userdata):
  subs = re.sub( ‘[Bb][Uu][Gg]\s*([0-9]+)’, BUGZILLA_URL, word[1] )

  if subs != word[1]:
    xchat.emit_print(userdata[0], word[0], subs )
    return xchat.EAT_XCHAT

  else:
    return xchat.EAT_NONE

EVENTS = [
  ("Channel Action", 1),
  ("Channel Action Hilight", 1),
  ("Channel Message", 1),
  ("Channel Msg Hilight", 1)
]

for event in EVENTS:
  xchat.hook_print( event[0], echoBug, event)

I’d really like it to display “bug 20000 (http://bugzilla.mozilla.org/show_bug.cgi?id=20000)” instead. Can anyone help me out here? I’ve tried to change the BUGZILLA_URL line to

BUGZILLA_URL = lambda num: “bug ” + num.group(1) + ” (http://bugzilla.mozilla.org/show_bug.cgi?id=” + num.group(1) + “)”

and many, many other variations, but all are a no-go. Can someone help me make this script do what I want? :) I’ve tried Googling for answers with no success. I’m sure its a minor detail I’m missing, but I’ve spent a long time on it now and can’t figure it out.

Any help would be sincerely appreciated.

UPDATE: I’ve posted a fixed, updated script here (see also the comments section). Note that it requires a working Python plugin for XChat.