on *:text:*:#: {
if ($1 == ?) {
var %text = $2- =>
%text = $read(learnt.txt, w, %text $+ *)
;if "this entry*" is found at the beginning of a line,
if (%text) {
var %term = $reptok(%text,=>,is,1,32)
msg $chan hmm, %term
}
}
if ($1 == !append) {
var %islocation = $findtok($2-,is,1,32)
if (%islocation) {
var %text = $2-
%text = $reptok(%text,is,=>,1,32)
var %newentry = $gettok(%text,1- $+ %islocation,32)
var %findentry = $read(learnt.txt,w,%newentry $+ *)
var %foundentry = $gettok(%findentry,1- $+ %islocation,32)
if (%newentry == %foundentry) {
var %append = $gettok(%text,$calc(%islocation +1) $+ -,32)
write -l $+ $readn learnt.txt %findentry or %append
msg $chan Appended data.
}
}
}
if ($1 == !replace) {
var %islocation = $findtok($2-,is,1,32)
if (%islocation) {
var %text = $2-
%text = $reptok(%text,is,=>,1,32)
write -l $+ $readn learnt.txt %text
msg $chan Replaced entry.
}
}
if ($1 == !learn) {
var %islocation = $findtok($2-,is,1,32)
if (%islocation) {
var %text = $2-
%text = $reptok(%text,is,=>,1,32)
var %newentry = $gettok(%text,1- $+ %islocation,32)
var %findentry = $read(learnt.txt,w,%newentry $+ *)
var %foundentry = $gettok(%findentry,1- $+ %islocation,32)
if (%newentry == %foundentry) {
msg $chan Already have something for that.
}
else {
write learnt.txt %text
;write this to a file: this entry => that info
;after it's done writing verify that the data did write to the file and if so have it tell you "ok".
if ($read(learnt.txt,w,%text)) { msg $chan ok }
else { msg $chan I pooped my pants }
}
}
}
}