egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Freshmeat/Sourceforge lookup/search script

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
Razor
Voice


Joined: 19 Nov 2009
Posts: 17

PostPosted: Sat Oct 30, 2010 11:23 am    Post subject: Freshmeat/Sourceforge lookup/search script Reply with quote

Heya,

I came across this script by domsen called freshmeat(1.2.tcl). The script seem to work, the only thing is that it does not output the "$newsline" accordingly, ok.. ok.. it doesn't work..

Example:
Quote:
[ Razor ]: !freshmeat Joomla
[ BitchyBot ]: - http://freshmeat.net
[ BitchyBot ]: - http://freshmeat.net
[ BitchyBot ]: - http://freshmeat.net
[ BitchyBot ]: - http://freshmeat.net
[ BitchyBot ]: - http://freshmeat.net


The above shows the output after a 'freshmeattrigger' and 'freshmeatsearchtrigger' command is executed in 'freshmeatchans'.

I've try'd it on an eggdrop1.6.20 with egghttp.tcl installed.

Also, will it be possible to have a SourceForge.net lookup/search aswell? I think that would be a handy one, especially for those Computer Geeks ;P - Hope I'm not asking too much.

Besides this script, can http://forum.egghelp.org/viewtopic.php?t=16856 be converted to a Freshmeat and Sourceforge lookup/search script?

Would appreciate the kind help, thank you.



Code:
set freshmeattrigger "!freshmeat"

set freshmeatsearchtrigger "!fms"

set freshmeatchans "#razor-bots #ubuntu"

set freshmeatlimit "5"

set freshmeatnewspostlimit "3"

set freshmeatnewspost "1"

set isfreshmeathub "0"

set freshmeatleafs ""



# Auto get new news.

set freshmeat(autonews) "1"



# update delay (minimal 5)

set freshmeat(updates) "5"





####### ende der config #############



bind msg - $freshmeattrigger msg_freshmeat

bind pub - $freshmeattrigger pub_freshmeat

bind msg - $freshmeatsearchtrigger msg_freshmeatsearch

bind pub - $freshmeatsearchtrigger pub_freshmeatsearch

#bind time - "*0,*5 * * * *" freshmeatcheck



proc sendfreshmeatnews { arg } {

global freshmeatleafs

foreach bot [bots] {

if {([lsearch -exact [string tolower $freshmeatleafs] [string tolower $bot]] != -1)} {

putbot $bot "freshmeat: $arg"

}}}



proc shrink { calc number string start bl} { return [expr [string first "$string" $bl $start] $calc $number] }





proc freshmeatsearch { target limit arg } {

if {$arg == ""} { return 0}

putlog "freshmeat: search by $target for ($arg)"

regsub " " $arg "%20" arg

if {[catch {set sock [socket freshmeat.net 80] } sockerror]} {

putlog "error: $sockerror"

return 0 } else {

puts $sock "GET /search/?q=$arg&section=projects HTTP/1.1"

puts $sock "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9)"

puts $sock "Host: freshmeat.net"

puts $sock "Connection: close"

puts $sock ""

flush $sock

set counter 0

while {[eof $sock] != 1} {

set bl [gets $sock]

if {[string first "No matches" $bl] != -1 } {putserv "privmsg $target :no matches found";return 0 }

if {[string first "Location: http://freshmeat.net/projects/" $bl] != -1 } {

set newsline $arg

set link "www.freshmeat.net/[string range $bl 30 [string last "/" $bl]]"

putserv "notice $target :$newsline -  $link"

incr counter

}



if {[string first "href=\"/projects/" $bl] != -1} {

set link "www.freshmeat.net/[string range $bl [shrink + 8 " href=\"" 0 $bl] [shrink - 1 "/\">" 0 $bl]]"

set newsline [string range $bl [shrink + 3 "<b>" 0 $bl] [shrink - 1 "</b>" 0 $bl]]

regsub -all "<b style=\"background: #FFFF00\">" $newsline "" newsline

putserv "notice $target :$newsline -  $link"

incr counter

}

if {$counter == $limit} {close $sock; return 0}

}}}







proc freshmeatnews { target limit } {

if {[catch {set sock [socket freshmeat.net 80] } sockerror]} {

putlog "error: $sockerror"

return 0 } else {

puts $sock "GET / HTTP/1.1"

puts $sock "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"

puts $sock "Host: freshmeat.net"

puts $sock "Connection: close"

puts $sock ""

flush $sock

set counter 0

while {[eof $sock] != 1} {

set bl [gets $sock]

if {[string first "Tired of seeing a" $bl] != -1} { return 0 }

if {[string first "/projects/" $bl] != -1 && [string first "sourceforge.net" $bl] == -1} {

set link "www.freshmeat.net/[string range $bl [shrink + 8 " href=\"" 0 $bl] [shrink - 1 "/\">" 0 $bl]]"

set newsline [string range $bl [shrink + 9 "#000000\">" 0 $bl] [shrink - 1 "</font>" 0 $bl]]

putserv "notice $target :[incr counter] $newsline -  $link"

}

if {$counter == $limit} {close $sock; return 0}

}}}





