This was basically just a test to learn hash tables, and it worked great! So I figured I'd put it on here.
Load into your bots remotes (ALT+R).
As a "Learn bot", you can make it learn stuff and then recall back to information about the topic. Type !learn to make the bot "learn" it. You can then recall the information by using !remember .
You can also use !forget , but you need access level 10 to the bot to use that. Type:
/auser 10 YOUR_NICKNAME
in your bots screen to set that.
Oh, and if you type /viewlearn in your bots mIRC, you can view a list of all topics and data that are currently stored within the learn bot.
Enjoy!
on *:TEXT:!learn *:#: {
if (!$3) {
notice $nick You didn't specify the right parameters.
notice $nick Syntax: !learn <topic> <description>
}
else {
hadd -m learn $strip($2) $3-
msg $chan Data $3- saved as topic: $strip($2)
}
}
on *:TEXT:!remember *:#: {
if (!$2) {
notice $nick You didn't specify the right parameters.
notice $nick Syntax: !remember <topic>
}
elseif (!$hget(learn,$strip($2))) {
msg $chan No data was found for $2 $+ .
}
else {
msg $chan Results for $strip($2) $+ : $hget(learn,$2)
}
}
on 10:TEXT:!forget *:#: {
if (!$2) {
notice $nick You didn't specify the right parameters.
notice $nick Syntax: !forget <topic>
}
elseif (!$hget(learn,$strip($2))) {
msg $chan No data was found for $strip($2) $+ .
}
else {
msg $chan Removed topic $strip($2) ( $+ $hget(learn,$strip($2)) $+ ) from the database.
hdel learn $strip($2)
}
}
alias viewlearn {
window -a @Learn
var %x = 1
while (%x <= $hget(learn,0).item) {
echo -g @Learn $hget(learn,%x).item $+ : $hget(learn,%x).data
inc %x
}
}
on *:EXIT: { hsave learn learn.txt }
on *:START: {
if (!$isfile(learn.txt)) {
noop $input(The hash table for the learn bot could not be found.,uwo,Error!)
}
else {
hmake learn 100
hload learn learn.txt
}
}
i have a script smaller than this one and it saves factoids as variables. also when i use this script the hash table does not carry over... anyway the script i came up with is http://www.hawkee.com/snippet/5853/ there. but now that script does not include a forget command so i amde another hash table one that is simpler than this also and when i saved it it worked :p that is somewhere on patx.pastebin.com lol anyway good script :: i must admit this was the first time i ound a working learn bot so i give i a 9 (would have given ten but i am having trouble with thats hash saving thing :p
Umm its a reason not an excuse , excuse implys lieing;p and don't blame me i can't rate yet.If i could rate id give it a 5 or a 6 you still need to silence those notices and messages and add flood pros (EL FTW) and you need to check if the learn file exist and create it before you /hload if (!$hget(learn)) { hmake learn amount} and other then $strip-ing everything else i haven't tested it myself.`-.-´