Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # bind <type> <flags> <match> <proc name>
- bind pub - $botnick plapper
- # procname <nick> <user@host> <handle> <channel> <text>
- proc plapper {nick uhost handle chan arg} {
- putlog "plapper getriggert fuer $arg"
- putmsg $channel "Ich hoere dich, $nick, du sagtest '$arg'"
- set parosa [wget "http://parosa.hopto.org/chatbot/conversation_start.php?bot_id=1&convo_id=exampleusage_1231232&format=xml&say=$arg"] }
- putmsg $chan "Parosa meint dazu '$parosa'"
- bind pub - "!x" lebenszeichen
- proc lebenszeichen {nick uhost handle chan arg} {putmsg $chan "Ja $nick, ich lebe noch, du sagtest '$arg'"}
- package require http
- package require tls
- proc wget { url } {
- putlog "WGET for $url"
- http::config -useragent "Mozilla"
- # SNI FIX
- regexp -nocase {https*\://([^/]+)} $url sni_match sni_servername
- #putlog "TLS-SNI: servername = $sni_servername"
- http::register https 443 [list ::tls::socket -require 0 -request 1 -ssl2 false -ssl3 false -tls1 true -servername $sni_servername ]
- # END SNI-FIX
- catch {set token [http::geturl $url -binary 1 -timeout 5000]} error
- if {![string match -nocase "::http::*" $error]} {
- putlog "Error: [string totitle [string map {"\n" " | "} $error]] \( $url \)"
- return 0
- }
- if {![string equal -nocase [::http::status $token] "ok"]} {
- putlog "Http error: [string totitle [::http::status $token]] \( $url \)"
- http::cleanup $token
- return 0
- }
- if {[string match "*[http::ncode $token]*" "303|302|301" ]} {
- upvar #0 $token state
- foreach {name value} $state(meta) {
- if {[regexp -nocase ^location$ $name]} {
- if {![string match "http*" $value]} {
- if {![string match "/" [string index $value 0]]} {
- set value "[join [lrange [split $url "/"] 0 2] "/"]/$value"
- } else {
- set value "[join [lrange [split $url "/"] 0 2] "/"]$value"
- }
- }
- wget $value
- http::cleanup $token
- return
- }
- }
- }
- if {[string match 4* [http::ncode $token]] || [string match 5* [http::ncode $token]]} {
- putlog "Http resource is not evailable: [http::ncode $token] \( $url \)"
- http::cleanup $token
- return 0
- }
- set data [http::data $token]
- http::cleanup $token
- putlog "returning DATA: $token"
- return $data
- }
- #set response=[wget("http://parosa.hopto.org/chatbot/conversation_start.php")]
- ############### RELOAD SCRIPT FUNKTION ################
- set Irmgard(pathname) [info script]
- bind msg - "!neuladen" neuladen:reload
- proc neuladen:reload {nick uhost hand text} {
- global Irmgard
- if {$hand != "*"} {
- putlog "re-load of $Irmgard(pathname) requested from $nick ($hand) with (optional) message '$text'"
- puthelp "PRIVMSG $nick reloading $Irmgard(pathname)"
- uplevel 1 source $Irmgard(pathname)
- uplevel 1 source "scripts/eigene/reload.tcl"
- uplevel 1 rehash
- } else {
- putlog "denied re-load of $Irmgard(pathname) requested from $nick ($hand) with (optional) message '$text'"
- puthelp "PRIVMSG $nick Ein Reload ist nur mir bekannten Anwendern erlaubt"
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement