Последние темы с форума | IRC

Discussion in 'Болталка' started by ReanimatoR, 18 Sep 2009.

  1. ReanimatoR

    ReanimatoR Elder - Старейшина

    Joined:
    27 Aug 2006
    Messages:
    115
    Likes Received:
    118
    Reputations:
    34
    Каждую минуту проверяет есть ли новая тема на античате, если есть выводит на канал в таком виде:
    [16:36:03] <Info> (как подменить порт? - /showthread.php?t=142169&)
    [16:43:05] <Info> (Что с почтой Вэб-точка-де? - /showthread.php?t=142171&)



    Сейчас этот бот живет на irc.antichat.net #cyberpunk. Настраивайте под свою ирк-сеть и пользуйтесь :)
    Собственно вод код скрипта для eggdrop'a(попозже оптимизурую, так как есть мусор)

    Разбил на три куска, ибо глючит=\\
    Code:
    ## 
    ## edited ReanimatoR
    ## RSS bot 
    ## 
    ## GHhost - Georgiewskiy Yuriy <bottleman@icf.bofh.ru> http://icf.bofh.ru (C) GHhost 
    ## 
    ## additional thx to mrBuG <mrbug@eggdrop.org.ru> and Drakon <drakon@eggdrop.org.ru> for help with egglib and for 
    ## answers on my question (sometime stupid:) ) 
    ## 
    ## based on rssnews.tcl by perpleXa - http://perpleXa.net | http://dev.perpleXa.net #perpleXa on QuakeNet (C) 2004 
    ## Внимание!!! Данный скрипт требует установленную eggglib.tcl c http://www.eggdrop.org.ru/scripts/ 
    ## Changelog: 
    ## 2004-09-08   	rewriten using egglib by Shrike <shrike@eggdrop.org.ru> and mrBuG <mrbug@eggdrop.org.ru> to awoid  
    ##              	blocked socket problems, added support to recoding feeds from different codepages.
    ## 2004-09-08 15:36:30	misc bug fixex, don't store colours in cache.
    ## 2004-09-17 15:55:41  added flood protections, added http user agent, added destination encoding var, fixed some
    ##			charasters in html parse.
    ## 2004-09-20 11:18:41  added VIANOTICE feed flag to allow switch betwen post type - to channel or user via notice,
    ##			added rss(defaultposttype) var to switch it globaly for feed which not have VIANOTICE flag
    ##			set, added checks if egglib present.
    ## 2004-09-27 5:58:47  fixed bug with post news vian msg, fixed out of file decriptors bug.
    ## 2004-11-30 16:37:30  added proxy support, thx to <admin@lubimez.tomsk.ru>.
    ## 2005-09-15 20:46:00 translate to Russian by MMS <MMS@xaker.ru>
    ## 2005-09-15 20:53:02 fixed and optimized for WeNet
    ## 2009-09-XX optimized ONLY for forum.antichat.ru
    
    ###########################################
    ## Не изменять!
    array unset feed
    ##
    ###########################################
    ###### Setup ##############################
    
    set feed(antichat) {
      URL=/news.rss
      DATABASE=rssnews/antichat.ru
      CHANNELS=#cyberpunk
      POSTNEWS=1
      POSTLIMIT=1
      PUBLIMIT=1
      MSGLIMIT=1
      ENCODINGFROM=cp1251
      VIANOTICE=0
      POSTLAYOUT= 4(10<news> 04- 07<link>04)
      TRIGLAYOUT=  4(10<news> 04- 07<link>04)
    }
    
    set rss(encoding_to) cp1251
    set rss(httptimeout) 150
    set rss(defaultposttype) 0
    set rss(client) {Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040803 Firefox/0.9.3}
    set rss(use_proxy) 0
    set rss(proxy_host) ""
    set rss(proxy_port) 8080
    
    
    ###### End of Setup #######################
    ###########################################
    Code:
    
    # Debug mode (to display status messages on the partyline, better don't touch those lines)
    
    set rss(debug) 1
    set rss(v_major) 3
    set rss(v_minor) 0
    set rss(v_build) 005
    
    if { ![info exists egglib(ver)] } {
        putlog "***********************************************"
        putlog "             egglib_pub NOT FOUND !"
        putlog "   Download last version of egglib_pub here:"
        putlog "  http://eggdrop.org.ru/scripts/egglib_pub.zip"
        putlog "***********************************************"
        die
    }
    
    if { [expr {$egglib(ver) < 1.4}] } {
        putlog "***********************************************"
        putlog " YOUR VERSION OF egglib_pub IS TOO OLD !"
        putlog "   Download last version of egglib_pub here:"
        putlog "  http://eggdrop.org.ru/scripts/egglib_pub.zip"
        putlog "***********************************************"
        putlog " version installed : $egglib(ver)"
        putlog " version required: 1.4"
        die
    }
    
    # Binds
    bind PUB  -|-  {last}       rsspublic
    bind MSG  -|-  {--news}        rssprivate
    bind TIME -|-  {?? * * * *}  rsscheck
    bind PUB  -|-  {-cache}      rsscheck
    
    proc rsscheck {min hour day week year} {
        global feed rssnews rss
        foreach id [array names feed] {
    	set url          "0"
    	set database     "0"
    	set channels     "0"
    	set postnews     "1"
    	set postlimit    "3"
    	set publimit     "3"
    	set msglimit     "5"
    	set postlayout   "<news> <link>"
    	set colour ""
    	foreach item [split $feed($id) \n] {
    	    regsub -all -- {/\*.*\*/} $item {} item
    	    regexp -nocase -- {^\s*URL=(.+?)\s*$} $item tmp url
    	    regexp -nocase -- {^\s*DATABASE=(.+?)\s*$} $item tmp database
    	    regexp -nocase -- {^\s*CHANNELS=(.+?)\s*$} $item tmp channels
    	    regexp -nocase -- {^\s*POSTNEWS=(.+?)\s*$} $item tmp postnews
    	    regexp -nocase -- {^\s*POSTLIMIT=(.+?)\s*$} $item tmp postlimit
    	    regexp -nocase -- {^\s*PUBLIMIT=(.+?)\s*$} $item tmp publimit
    	    regexp -nocase -- {^\s*MSGLIMIT=(.+?)\s*$} $item tmp msglimit
    	    regexp -nocase -- {^\s*ENCODINGFROM=(.+?)\s*$} $item tmp encodingfrom
    	    regexp -nocase -- {^\s*POSTLAYOUT=(.+?)\s*$} $item tmp postlayout
    	    regexp -nocase -- {^\s*COLOUR=(.+?)\s*$} $item tmp colour
    	    
    	}
    	
        if {($url == 0) || ($database == 0) || ($channels == 0)} {
    	putlog "RSS: Warning: Couldn't load configuration for feed '$id'"
    	continue
        }
    	if {$postnews == 0} {
    	    continue
    	}
    	#regexp -nocase -- {^(http://)?(\S*\.[a-zA-Z]{2,3})(/.*?)(\:([0-9]+))?$} $url tmp tmp host get tmp port
    	#if {$port == ""} {
    	#    set port 80
    	#}
    	set latestnews "iddqd"
    	regexp -- {^(\S+/)?.*$} $database tmp directory
    	if {$directory != ""} {
    	    if {![file isdirectory $directory]} {
    		file mkdir $directory
    		if {$rss(debug) == 1} {
              putlog "RSS: created directory for feed '$id': $directory"
    		}
    	    }
    	}
    	if {[file exists $database]} {
    	    set temp [open $database r]
    	    set latestnews [gets $temp]
    	    if {$latestnews == ""} {
    		set latestnews "iddqd"
    	    }
    	    close $temp
    	}
    	set count 0
    	set data {}
    	set limit $postlimit
    	if {$limit < $publimit} {
    	    set limit $publimit
    	}
    	if {$limit < $msglimit} {
    	    set limit $msglimit
    	}
    	puthelp "PING :[unixtime]"
    	set http_id [::egglib::http_init "rsscheck_"]
    	::egglib::http_set_agent $http_id $rss(client)
    	::egglib::http_set_timeout $http_id $rss(httptimeout)
    	if { $rss(use_proxy) } { ::egglib::http_set_proxy $http_id $rss(proxy_host) $rss(proxy_port) }
    	::egglib::http_get $http_id $url [list $encodingfrom $limit $database $postlayout $postlimit $channels $id $latestnews $colour]
        }
    }
    
    proc rsscheck_on_error {http_id encodingfrom limit database postlayout postlimit channels id latestnews colour} {
        putlog "RSSNEWS::connect timeout while getting data for feed $id"
    }
    
    
    Code:
    proc rsscheck_on_data {http_id html encodingfrom limit database postlayout postlimit channels id latestnews colour} {
        global fedd rssnews rss
        set count 0
        foreach line [split $html \n] {
    	append data $line
    	incr count [regexp -all -nocase -- {</item>} $line]
    	if {([regexp -nocase -- {</rss>} $line]) || ($count >= $limit)} {
    	    break
    	}
        }
        ::egglib::http_cleanup $http_id
        
        set temp [open $database w]
        set data [rsshtmlspecialchars $data]
        set publisher [rsspublisher $data]
        set data [rssparse $data]
        foreach {rssitem} [lsort -dictionary $data] {
    	regsub -all -- {<id>} $postlayout $rssitem output
    	regsub -all -- {<publisher>} $output $publisher output
    	regsub -all -- {<news>} $output [lindex $rssnews($rssitem) 1] output
    	regsub -all -- {<link>} $output [lindex $rssnews($rssitem) 0] output
    	if {$encodingfrom != $rss(encoding_to)} {
    	    set output [encoding convertfrom $encodingfrom $output]
    	    set output [encoding convertto $rss(encoding_to) $output]
    	}
    	puts $temp $output
        }
        close $temp
        set count 0
        set temp [open $database r]
        while {![eof $temp]} {
    	gets $temp headline
    	set line [join $headline]
    	if {($latestnews == $headline) || ($latestnews == "iddqd") || ($line == "") || ($count == $postlimit)} {
    	    break
    	    close $temp
    	}
    	incr count
    	foreach channel [channels] {
    	    set coloredline $line
    	    set colour 
    	    if {[string equal -nocase $channels "ALL"]} {
    		if {[regexp -- {c} [getchanmode $channel]]} {
    		    putserv "PRIVMSG $channel ${colour}[rssnocols $coloredline]"
    		} else {
    		    putserv "PRIVMSG $channel ${colour}$coloredline"
    		}
    	    } else {
    		if {[lsearch -exact [string tolower $channels] [string tolower $channel]] != -1} {
    		    if {[regexp -- {c} [getchanmode $channel]]} {
    			putserv "PRIVMSG $channel ${colour}[rssnocols $coloredline]"
    		    } else {
    			putserv "PRIVMSG $channel ${colour}$coloredline"
    		    }
    		}
    	    }
    	}
        }
        close $temp
    }
    
    proc rssnews {target fid type nickname} {
        putlog "!rss $fid"
        global feed rss rssnews
        set url          "0"
        set publimit     "3"
        set msglimit     "5"
        set triglayout   "<id> <news> <link>"
        set vianotice $rss(defaultposttype)
        
        foreach item [split $feed($fid) \n] {
    	regsub -all -- {/\*.*\*/} $item {} item
    	regexp -nocase -- {^\s*URL=(.+?)\s*$} $item tmp url
    	regexp -nocase -- {^\s*PUBLIMIT=(.+?)\s*$} $item tmp publimit
    	regexp -nocase -- {^\s*MSGLIMIT=(.+?)\s*$} $item tmp msglimit
    	regexp -nocase -- {^\s*TRIGLAYOUT=(.+?)\s*$} $item tmp triglayout
    	regexp -nocase -- {^\s*ENCODINGFROM=(.+?)\s*$} $item tmp encodingfrom
    	regexp -nocase -- {^\s*VIANOTICE=(.+?)\s*$} $item tmp vianotice
        }
        
        if {($url == 0)} {
    	putserv "PRIVMSG $target :Внимание: Невозможно загрузить конфигурацию для '$id'"
    	return 0
        }
        #regexp -nocase -- {^(http://)?(\S*\.[a-zA-Z]{2,3})(/.*?)(\:([0-9]+))?$} $url tmp tmp host get tmp port
        #if {$port == ""} {
    	#set port 80
        #}
        if {$type == 1} {
    	set limit $msglimit
        } elseif {$type == 2} {
    	set limit $publimit
        } else {
    	return 0
        }
        
        set http_id [::egglib::http_init "rssnews_"]
        ::egglib::http_set_timeout $http_id $rss(httptimeout)
        ::egglib::http_set_agent $http_id $rss(client)
        if { $rss(use_proxy) } { ::egglib::http_set_proxy $http_id $rss(proxy_host) $rss(proxy_port) }
        ::egglib::http_get $http_id $url [list $target $fid $type $encodingfrom $limit $triglayout $vianotice $nickname]
    }
    
    proc rssnews_on_error {http_id target fid type encodingfrom limit triglayout vianotice nickname} {
    if {($vianotice == 0)} {putserv "PRIVMSG $target :$fid: При получении информации произошла ошибка"}
    if {($vianotice == 1)} {putserv "NOTICE $nickname :$fid: При получении информации произошла ошибка"}
    putlog "RSSNEWS::connect timeout while getting data for feed $fid"
    }
    
    proc rssnews_on_data {http_id html target fid type encodingfrom limit triglayout vianotice nickname} {
        global feed rss rssnews
        set count 0
        foreach line [split $html \n] {
    	append data $line
    	incr count [regexp -all -nocase -- {</item>} $line]
    	if {([regexp -nocase -- {</rss>} $line]) || ($count >= $limit)} {
    	    break
    	}
        }
        ::egglib::http_cleanup $http_id
        set data [rsshtmlspecialchars $data]
        set publisher [rsspublisher $data]
        set data [rssparse $data]
        set count 0
        foreach {id} [lsort -dictionary $data] {
    	incr count
    	regsub -all -- {<id>} $triglayout $id output
    	regsub -all -- {<publisher>} $output $publisher output
    	regsub -all -- {<news>} $output [lindex $rssnews($id) 1] output
    	regsub -all -- {<link>} $output [lindex $rssnews($id) 0] output
    	set output [join $output]
    	if {$type == 2} {
    	    if {[regexp -- {c} [getchanmode $target]]} {
        		set output [rssnocols $output]
    	    }
    	}
    	
    	if {$encodingfrom != $rss(encoding_to)} {
    	    
    	    set output [encoding convertfrom $encodingfrom $output]
    	    set output [encoding convertto $rss(encoding_to) $output]
    	}
    	if {($vianotice == 0)} {putserv "PRIVMSG $target :$output"}
    	if {($vianotice == 1)} {putserv "NOTICE $nickname :$fid:\00300$output"}
    	if {($count == $limit)} {
    	    break
    	}
        }
    }
    
    proc rsspublisher {content} {
        set publisher {n/a}
        regsub -all -- {\n+|\s+|\t+|\r+} $content { } content
        regsub -all -- {\&} $content {\\\&} content
        regexp -nocase -- {<title>(.+?)</title>} $content tmp publisher
        regsub -nocase -- {<title>(.+?)</title>} $content {} content
        return $publisher
    }
    
    proc rssparse {content} {
        global rssnews
        array unset rssnews
        regsub -all -- {\n+|\s+|\t+|\r+} $content { } content
        regsub -all -- {\&} $content {\\\&} content
        set item 0
        while {[regexp -nocase -- {<item(\s[^>]*?)?>(.+?)</item>} $content tmp tmp value]} {
    	incr item
    	set title  {n/a}
    	regexp -nocase -- {<title>(.+?)</title>} $value tmp title
    	set link {n/a}
    	regexp -nocase -- {<link>(.+?)goto=newpost</link>} $value tmp link
    	regsub -nocase -- {<item.*?>.+?</item>} $content {} content
    	set rssnews($item) "{$link} {$title}"
        }
        return [array names rssnews]
    }
    
    proc rsshtmlspecialchars {content} {
    set t [string map { &nbsp; \x20 &quot; \x22 &apos; \x27 &ndash; \x2D &lt; \x3C &gt; \x3E &amp; \x26 &tilde; \x7E &euro; \x80 &brvbar; \xA6 &copy; \xA9 &Auml; \xC4 &Ouml; \xD6 &Uuml; \xDC &szlig; \xDF &auml; \xE4 &ouml; \xF6 &uuml; \xFC &laquo; \\" &raquo; \\" } $content]
    regsub -all -- {&\#8211;} $t {.} t
    return $t
    }
    
    proc rssprivate {nickname hostname handle arguments} {
        global feed rss
        regsub -all {\\} $arguments {\\\\} arguments
        set spewfeed [lindex $arguments 0]
        if {![isvalidfeed $spewfeed 1]} {
    	puthelp "NOTICE $nickname :Выберите одну из доступных рассылок: [lsort -dictionary [array names feed]]"
    	return 0
        }
        set spewfeed [isvalidfeed $spewfeed 2]
        rssnews $nickname $spewfeed 1 $nickname
    }
    
    proc rsspublic {nickname hostname handle channel arguments} {
        global feed rss
        regsub -all {\\} $arguments {\\\\} arguments
        set protect 15
        if {([info exists rss(flood)]) && (![isop $nickname $channel])} {
    	set spam [expr [clock seconds] - $rss(flood)]
    	if {$spam < $protect} {
    	    putserv "NOTICE $nickname :Скрипт в данный момент используется! Пожалуйста ждите [expr $protect - $spam] секунд."
    	    return 0
    	}
        }
        set rss(flood) [clock seconds]
        set spewfeed [lindex antichat 0]
        if {![isvalidfeed $spewfeed 1]} {
    	puthelp "NOTICE $nickname :Выберите одну из доступных рассылок: [lsort -dictionary [array names feed]]"
    	return 0
        }
        set spewfeed [isvalidfeed $spewfeed 2]
        set channels 0
        foreach item [split $feed($spewfeed) \n] {
    	regsub -all -- {/\*.*\*/} $item {} item
    	regexp -nocase -- {^\s*CHANNELS=(.+?)\s*$} $item tmp channels
        }
        if {([lsearch -exact [string tolower $channels] [string tolower $channel]] == -1) && (![string equal -nocase $channels "ALL"])} {
    	puthelp "NOTICE $nickname :Эта рассылка недоступна на данном канале."
    	return 0
        }
        rssnews $channel $spewfeed 2 $nickname
    }
    
    proc isvalidfeed {keyword type} {
        global feed
        foreach id [array names feed] {
    	if {[string equal -nocase $id $keyword]} {
    	    switch -exact -- $type {
    		{1} {
    		    return 1
    		}
    		{2} {
    		    return $id
    		}
    	    }
    	}
        }
        return 0
    }
    
    proc rssnocols {string} {
        regsub -all -- {\003[\d]{0,2}(,[\d]{0,2})?} $string {} string
        return $string
    }
    
    putlog "Script loaded: RSS feed parser $rss(v_major).$rss(v_minor).$rss(v_build) (C) 2004 GHhost."
    putlog "RSS feed parser translated to Russian by MMS <MMS@xaker.ru , /server irc.wenet.ru #37>"
    putlog "Antichat's Announcements loader edited by ReanimatoR>"
    CHANNELS=#cyberpunk заменить на нужный вам канал.
     
    #1 ReanimatoR, 18 Sep 2009
    Last edited: 18 Sep 2009
  2. Cthulchu

    Cthulchu Elder - Старейшина

    Joined:
    22 Nov 2007
    Messages:
    405
    Likes Received:
    709
    Reputations:
    85
    )) #киберпанка хватает)
     
  3. Suicide

    Suicide Super Moderator
    Staff Member

    Joined:
    24 Apr 2009
    Messages:
    2,373
    Likes Received:
    6,619
    Reputations:
    693
    Удобный бот с его выдачей тем, с самого начала его трудовой деятельности читаем +) Полезный скрипт +)
     
  4. Funk

    Funk Member

    Joined:
    8 Jun 2009
    Messages:
    12
    Likes Received:
    17
    Reputations:
    0
    и что ты там 3 строчки отредактировал? скрипту сто лет, за бота сказать спасибо? ничего особенного
     
  5. Suicide

    Suicide Super Moderator
    Staff Member

    Joined:
    24 Apr 2009
    Messages:
    2,373
    Likes Received:
    6,619
    Reputations:
    693
    И чего? Да сказать, почему бы и нет. А почему Вы не пришли и не отредактировали или навели на мысль? Только ругать да умеем?
     
  6. ReanimatoR

    ReanimatoR Elder - Старейшина

    Joined:
    27 Aug 2006
    Messages:
    115
    Likes Received:
    118
    Reputations:
    34
    fc "rssnews (2).tcl" rssnews.tcl > diff.txt
    http://pastebin.com/m20cfab98
    удачи сравнить школотень ;)
     
  7. fox_malder

    fox_malder Active Member

    Joined:
    28 Nov 2008
    Messages:
    162
    Likes Received:
    131
    Reputations:
    73
    народ как в ирку попасть в чат
    напишите координаты плз
     
  8. gisTy

    gisTy Elder - Старейшина

    Joined:
    24 May 2008
    Messages:
    432
    Likes Received:
    160
    Reputations:
    27
    irc.antichat.net/7771
    кстати, рем, добавь чтобы бот выводил еще и раздел, помимо названия темы
     
    #8 gisTy, 18 Sep 2009
    Last edited: 18 Sep 2009
  9. fox_malder

    fox_malder Active Member

    Joined:
    28 Nov 2008
    Messages:
    162
    Likes Received:
    131
    Reputations:
    73
    да не заходит
    irc.antichat.net- *** Looking up your hostname...
    -
    -irc.antichat.net- *** Couldn't resolve your hostname; using your IP address instead
    -
    -irc.antichat.net- *** You connected on 7771 port. Using CP1251 translation scheme as default.
    -
     
  10. Ponchik

    Ponchik Хлебо-булочное изделие

    Joined:
    30 Aug 2005
    Messages:
    687
    Likes Received:
    807
    Reputations:
    311
    fox_malder, действительно "You connected" это значит не заходит...
    У меня всё работает, что я делаю не так?
    ПыСы пиши /join #antichat
     
  11. fox_malder

    fox_malder Active Member

    Joined:
    28 Nov 2008
    Messages:
    162
    Likes Received:
    131
    Reputations:
    73
    все равно не могу
    напишите плз что да как
     
  12. gisTy

    gisTy Elder - Старейшина

    Joined:
    24 May 2008
    Messages:
    432
    Likes Received:
    160
    Reputations:
    27
    попробуй через проксик какой-нибудь, там последние несколько месяцев лаги...
     
  13. Funk

    Funk Member

    Joined:
    8 Jun 2009
    Messages:
    12
    Likes Received:
    17
    Reputations:
    0
    школотень это ты му**к. я был на олчитсе когда ты пытался осовить экшены on text, on join и тд в мирке, "писал" бота, который будет тебе опа давать на канале, весь день и тупые вопросы задавал, что ты там отредактировать можешь? не смеши.
     
  14. ReanimatoR

    ReanimatoR Elder - Старейшина

    Joined:
    27 Aug 2006
    Messages:
    115
    Likes Received:
    118
    Reputations:
    34
    и?) научился же, а ты как был школотроллем так и остался ;)

    p.s.
    почитал твои посты...
    удачи в игноре тебе, все равно ничего умного не скажешь на этом форуме...
     
    #14 ReanimatoR, 19 Sep 2009
    Last edited: 19 Sep 2009
  15. Suicide

    Suicide Super Moderator
    Staff Member

    Joined:
    24 Apr 2009
    Messages:
    2,373
    Likes Received:
    6,619
    Reputations:
    693
    fox_malder, юзайте носочки, много раз подобная тема поднималась уже.
     
  16. gisTy

    gisTy Elder - Старейшина

    Joined:
    24 May 2008
    Messages:
    432
    Likes Received:
    160
    Reputations:
    27
    дадада. лучше всего шерстяные!
     
  17. Alexandr II

    Alexandr II -=ImperatoR=-

    Joined:
    28 Dec 2007
    Messages:
    1,068
    Likes Received:
    642
    Reputations:
    87
    а у меня только варежки(( они не подойдут? носки моль съела..=\
     
  18. gisTy

    gisTy Elder - Старейшина

    Joined:
    24 May 2008
    Messages:
    432
    Likes Received:
    160
    Reputations:
    27
    на ноги нацепишь? тогда пойдут!
     
  19. Useroff

    Useroff Elder - Старейшина

    Joined:
    23 Aug 2008
    Messages:
    146
    Likes Received:
    27
    Reputations:
    -3
    Чую корж с дарком идут на позицию блондинок аля чатовцы :D