A dictionary I made for my bot. It's pretty simple to use:
!addef (word) (definition)
!deldef (word)
!editdef (word) (definition)
!viewdictionary
!define (word)
Please type: /set %myowner (owner) in the bot's mirc so that it will respond to you.
; Dictionary
; by simplicity
on *:LOAD:{
echo $color(info) -a Setup for bot owner..
set %myowner $?="enter the nick you wish to set as the owner for this script"
}
on *:TEXT:*:#:{
if ($nick iswm %myowner) {
;dictionary
if ($1 iswm !addef) && ($2-3) {
while (!$readini(bot.ini,words,$2)) {
writeini -n bot.ini words $2 $3-
notice $nick Word $2 has been added!
halt
}
if ($readini(bot.ini,words,$2)) { notice $nick Definition $+(',$2,') is in the dictionary! | halt }
}
if ($1 iswm !deldef) && ($2) {
while ($readini(bot.ini,words,$2)) {
remini bot.ini words $2
notice $nick Word $2 has been deleted.
halt
}
if (!$readini(bot.ini,words,$2)) { notice $nick Definition $+(',$2,') in the dictionary! | halt }
}
if ($1 iswm !editdef) && ($2-3) {
while ($readini(bot.ini,words,$2)) {
writeini -n bot.ini words $2 $3-
notice $nick Word $2 has been edited.
halt
}
if (!$readini(bot.ini,words,$2)) { notice $nick Definition $+(',$2,') isn't in the dictionary! | halt }
}
if ($1 iswm !viewdictionary) { run bot.ini }
if ($1 iswm !define) && ($2) {
while ($readini(bot.ini,words,$2)) {
msg $chan Definition for word $+($2,:) $readini(bot.ini,words,$2)
halt
}
if (!$readini(bot.ini,words,$2)) { notice $nick Definition $+(',$2,') isn't in the dictionary! | halt }
}
}
}
why \"if ($nick [b]iswm] %myowner) {\" ?
someone could simply use a similar nick to the owner and delete every word ... and for the other if\'s, u should use ==
No, not really. It would have to use $+(,%myowner,) or something similar to match the nick. Just %myowner would make the script make sure it was positively %myowner.
Try it using something like this:
alias testnick {
if ($1 iswm Rebellious) { echo -a Match! }
else { echo -a No match! }
}
/testnick Rebellious would return Match! while /testnick Rebellious1 would return No match!
But yes, this snippet has a LOT of room for improvement.
why \"if ($nick [b]iswm] %myowner) {\" ?
someone could simply use a similar nick to the owner and delete every word ... and for the other if\'s, u should use ==
for the if $2-3, u only need if $3 because if there is a $3, there\'s automatically a $2
and rather than using while, use if and else
and rather than halting, put a . in front of the command (.notice $nick ...)