Open lehmannro opened 14 years ago
TiHKAL's legacy implementation:
$regexdecide($remove($5-,$chr(44)),$asciicount($gettok($address($gettok($right($1,-1),1,33),1),1,64)))
; $5- is the set of decisions
; $chr(44) is a comma
; $address(1) returns an unmasked ident and host mask, as in:
; *!*nexus@NexuS.users.quakenet.org (for nexus!~nexus@...)
alias regexdecide {
$iif($regex($1,/(".+?"|(?<!").+?(?!"))(?:\s|$)/g),)
set %i 1
unset %return
while (%i <= $regml(0)) {
if (!%return) set %return $regml(1)
else set %return $+(%return,$chr(44),$regml(%i))
inc %i
}
if ($2 isnum) var %decideadd = $2
tokenize 44 $sorttok(%return,44)
if ($2) return für $($+($, $calc((($asciicount($1-) + $asciicount($date)) + $right(%decideadd,2)) % $0 +1)),2)
else return $iif($+($calc((($asciicount($1-) + $asciicount($date)) % $right(%decideadd,2) % 2) +1)) == 1,dafür,dagegen)
}
pyhkal.contrib.decide
provides a Decision Finding Algorithm (DFA, see Knuth for details on that topic). We should settle that algorithm in a way that satisfies our requirements, which are as-of-now unclear.We could either try to resemble TiHKAL's legacy algorithm as closely as possible, giving up on multi-protocol support (or abstraction, for that matter). Every other solution involves relying only on Identities which additionally yields per-Identity decisions.