# Zug benachrichtigung im IRC Channel # Testet with Skrupel 0.96 and Eggdrop 1.6.15 # first edit: 06.Mar.2004 # last edit: 14.Mar.2004 package req http # irc befehle: set ::SkrupelTrigger ! set ::SkrupelFlags - set ::SkrupelChan #skrupel# set ::SkrupelSite "http://localhost:81/~skrupel/" #set ::SkrupelSite "http://skrupel.b0rk.de" #set ::SkrupelSite "http://skrupel.b0rk.de:81" bind pubm $::SkrupelFlags "${::SkrupelChan} ${::SkrupelTrigger}*" {skrupel:pubm} set ::SkrupelVer 0.2 set ::SkrupelTopicAppend "Browser: http://skrupel.b0rk.de/browser.php - Register: http://skrupel.b0rk.de/register.php - Help: http://info.skrupel.de/ - Forum: http://berlin.b0rk.de/forum/viewforum.php?f=12" if ![info exist ::SkrupelNames] {set ::SkrupelNames [list]} if ![info exist ::SkrupelZug] {set ::SkrupelZug [list]} if ![array exist ::SkrupelWatch] { array set ::SkrupelWatch {-1 {-1 -1 -1 -1}} } bind time - "55 *" skrupel:zug bind time - "10 *" skrupel:zug bind time - "25 *" skrupel:zug bind time - "40 *" skrupel:zug proc skrupel:zug args { set query $::SkrupelSite; #Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0) set cyagent "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0; SkrupelBot $::SkrupelVer)"; set token [http::config -useragent $cyagent]; catch { set token [http::geturl $query -timeout 900] } error; if {$error!=$token} { return "-1 Error" } ## if u have a windrop, remove next line puts stderr ""; ## windrop failure upvar #0 $token state; set size [array size state]; set getstate [array get state]; if {[string tolower [lindex $state(http) 2]] != "ok"} { return "-1 $state(http)" } set htmldata [http::data $token]; http::cleanup $token; set ::globdata $htmldata set tick -1; set gametmp [list]; set gametmp2 [list]; set nametmp [list]; set nametmp2 [list]; set gnametmp [list]; set gamesfound 0 foreach line [split $htmldata \n] { #input type="hidden" name="info_28" value="Fehlende Züge if [regexp -- {.*input type=\"hidden\" name=\"info_(.*)\" value=\"Fehlende Z.*} $line temp num] { #putcmdlog "newgame clear $num" set date "nie" set tick 0; if {$nametmp!=[list]} { lappend gametmp2 $gametmp [list $nametmp]; set gametmp [list]; set nametmp [list] } } elseif [regexp -- {.*input type=\"hidden\" name=\"info_(.*)\" value=\"Letzte Auswertung: (.*)} $line temp num date] { #putcmdlog "existgame $num" set tick 0; if {$nametmp!=[list]} { lappend gametmp2 $gametmp [list $nametmp]; set gametmp [list]; set nametmp [list] } } { switch $tick { 1 { if [regexp -- {.*AutoTick: (.*)} $line temp autotick] { incr gamesfound; lappend gametmp [list $num $date $autotick] } { set autotick "keiner" incr gamesfound; lappend gametmp [list $num $date $autotick] } } default { if {$tick>0} { set trim [string trim $line]; if {$trim!="" && $trim!="Fehlende Züge" && $trim!="------------------------" && [string len $trim]<=32} { set ltick $tick lappend nametmp $trim } } } } set x ""; set lastid "" if [regexp -- {.*option value=\"(.*)\" style=\"background-color:\#444444;\">(.*).*} $line] { foreach x [regexp -inline -all {.*option(.*)/option.*} $line] { foreach str1 [split $x /] { if [regexp -- {value="(.*)" style="background-color:#444444;">(.*) \(Runde.*<} $str1 temp id name] { if {$id!="0" && $lastid!=$id} { if [regexp -- {\(Runde (.*)\)} $str1 temp runde] { lappend gnametmp [list $id $name $runde] } set lastid $id } } } } } } if {$tick!="-1"} {incr tick} } if {$gametmp!=[list] && $nametmp!=[list]} { lappend gametmp2 $gametmp [list $nametmp]; set gametmp [list]; set nametmp [list] } if {$::SkrupelNames!=$gnametmp} { putcmdlog "Game changes found (add/remove)" set ::SkrupelNames $gnametmp } set return "ok" if {$::SkrupelZug!=$gametmp2} { foreach { Zug Names } $gametmp2 { set zug [lindex $Zug 0]; set names [lindex $Names 0]; set id [lindex $zug 0] foreach gname $gnametmp { set gid [lindex $gname 0] if {$id==$gid} { set GameName [lindex $gname 1] set GameZug [lindex $gname 2] } } foreach watch [array names ::SkrupelWatch] { if {$watch==$id} { set text "" #putcmdlog "1.$id watch $watch $::SkrupelWatch($watch)" set tmp $::SkrupelWatch($watch); set diff 0 if {[lindex $tmp 0]!=$GameZug} {putcmdlog "new zug [lindex $tmp 0]!=$GameZug"; set diff 1} if {[lindex $tmp 1]!=[lindex $zug 1]} {putcmdlog "new lasttick [lindex $tmp 1]!=[lindex $zug 1]"; append text " - Seit [lindex $zug 1]"; set diff 1} if {[lindex $tmp 2]!=[lindex $zug 2]} {putcmdlog "new nexttick [lindex $tmp 2]!=[lindex $zug 2]"; append text " - Nächster Autotick [lindex $zug 2]"; set diff 1} if {[lindex $tmp 3]!=$names} {putcmdlog "new nexttick [lindex $tmp 3]!=$names"; append text " - Fehlende Spieler: [join $names ", "]"; set diff 1} if {$text!=""} { set text "Veraenderungen im Spiel '$GameName' (#$id) - Zug $GameZug$text" set ::SkrupelWatch($watch) [list $GameZug [lindex $zug 1] [lindex $zug 2] $names] putmsg $::SkrupelChan $text set return "diff" } } } } set ::SkrupelZug $gametmp2 } return $return } proc skrupel:pubm {nick host hand chan arg} { set result [skrupel:zug] set trigger [string range [lindex [split $arg] 0] 1 end] set arg [join [lrange [split $arg] 1 end]] if {$::SkrupelChan!=$chan} { return "-1" } putcmdlog "skrupel:pub $trigger from $nick in $chan - arg $arg" switch -exact -- $trigger { skrupel - hilfe - help { putnotc $nick "!hilfe !skrupel - Diese Hilfe" putnotc $nick "!watch !watchlist - Gebe die Spiele aus, die in der Watchliste sind" putnotc $nick "!watchadd <#id|name> - Spiel zur Watchliste hinzufügen" putnotc $nick "!watchdel <#id|name> - Spiel von der Watchliste entfernen" putnotc $nick "!game !spiel !suche <#id|name> - Suche bestimmte Spiel(e) - Namen dürfen Wildcards haben" putnotc $nick "!games !spiele - Listet alle Spiele auf" } addwatch - watchadd - add { set exists 0; set addid -1; foreach { Zug Names } $::SkrupelZug { set zug [lindex $Zug 0]; set names [lindex $Names 0]; set id [lindex $zug 0] foreach gname $::SkrupelNames { set gid [lindex $gname 0]; if {$id==$gid} { set GameName [lindex $gname 1]; set GameZug [lindex $gname 2] } } set watch [lindex $arg 0] if {$watch==$id || [string match -nocase $watch $GameName]} { if [info exist ::SkrupelWatch($id)] { set exists 1; putcmdlog "Watch exists" } { set ::SkrupelWatch($id) [list 0 0 0 0]; set addid $id; putcmdlog "Watch not exists"; ; putmsg $chan "Füge $id hinzu" } } } } delwatch - watchdel - del { set exists 0; set addid -1; set delid -1; foreach { Zug Names } $::SkrupelZug { set zug [lindex $Zug 0]; set names [lindex $Names 0]; set id [lindex $zug 0] foreach gname $::SkrupelNames { set gid [lindex $gname 0]; if {$id==$gid} { set GameName [lindex $gname 1]; set GameZug [lindex $gname 2] } } set watch [lindex $arg 0] if {$watch==$id || [string match -nocase $watch $GameName]} { if [info exist ::SkrupelWatch($id)] { unset ::SkrupelWatch($id); putmsg $chan "Lösche $id" } } } } spiele - games { foreach { Zug Names } $::SkrupelZug { set zug [lindex $Zug 0]; set names [lindex $Names 0]; set id [lindex $zug 0] foreach gname $::SkrupelNames { set gid [lindex $gname 0]; if {$id==$gid} { set GameName [lindex $gname 1]; set GameZug [lindex $gname 2] } } set watch $id set text ""; append text " - Zug $GameZug"; append text " - Seit [lindex $zug 1]"; append text " - Nächster Autotick [lindex $zug 2]"; append text " - Fehlende Spieler: [join $names ", "]"; if {$text!=""} { set text "Infos über das Spiel '$GameName' (#$id)$text" putmsg $::SkrupelChan $text } } } spiel - suchespiel - suche - game { foreach { Zug Names } $::SkrupelZug { set zug [lindex $Zug 0]; set names [lindex $Names 0]; set id [lindex $zug 0] foreach gname $::SkrupelNames { set gid [lindex $gname 0]; if {$id==$gid} { set GameName [lindex $gname 1]; set GameZug [lindex $gname 2] } } set watch [lindex $arg 0] if {$watch==$id || [string match -nocase $watch $GameName]} { set text ""; append text " - Zug $GameZug"; append text " - Seit [lindex $zug 1]"; append text " - Nächster Autotick [lindex $zug 2]"; append text " - Fehlende Spieler: [join $names ", "]"; if {$text!=""} { set text "Infos über das Spiel '$GameName' (#$id)$text" putmsg $::SkrupelChan $text } } } } watch - watchlist { if {$result=="ok"} { foreach { Zug Names } $::SkrupelZug { set zug [lindex $Zug 0]; set names [lindex $Names 0]; set id [lindex $zug 0] foreach gname $::SkrupelNames { set gid [lindex $gname 0]; if {$id==$gid} { set GameName [lindex $gname 1]; set GameZug [lindex $gname 2] } } foreach watch [array names ::SkrupelWatch] { if {$watch==$id} { set text ""; append text " - Zug $GameZug"; append text " - Seit [lindex $zug 1]"; append text " - Nächster Autotick [lindex $zug 2]"; append text " - Fehlende Spieler: [join $names ", "]"; if {$text!=""} { set text "Infos über das Spiel '$GameName' (#$id)$text"; putmsg $::SkrupelChan $text } } } } } } default { putcmdlog "default $trigger from $nick in $chan" } } } putcmdlog "Skrupel $::SkrupelVer loaded" return "ok"