Advertisement
Guest User

Untitled

a guest
Nov 1st, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 3.14 KB | None | 0 0
  1. # bind <type> <flags> <match> <proc name>
  2. bind pub - $botnick plapper
  3. # procname <nick> <user@host> <handle> <channel> <text>
  4. proc plapper {nick uhost handle chan arg} {
  5.     putlog "plapper getriggert fuer $arg"
  6.     putmsg $channel "Ich hoere dich, $nick, du sagtest '$arg'"
  7.      set parosa [wget "http://parosa.hopto.org/chatbot/conversation_start.php?bot_id=1&convo_id=exampleusage_1231232&format=xml&say=$arg"] }
  8.  putmsg $chan "Parosa meint dazu '$parosa'"
  9. bind pub - "!x" lebenszeichen
  10. proc lebenszeichen {nick uhost handle chan arg} {putmsg $chan "Ja $nick, ich lebe noch, du sagtest '$arg'"}
  11.  
  12.  
  13. package require http
  14. package require tls
  15.  
  16. proc wget { url } {
  17.    putlog "WGET for $url"
  18.    http::config -useragent "Mozilla"
  19.    # SNI FIX
  20.    regexp -nocase {https*\://([^/]+)} $url sni_match sni_servername
  21.    #putlog "TLS-SNI: servername = $sni_servername"
  22.    http::register https 443 [list ::tls::socket -require 0 -request 1 -ssl2 false -ssl3 false -tls1 true -servername $sni_servername ]
  23.    # END SNI-FIX
  24.  
  25.    catch {set token [http::geturl $url -binary 1 -timeout 5000]} error
  26.    if {![string match -nocase "::http::*" $error]} {
  27.       putlog "Error: [string totitle [string map {"\n" " | "} $error]] \( $url \)"
  28.       return 0
  29.    }
  30.    if {![string equal -nocase [::http::status $token] "ok"]} {
  31.       putlog "Http error: [string totitle [::http::status $token]] \( $url \)"
  32.       http::cleanup $token
  33.       return 0
  34.    }
  35.    if {[string match "*[http::ncode $token]*" "303|302|301" ]} {
  36.       upvar #0 $token state
  37.       foreach {name value} $state(meta) {
  38.          if {[regexp -nocase ^location$ $name]} {
  39.             if {![string match "http*" $value]} {
  40.                if {![string match "/" [string index $value 0]]} {
  41.                   set value "[join [lrange [split $url "/"] 0 2] "/"]/$value"
  42.                } else {
  43.                   set value "[join [lrange [split $url "/"] 0 2] "/"]$value"
  44.                }
  45.             }
  46.             wget $value
  47.             http::cleanup $token
  48.             return
  49.          }
  50.       }
  51.    }
  52.    if {[string match 4* [http::ncode $token]] || [string match 5* [http::ncode $token]]} {
  53.       putlog "Http resource is not evailable: [http::ncode $token] \( $url \)"
  54.       http::cleanup $token
  55.       return 0
  56.    }
  57.     set data [http::data $token]
  58.     http::cleanup $token
  59.     putlog "returning DATA: $token"
  60.     return $data
  61. }
  62.  
  63.  
  64.  
  65.  
  66. #set response=[wget("http://parosa.hopto.org/chatbot/conversation_start.php")]
  67.  
  68.  
  69.  
  70. ############### RELOAD SCRIPT FUNKTION ################
  71.  
  72.  
  73.  
  74. set Irmgard(pathname) [info script]
  75.  
  76. bind msg - "!neuladen" neuladen:reload
  77.  proc neuladen:reload {nick uhost hand text} {
  78.  global Irmgard
  79.  if {$hand != "*"} {
  80.  
  81.  
  82.  
  83. putlog "re-load of $Irmgard(pathname) requested from $nick ($hand) with (optional) message '$text'"
  84. puthelp "PRIVMSG $nick reloading $Irmgard(pathname)"
  85.  uplevel 1 source $Irmgard(pathname)
  86.  uplevel 1 source "scripts/eigene/reload.tcl"
  87.  uplevel 1 rehash
  88.  } else {
  89.  putlog "denied re-load of $Irmgard(pathname) requested from $nick ($hand) with (optional) message '$text'"
  90.  puthelp "PRIVMSG $nick Ein Reload ist nur mir bekannten Anwendern erlaubt"
  91.  }
  92.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement