Learn & Regurgitate Bot

By Jonesy44 on Jun 21, 2009

What is this?
Another, but working, simple (!)learn and (!)say bot. This was made by request for a friend of mine.

Commands
As a user:-
[!@]say <topic> - returns topic's data [!@]learn - adds topic & data to bot
As the bot:-
/remsay - remove a "say" topic
/saylist [-o] - echo say list location, -o switch opens the file

; say/learn bot
; by jonesy44
; /remsay - remove a say
; /saylist [-o] - echo say list location, -o switch opens the file.

on $*:text:/^[!`@](say|learn)\s?(.*)$/Si:#: {
  var %key = $gettok($regml(2),1,32), %dt = $gettok($regml(2),2-,32)
  if $regml(1) == say {
    if (!%key) { var %y = $r(1,$lines(say.dat)) | msg # $+(,%y,/,$lines(say.dat),) $+(,$gettok($read(say.dat,%y),1,32),) - $gettok($read(say.dat,%y),2-,32) }
    elseif ($read(say.dat,s,%key)) msg # $+(,%key,) - $v1
    else msg # Nothing saved for $+(,%key,)
  }
  elseif $regml(1) == learn {
    if (!$read(say.dat,s,%key)) { write say.dat %key %dt | msg # Data for $+(,%key,) has been saved as $qt(%dt) }
    else msg # Data for $+(,%key,) already exists
  }
}
alias remsay {
  var %r = $$input(Data topic to be removed,eq,Remove Say Data)
  if ($read(say.dat,s,%r)) { write $+(-ds,%r) say.dat | noop $input(Data removed,oi,Remove Say Data) }
  else noop $input(No data found for $qt(%r),wo,Remove Say Data)
}
alias saylist $iif($1 == -o,run,echo -a) $+($mircdir,say.dat)

Comments

Sign in to comment.
PATX   -  Jun 23, 2009

Yes. I like the point and the coding is pretty nice. :) Good job!

 Respond  
Jonesy44   -  Jun 23, 2009

Most people do have these lol. But based on the coding? You'd say it's good?

 Respond  
^Neptune   -  Jun 23, 2009
  • Neptune barfs.
 Respond  
PATX   -  Jun 22, 2009

meh... i have my own version of this... but its still good 5.4/10

 Respond  
Jonesy44   -  Jun 22, 2009

Updated - Hawkee stripped the backslashed for some reason.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.