Omnimaga
General Discussion => Technology and Development => Computer Projects and Ideas => Topic started by: XVicarious on October 19, 2011, 08:34:53 pm
-
Hey all, I have been working on a new script called IrmageBoard and it is for X-Chat! It is written in Python. Here are the features:
-- >greentext
-- Filters (if you don't know what they are, it changes words like "moot" into "missingno" , and "missingno" is colored)
-- /facepalm command (*XVicarious facepalms at Juju :P)
-- Update the filter list (stored on a webserver) without reloading the plugin with "/irmage update filter"
-- See the update log of the script with "/irmage log"
Upcoming Features:
-- Update the script with "/irmage update script"
-- Add configurations for servers and channels!
Bugs:
-- NONE! (I hope :D)
Download: http://xvicario.us/getfile.php?f=IrmageBoard.py (v0.5.0)
Development Version:
You need to have PyYaml for this plugin installed!
Here is an example of a filters.yml (the first word is the word to be replaced, the second is the word to replace with)
lol : Laughing Out Loud
jkag : Pure Awesomeness :D
The readme for the next version (v0.7.0)
Also, I need suggestions on features to add to my plugin! I know it needs more features!
-
v0.5.5 released. Fixed the bug and added /facepalm <facepalm at this>
-
Lol nice, although at first because of the name I thought it was some sort of 4chan image board but for display in X-Chat instead of a browser. :P
Make sure people won't abuse facepalm though, because facepalming at other ppl in omni might get the command user banned x.x
-
Taht is true. Oh and a note, most of the filters are inappropriate for Omnimaga since it was made for another server where the rules are more lax. If you guys want, I'll host a special version of the filter for Omnimaga use. But you have to come up with the filter ideas.
IE, lobster filters to Netham45
-
Ok it migth be best. Swearing is allowed here but if it got too bad (like two swear per sentence in average) or if there'S too much caps lock it would be a problem.
-
I know its allowed, but just the types of words I used I have never heard here, so yeah.
-
Oh ok, yeah you migth want to be careful about that. Also at some other places you gotta be careful too since you might be labelled as bigot or something even if you are just pissed at Microsoft for example.
(which is even worse with the fact that a person gets pissed at M$ an average of 8 hours a day)
-
But if people want to use it here, please give me some ideas for filters here :)
-
Why not configuring the filters per channel? So you could have one filter list for #omnimaga and one for some other channel, etc.
-
That is a good idea... I'll look into it. It will require a configuration file... I'll just use YAML again since INI was giving me problems for XTranzlator
-
Updated first post. Added readme for the next version.
v0.7.0 is aimed for Friday, 11 November 2011! (not working at all this week, will have LOTS of time!)
(and please give me more ideas for features)
-
This is an idea that can from IRC today: Creating a /punch script
so is the filter for this like the builtin filter for XChat just with the terms stored on a server?
-
Does the script let people enable/disable individual features by the way? For example if someone doesn't want the script's racial/bigot jokes to work but still want the other stuff, or vice-versa?
-
Yes DJ_O. You can disable certain features. Everything is automatically off when you are on a channel. You can also have separate filter files for each channel.
-
Good to hear. Is there also flood control for commands requiring user input?
-
User input doesn't show up in the IRC channel. Its all local. The output, no, because its normal words and stuff. Just possibly altered.
EDIT: If anyone wants to write me a configuration system using xml.etree.ElementTree, please do. I've been working and I'm all fucked up...
Sample Config:
<config>
<irc.omnimaga.org>
<Omnimaga>
<greentext val="0" />
<filters val="0" />
<filter-url val="null" />
</Omnimaga>
<IRP>
<greentext val="1" />
<filters val="1" />
<filter-url val="http://xvicario.us/irmageboard/irp.yml" />
</IRP>
</irc.omnimaga.org>
</config>
And my current code...
__module_name__ = "IrmageBoard"
__module_version__ = "0.5.5"
__module_description__ = "Liek a real imageboard guies (without the images!!!1)"
tinyVersion = 55
import xchat, string, re, random, yaml, sys, os, StringIO
import xml.etree.ElementTree as ElementTree
from urllib2 import urlopen
ymlFilter = urlopen("http://xvicario.us/irmageboard/filters.yml")
myFilter = yaml.load(ymlFilter)
ymlFilter.close()
configPath = "".join([re.sub('\IrmageBoard.py$', '', os.path.realpath(__file__)),"irmageconfig.xml"])
myConfig = open(configPath)
myCfg = ElementTree.parse(myConfig)
myConfig.close()
print "\0034>>>>>",__module_name__, __module_version__, "has been loaded <<<<<\003"
def greenText(word, word_eol, userdata):
if word_eol[0].find('>'):
return xchat.EAT_NONE
else:
xchat.command(" ".join(["msg", xchat.get_info("channel"), ''.join(["3",word_eol[0]])]))
return xchat.EAT_ALL
def filters(word, word_eol, userdata):
newString = word_eol[0]
for k, v in myFilter.iteritems():
tempColor = random.randrange(0,16,1)
tempBack = random.randrange(0,16,1)
while (tempColor == tempBack):
tempColor = random.randrange(0,16,1)
tempBack = random.randrange(0,16,1)
tempReplace = re.compile(k, re.IGNORECASE)
newString = tempReplace.sub("".join(["\003", str(tempColor), ",", str(tempBack), v, "\003"]), newString)
xchat.command(" ".join(["msg", xchat.get_info("channel"), newString]))
return xchat.EAT_ALL
def irmageCommand(word, word_eol, userdata):
try:
if word[1] == "filters":
if word[2] == "on":
filterHook = xchat.hook_command("", filters)
print "\0034Filters are now on! GO AT IT!\003"
if word[2] == "off":
xchat.unhook(filterHook)
print "\0034You turned filters off :(\003"
if word[1] == "log":
log = urlopen("http://xvicario.us/irmageboard/log.txt")
print log.read()
log.close()
if word[1] == "about":
print __module_name__," v",__module_version__,"\nWritten by Brian J Maurer (XVicario.us, contact at [email protected])\nThis plugin adds features to XChat like an imageboard's \"\0033>greentext\003\" and filters (like when you type \"jew\" it turns into \"\0035,3Steve Jobs\003\". Many more features are to come :D"
if word[1] == "update":
if word[2] == "filter":
print "\0034Updating Filters...\003"
global ymlFilter
ymlFilter = urlopen("http://xvicario.us/irmageboard/filters.yml")
global myFilter
myFilter = yaml.load(ymlFilter)
ymlFilter.close()
print "\0034Filters are Updated!\003"
"""
if word[2] == "script":
myversion = urlopen("http://xvicario.us/irmageboard/version")
myversion = int(myversion.read())
if (myversion == tinyVersion):
print "\0034NO UPDATE FOUND!\003"
elif (myversion > tinyVersion):
print "\0034UPDATE FOUND!\003"
print "\0034Downloading Update...\003"
update = urlopen("http://xvicario.us/irmageboard/update")
update = update.read()
irmageBoard = open("IrmageBoard.py","w")
irmageBoard.write(update)
irmageBoard.close()
print "\0034Update Successful!\003"
else:
print "\0034ARE YOU FROM THE FUTURE!?\003"
"""
if word[1] == "dump":
global myCfg
myCfg2 = ElementTree.tostring(myCfg)
print myCfg
print xchat.get_info("server")
if word[1] == "add":
if word[2] == "server":
myConfig = open("".join([re.sub('\IrmageBoard.py$', '', os.path.realpath(configPath))]),"r+")
ircfg = myConfig.read()
ircfg = ElementTree.XML(ircfg)
newServer = ElementTree.Element(xchat.get_info("server"))
ircfg.append(newServer)
cfgFile = StringIO.StringIO()
ircfg = ElementTree.tostring(ircfg)
print type(ircfg), ircfg
ircfg = cfgFile.write(ircfg)
ircfg = ElementTree.parse(ircfg)
ircfg.write(myConfig)
myConfig.close()
except IndexError:
print "\0034Welcome to the IrmageBoard Plugin! For a brief help type '/help irmage'.\003"
return xchat.EAT_ALL
def facepalm(word, word_eol, userdata):
xchat.command("ME facepalms at " + word_eol[1])
xchat.EAT_ALL
# Hook the commands :D
xchat.hook_command("IRMAGE", irmageCommand, help="Usage:\n/irmage filters <on/off> -- Turn the filters on or off\n/irmage log -- Display the changelog of the plugin (downloaded from XVicario.us)\n/irmage about -- Display an about text\n/irmage update filter -- update the list of word filters, when you load the script you will automatically have this, but if something changes when the script is loaded, just run this and you have the new filtes ;D")
xchat.hook_command("", filters)
xchat.hook_command("", greenText)
xchat.hook_command("facepalm",facepalm)
-
Well I meant so if someone messages the bot a command about 1000 times in a row, it doesn't flood the hell out of IRC channels, causing your bot to be K-lined from efnet and stuff for spamming. Some people really don't know when to stop when they start having fun with something on IRC. Eg: Runer112 z80 commands will /ignore an user for one minute if that user uses !z80 more than 3 times a minute.
-
Ah I see what you mean (it has been quite a while lol). It isn't a bot, but a local script that is run in your and only your instance of X-Chat. the only things that someone outside would see are the effects of the filters or greentext. (or the facepalm command)