patxbot by patx@patxbot.tk
~learn -- to add a factoid.
~ -- to recall a factoid.
~forget -- to delete a factoid.
go to http://patxbot.tk for more info/news on this snippet. and now their is a version w/ user levels for security (just go to the site :p)
Hash table and Ini versions of this script have also been submitted:
~ Hash - http://bitbucket.org/patx/patxbot/wiki/Hash_Tables
~ .Ini - http://bitbucket.org/patx/patxbot/wiki/Ini
ALSO: patxBot new official site http://patx44.appspot.com/patxbot
; factoid script by patx (patx@patxbot.tk) (http://www.patx.tk)
; the code it licensed under the patx license version 3!!!!!!!!
; http://www.iolanguage.com/paste/p/07f3dc4a0.html <<< license.
; patxbot version 13
; by patx@patxbot.tk
; http://patxbot.tk
on *:text:~learn*:#: { %patx [ $+ [ $2 ] ] = $3-
msg $chan topic saved. }
on *:text:~forget*:#: { unset %patx [ $+ [ $2 ] ]
msg $chan the factoid $2 has been deleted. }
on *:text:~*:#: { msg $chan %patx [ $+ [ $remove($1,$left($1,1)) ] ] }
you can make it use ini's like this an also make it channel specific an if you dont want it channel specific you can change the # to learn in the ini set up. just a fast remake no error checks added.
on $*:text:/^~(learn|forget|factoid)\s(\w+)\s?(\w.+)?/iS:#: {
if (!$($+(%,factoidflood,$nick),2)) {
set -u3 $+(%,factoidflood,$nick) on
if ($regml(1) == learn && $regml(3) && !$readini(learn.ini,-n,$regml(2),#)) { writeini -n learn.ini $regml(2) # $regml(3) | msg # the factoid has been saved. }
if ($regml(1) == forget && $readini(learn.ini,-n,$regml(2),#)) { remini learn.ini $regml(2) # | msg # the factoid $regml(2) has been deleted. }
if ($regml(1) == factoid && $readini(learn.ini,-n,$regml(2),#)) { msg # $readini(learn.ini,-n,$regml(2),#)) }
}
}
meh just put it as a wiki page... http://bitbucket.org/patx/patxbot/wiki/Hash_Tables
maybe, i have grown to like the vars tho.... at first yes i liked hash tables but vars just seem so much easier ya know. anyway. @Slickone i like that snip u suggested it works. i'll keep it up here. also i may wanna put it as a branch to patxbot... if thats ok w/ u jus let me know... or u can also do it urself: http://bitbucket.org/patx/patxbot/fork/ :)
maybe do
on *:disconnect:{ .hsave learn $qt($scriptdirlearn.hsh) }
on *:exit:{ .hsave learn $qt($scriptdirlearn.hsh) }
on *:start:{ if (!$hget(learn)) { .hmake learn 100 | .hload learn $qt($scriptdirlearn.hsh) } }
on *:load:{ if (!$hget(learn)) { .hmake learn 100 | .hload learn $qt($scriptdirlearn.hsh) } }
on $*:text:/^~(learn|forget|factoid)\s(\w+)\s?(\w.+)?/iS:#: {
if (!$($+(%,factoidflood,$nick),2)) {
set -u3 $+(%,factoidflood,$nick) on
if ($regml(1) == learn && $regml(3) && !$hget(learn,$regml(2))) { hadd -m learn $regml(2) $regml(3) | msg # the factoid has been saved. }
if ($regml(1) == forget && $hget(learn,$regml(2))) { hdel learn $regml(2) | msg # the factoid $regml(2) has been deleted. }
if ($regml(1) == factoid && $hget(learn,$regml(2))) { msg # $hget(learn,$regml(2)) }
}
}
@mr_president i did go with hash tables when i was first making this script. but i kept on having an error with /hsave resulting in not being able to save the factoids when you exit mirc. with vars the code is shorter and it saves the info. the same basic script with hash is on http://bitbucket.org/patx/patxbot/src/tip/versions. feel free to use it.