rendered paste bodyon *:text:Markov*:*: {
if ($2) {
%msgto = $chan
%markov.new = [ $ $+ [ $rand(2,$0) ] ]
%i = 0
while (!$readini(markov.ini,null. $+ %markov.new, 1)) {
if (%i > $0) { msg # Sorry, I can't understand that! | unset %markov.new | break | haltdef }
inc %i 1
%markov.new = [ $ $+ [ $rand(2,$0) ] ]
}
if (%markov.new) { doMarkov %markov.new }
}
else {
%msgto = $chan
doMarkov
}
}
alias doMarkov {
var %mc.limit = 400
var %mc.rstep = 0
var %mc.rn1 = null
var %mc.rn2 = null
if ($1) { %mc.rn2 = $1 | %firstfix = $1 }
var %mc.rstring
while (%mc.rstep <= %mc.limit) {
inc %mc.rstep
var %mc.rlmao = % $+ %mc.rn1 $+ . $+ %mc.rn2 $+ .step
var %mc.rand = $rand(1, [ [ %mc.rlmao ] ])
var %mc.rnext = $readini(markov.ini, [ %mc.rn1 ] $+ . $+ [ %mc.rn2 ], %mc.rand)
var %mc.rstring = %mc.rstring %mc.rnext
var %mc.rn1 = %mc.rn2
var %mc.rn2 = %mc.rnext
if ( %mc.rn2 == $null ) {
/break
}
}
; var %cat.end = $false
;while (%cat.end == $false) {
; inc %cat.step
;if ($gettok(%mc.rstring, %cat.step, 32) == $null) {
; /break
;}
; if ($readini(markcat.ini, $gettok(%mc.rstring, %cat.step, 32), place) == holder) {
; inc % $+ $gettok(%mc.rstring, %cat.step, 32) $+ .step
;/writeini markcat.ini $gettok(%mc.rstring, %cat.step, 32) % $+ $gettok(%mc.rstring, %cat.step, 32) $+ .step %mc.rstring
/msg %msgto %firstfix %mc.rstring
unset %firstfix
}
on *:TEXT:*:*: {
if (%collect == $false) {
/halt
}
var %mc.string = $1-
var %strip.step = 33
while ( %strip.step <= 47 ) {
var %mc.string = $replace(%mc.string, $chr(%strip.step), $null)
inc %strip.step
}
var %strip.step = 58
while ( %strip.step <= 64 ) {
var %mc.string = $replace(%mc.string, $chr(%strip.step), $null)
inc %strip.step
}
var %strip.step = 91
while ( %strip.step <= 96 ) {
var %mc.string = $replace(%mc.string, $chr(%strip.step), $null)
inc %strip.step
}
var %strip.step = 123
while ( %strip.step <= 255 ) {
var %mc.string = $replace(%mc.string, $chr(%strip.step), $null)
inc %strip.step
}
if ( $numtok(%mc.string,32) < 3 ) {
/halt
}
;var %mc.len = $len($1-)
var %end.reach = $false
var %mc.n1 = null
var %mc.n2 = null
var %mc.step = 0
while (%end.reach == $false) {
inc %mc.step
inc % $+ [ %mc.n1 ] $+ . $+ [ %mc.n2 ] $+ .step
var %mc.next = $replace($gettok(%mc.string, %mc.step, 32), $chr(44), $null)
if (%mc.next == $null) {
/break
}
set %mc.lmao % $+ %mc.n1 $+ . $+ %mc.n2 $+ .step
/writeini -n markov.ini [ %mc.n1 ] $+ . $+ [ %mc.n2 ] [ [ %mc.lmao ] ] %mc.next
var %mc.n1 = %mc.n2
var %mc.n2 = %mc.next
}
}