# Zug benachrichtigung im IRC Channel # Testet with Skrupel 0.96 and Eggdrop 1.6.15 # first edit: 06.Mar.2004 # last edit: 07.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.1 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 - "?7 *" skrupel:zug bind time - "?3 *" skrupel:zug proc skrupel:zug args { #putcmdlog "Check Skrupel Zug" set query $::SkrupelSite set cyagent "SkrupelBot $::SkrupelVer" set token [http::config -useragent $cyagent]; catch { set token [http::geturl $query -timeout 900] } error; if {$error!=$token} { return "-1 Error"; } puts stderr ""; 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 filetoken [open "skrupel.dat.tmp" w] 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] { if [regexp -- {.*input type=\"hidden\" name=\"info_(.*)\" value=\"Letzte Auswertung: (.*)} $line temp num date] { #putcmdlog "s.0: get game '$num' from '$date'" puts $filetoken "0 $num $date" set tick 0; if {$gametmp!=[list] && $nametmp!=[list]} { #lappend gametmp2 $gametmp lappend gametmp2 $gametmp [list $nametmp] #putcmdlog "new gamtmp $gametmp nametmp $nametmp" #putcmdlog "new gamtmp2 $gametmp2" set gametmp [list] set nametmp [list] } } { switch $tick { 1 { if [regexp -- {.*AutoTick: (.*)} $line temp autotick] { incr gamesfound #putcmdlog "s.1.$tick.$gamesfound: get autotick '$autotick'" puts $filetoken "1 $num $autotick" lappend gametmp [list $num $date $autotick] } } default { #putcmdlog "default tick $tick" if {$tick>1} { set trim [string trim $line]; if {$trim!="" && $trim!="Fehlende Züge" && $trim!="------------------------" && [string len $trim]<=32} { #putcmdlog "s.2: get name '$trim'" puts $filetoken "2 $num $trim" #lappend gametmp [list $num $trim] lappend nametmp $trim } if {[string len $trim]>32} { #putcmdlog "s: $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] #putcmdlog "id $id name $name runde $runde" puts $filetoken "3 $id $name $runde" } set lastid $id } } #putcmdlog "y $y" } } } } if {$tick!="-1"} {incr tick} } if {$gametmp!=[list] && $nametmp!=[list]} { #lappend gametmp2 $gametmp lappend gametmp2 $gametmp [list $nametmp] #putcmdlog "new gamtmp $gametmp nametmp $nametmp" #putcmdlog "new gamtmp2 $gametmp2" set gametmp [list] set nametmp [list] } close $filetoken if {$::SkrupelNames!=$gnametmp} { #new gamefound putcmdlog "Game changes found (add/remove)" foreach Name $gnametmp { #putcmdlog "Name: $Name" } set ::SkrupelNames $gnametmp } if {$::SkrupelZug!=$gametmp2} { #putcmdlog "Zug changes found" foreach { Zug Names } $gametmp2 { set zug [lindex $Zug 0] set names [lindex $Names 0] #set names $Names 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] #putcmdlog "gn $GameName gz $GameZug" } } 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"; append text " - Zug $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'$text" putcmdlog "text $text" set ::SkrupelWatch($watch) [list $GameZug [lindex $zug 1] [lindex $zug 2] $names] putcmdlog "2.$id watch $watch $::SkrupelWatch($watch)" putmsg $::SkrupelChan $text } } } } set ::SkrupelZug $gametmp2 } return "ok" } proc skrupel:pubm {nick host hand chan arg} { 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" } watchadd - add { set exists 0; set addid -1; foreach { Zug Names } $::SkrupelZug { set zug [lindex $Zug 0] set names [lindex $Names 0] #set names $Names 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] #putcmdlog "gn $GameName gz $GameZug" } } set watch [lindex $arg 0] #putcmdlog "watch $watch" 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" } } } if !$exists { # add watch putcmdlog "add to watchlist $addid" set ::SkrupelWatch($addid) [list 0 0 0 0] #23 {120 lt nt {p1 p2}} } { #putcmdlog "dont add" } } 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 names $Names 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] #putcmdlog "gn $GameName gz $GameZug" } } set watch [lindex $arg 0] #putcmdlog "watch $watch" 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 names $Names 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] #putcmdlog "gn $GameName gz $GameZug" } } #foreach watch [array names ::SkrupelWatch] #if {$watch==$id} 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" putcmdlog "text $text" putmsg $::SkrupelChan $text } #end if #end foreach } } spiel - suchespiel - suche - game { foreach { Zug Names } $::SkrupelZug { set zug [lindex $Zug 0] set names [lindex $Names 0] #set names $Names 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] #putcmdlog "gn $GameName gz $GameZug" } } 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" putcmdlog "text $text" putmsg $::SkrupelChan $text } } } } watch - watchlist { foreach { Zug Names } $::SkrupelZug { set zug [lindex $Zug 0] set names [lindex $Names 0] #set names $Names 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] #putcmdlog "gn $GameName gz $GameZug" } } 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" putcmdlog "text $text" putmsg $::SkrupelChan $text } } } } } default { putcmdlog "default $trigger from $nick in $chan" } } }