# Author: tomekk # e-mail: tomekk/@/tomekk/./org # home page: http://tomekk.org/ # # Version 0.3 # # This file is Copyrighted under the GNU Public License. # http://www.gnu.org/copyleft/gpl.html # channels for !fmylife set fmylife_channels {#chan #chan2} # time between use !fmylife (seconds) set fmylife_reuse_time 20 # auto query # 0 - off, 1 - on set fmylife_auto_query 0 # set auto query interval (minutes) set fmylife_auto_interval 30 ########################################################### bind pub - !fmylife fm_main_proc package require http proc get_fmylife { } { set f_http_uagent "Mozilla/5.0 (X11; Linux i686; rv:20.0) Gecko/20100101 Firefox/20.0" set f_http_token [http::config -useragent $f_http_uagent] if {[catch {set f_http_token [::http::geturl "http://www.fmylife.com/random" -timeout 10000]}]} { return "error" } { return [http::data $f_http_token] } } set fmylife_reuse 1 proc fmylife_timer { } { global fmylife_auto_interval fm_auto_proc if {[string match *fmylife_timer* [timers]] != 1} { timer $fmylife_auto_interval fmylife_timer } } proc fm_auto_proc { } { global fmylife_channels set fm_quote "" set fm_quote [get_fmylife] if {($fm_quote == "error") || ($fm_quote == "")} { putlog "auto-quote-fmylife: problem with connection" return } foreach fm_each_chan [split $fmylife_channels] { if {$fm_each_chan != ""} { set fm_each_chan [string trim $fm_each_chan] if {[botonchan $fm_each_chan]} { fmylife_print $fm_quote $fm_each_chan } } } } proc fm_main_proc { nick uhost hand chan arg } { global fmylife_channels fmylife_reuse fmylife_reuse_time if {[expr [clock seconds] - $fmylife_reuse] <= $fmylife_reuse_time} { putquick "PRIVMSG $chan :$nick: to fast, sorry" return } if {[lsearch $fmylife_channels $chan] == -1} { return } set fm_quote "" set fm_quote [get_fmylife] if {($fm_quote == "error") || ($fm_quote == "")} { putquick "PRIVMSG $chan :problem with connection, try again later, sorry" return } fmylife_print $fm_quote $chan } proc fmylife_print { fm_data fm_chan } { global fmylife_reuse set fm_link "" regsub -all -nocase "\n" $fm_data "" fm_data regsub -all -nocase "\r" $fm_data "" fm_data regsub -all -nocase "\t" $fm_data "" fm_data # quote regsub -nocase {.*
(.+)