proc freshmeatcheck {} {

    global freshmeat freshmeatchans freshmeatnewspost isfreshmeathub freshmeatnewspostlimit

    set counter 0

    # Eggdrop timer to loop the checker

    if {$freshmeat(updates) < 5} {

        putlog "\[Freshmeat!\] Warning: the \$freshmeat(updates) setting is too low! Defaulting to 5 minutes..."

        timer 5 freshmeatcheck

    } else {

        timer $freshmeat(updates) freshmeatcheck

    }



    if {$freshmeatnewspost == 1 } {

   putlog "\[Freshmeat!\]: search for new news lines"

   set freshmeatlastnews "none"

   if {[file exists freshmeat.hdl]} {

       set temp [open "freshmeat.hdl" r]

       set freshmeatlastnews "[gets $temp]"

       if {$freshmeatlastnews == ""} { set freshmeatlastnews "none" }

       close $temp

   }

   set temp [open "freshmeat.hdl" w+]

   if {[catch {set sock [socket freshmeat.net 80] } sockerror]} {

       putlog "error: $sockerror"

       return 0

   } else {

       puts $sock "GET / HTTP/1.1"

       puts $sock "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"

       puts $sock "Host: freshmeat.net"

       puts $sock "Connection: close"

       puts $sock ""

       flush $sock

       set checker 0

       while {[eof $sock] != 1 && $checker == 0} {

      set bl [gets $sock]

           if {[string first "Tired of seeing a" $bl] != -1} { set checker 1 }

      if {[string first "/projects/" $bl] != -1 && [string first "sourceforge.net" $bl] == -1} {

          set link "www.freshmeat.net/[string range $bl [shrink + 8 " href=\"" 0 $bl] [shrink - 1 "/\">" 0 $bl]]"

          set newsline [string range $bl [shrink + 9 "#000000\">" 0 $bl] [shrink - 1 "</font>" 0 $bl]]

          puts $temp "$newsline -  $link"

      }

       }

   }

   close $sock ; close $temp

   if {$freshmeatlastnews == "none" } { putlog "freshmeat: headlinefile created" ; return 0 }

   set temp [open "freshmeat.hdl" r]

   while { [eof $temp] != 1 } {

       set freshmeatneunews [gets $temp]

       if {($freshmeatlastnews == $freshmeatneunews) || ($counter == $freshmeatnewspostlimit)} { close $temp;return 0 }

       incr counter

       if { $isfreshmeathub == "1" } { sendfreshmeatnews $freshmeatneunews }

       foreach chan [channels] {

      if {$freshmeatchans == "" } { putserv "privmsg $chan :\[\002Freshmeat.net\002\] $freshmeatneunews" }

          if {$freshmeatchans != "" } {

         if {([lsearch -exact [string tolower $freshmeatchans] [string tolower $chan]] != -1) || ($freshmeatchans == "")} {putserv "privmsg $chan :\[\002Freshmeat.net\002\] $freshmeatneunews"}

          }

       }

   }

    }

}



set fmeat_timer [timerexists "freshmeatcheck"]

if {$fmeat_timer != ""} { killtimer $fmeat_timer }

catch { unset fmeat_timer }



if {$freshmeat(autonews) == 1} { freshmeatcheck }





proc msg_freshmeat { nick uhost hand arg } { global freshmeatlimit ; freshmeatnews $nick $freshmeatlimit }

proc pub_freshmeat { nick uhost hand chan arg } { global freshmeatchans freshmeatlimit ; if {([lsearch -exact [string tolower $freshmeatchans] [string tolower $chan]] != -1) || ($freshmeatchans == "")} { freshmeatnews $nick $freshmeatlimit }}

proc msg_freshmeatsearch { nick uhost hand arg } { global freshmeatlimit ; freshmeatsearch $nick $freshmeatlimit $arg}

proc pub_freshmeatsearch { nick uhost hand chan arg } { global freshmeatchans freshmeatlimit ; if {([lsearch -exact [string tolower $freshmeatchans] [string tolower $chan]] != -1) || ($freshmeatchans == "")} { freshmeatsearch $nick $freshmeatlimit $arg }}



#[EOF]

_________________
\dev\null
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber