Python - CTCP Action fixer
Mon, 07/07/2008 - 01:09
Thought this would be useful for xchat users on IrCQ stop all those broken CTCP ACTION's (/me)
# Ctcp action fixer.<br />
# Copyright Iain Cambridge<br />
# Covered by BSD License<br />
##########################<br />
#Copyright (c) 2008, Iain Cambridge<br />
#All rights reserved.<br />
#Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following #conditions are met:<br />
#<br />
#Redistributions of source code must retain the above copyright notice, this list of conditions and the following #disclaimer.<br />
#Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following #disclaimer in the documentation and/or other materials provided with the distribution.<br />
#Neither the name of the Iain Cambridge nor the names of its contributors may be used to endorse or promote products #derived from this software without specific prior written permission.<br />
#<br />
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS<br />
#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT<br />
#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR<br />
#A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR<br />
#CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,<br />
#EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,<br />
#PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR<br />
#PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF<br />
#LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING<br />
#NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS<br />
#SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</p>
<p>__module_name__ = "CTCP ACTION fixer"<br />
__module_version__ = "1.0"<br />
__module_description__ = "Fixes broken CTCP ACTIONs on IrCQ"<br />
__module_author__ = "Iain Cambridge "</p>
<p>import xchat, string</p>
<p>def broken_action(word, word_eol, userdata):<br />
data = string.split(word[1], " ")<br />
if (data[0] == "\x01ACTION"):<br />
i = 0<br />
line = ""<br />
for words in data:<br />
if (words != "\x01ACTION"):<br />
line = line + words + " "</p>
<p> action = [word[0], line]<br />
if (userdata == "chan"):<br />
type = "Channel Action"<br />
elif (userdata == "chan"):<br />
type = "Channel Action Hilight"<br />
else:<br />
type = "Channel Action"<br />
xchat.emit_print(type, *action)<br />
return xchat.EAT_XCHAT</p>
<p>def unload_script(userdata):<br />
print "CTCP ACTION fixer unloaded." </p>
<p>xchat.hook_print("Channel Message",broken_action, "chan")<br />
xchat.hook_print("Private Message to Dialog",broken_action, "pvt")<br />
xchat.hook_print("Channel Msg Hilight",broken_action, "hi")<br />
xchat.hook_unload(unload_script) </p>
<p>print "CTCP ACTION fixer loaded."
