Jump to content

Archived

This topic is now archived and is closed to further replies.

chain

Twitter Search for Eggdrop

Recommended Posts

  • Administrators

Twitter Search for Eggdrop

 

ggdrop script that searches Twitter for mentions of a word(s) and returns the results to the channel.

 

Default trigger: !tsearch

Chanset: +tsearch

Syntax: !tsearch search words here

 

Advanced Searches::

Normal: !tserch words here

From a User: !tsearch from:UserNameHere

To a User: !tsearch to:UserNameHere

Referencing a User: !tsearch @UserNameHere

Hashtag: !tsearch #HashTagHere

Mixed Example: !tsearch from:UserNameHere search words here

 

Example Output:

15:32:07 !tsearch mirc

15:32:09 Twitter ahora recuerdo porque deje de entrar al #Mirc by lordpatto http://twitter.com/lordpatto/statuses/24877726982

15:32:10 Twitter Agreed RT @demenece: a twitter le falta el /me. Que era uno de los features m%s divertidos del mIRC. En realidad a todos los chats les falta by martinszy http://twitter.com/martinszy/statuses/24877183504

15:32:11 Twitter curto pacarai esses memes de tuiter. "Faust'o Morreu". No tempo do mirc a gente dizia q a Hebe tinha morrido. by guicz http://twitter.com/guicz/statuses/24876869318

15:32:13 Twitter @cjorchard First it was the web then it was an API script in mIRC then a gadget in Windows 7 now TweetDeck. by Zetacon http://twitter.com/Zetacon/statuses/24876536248

Example Advanced Search:

 

09:36:32 !tsearch water from:fordlawnmower

09:36:34 Twitter The U.S. state that contains the most square miles of inland water is Alaska. by FordLawnmower http://twitter.com/FordLawnmower/statuses/24747078031

09:36:35 Twitter A giraffe can go without water longer than a camel can. by FordLawnmower http://twitter.com/FordLawnmower/statuses/24687549208

09:36:36 Twitter 2 results

 

**Note** You have to add the +tsearch flag for each channel you want this script running in. (ie. .chanset #chan +tsearch)

 

>################################################################################################  ## TwitterSearch.tcl for eggdrop by Ford_Lawnmower irc.geekshed.net #Script-Help    ##  ##################################################################################################   To use this script you must set channel flag +tsearch (ie .chanset #chan +tsearch)     ################################################################################################################################################################################################  ##                             Start Setup.                                         ##  ################################################################################################## Change the character between the "" below to change the command character/trigger.       ##set twittersearchcmdchar "!"proc twittersearch {nick host hand chan search} {  if {[lsearch -exact [channel info $chan] +tsearch] != -1} {## Change the characters between the "" below to change the logo shown with each result.    ##    set twittersearchlogo "\002\00314T\0034w\0038i\00314t\0039t\0034e\00314r\002\003"## Change the format codes between the "" below to change the color/state of the text.      ##    set textf "\0034"	set linkf "\002\037\003"	set authorf "\002\0037"## Change twittersearchmax to change the maximum results returned to the channel.         	##	set twittersearchmax 4################################################################################################  ##                           End Setup.                                              ## ################################################################################################    set twittersearchsite "search.twitter.com"	if {$search == ""} { 	  putserv "PRIVMSG $chan :$twittersearchlogo ${textf} You must provide at least one search term!"	} else {	  set twittersearch  [urlencode [regsub -all { } $search +]]	  set twittersearchurl "/search.atom?q=${twittersearch}"	  set twittersearchfound ""	  set tslink ""	  set tsauthor ""	  set tstitle ""	  set tscount 1      if {[catch {set twittersearchsock [socket -async $twittersearchsite 80]} sockerr]} {        putlog "$twittersearchsite $twittersearchurl $sockerr error"        return 0        } else {        puts $twittersearchsock "GET $twittersearchurl HTTP/1.0"        puts $twittersearchsock "Host: $twittersearchsite"        puts $twittersearchsock "User-Agent: Opera 9.6"        puts $twittersearchsock ""        flush $twittersearchsock        while {![eof $twittersearchsock]} {          set twittersearchvar " [gets $twittersearchsock] "		  if {$tscount > $twittersearchmax} {		    close $twittersearchsock            return 0 		  } elseif {[regexp {} $twittersearchvar match tslink]} {		    noop		  } elseif {[regexp {(.*)} $twittersearchvar match tstitle]} {		    noop		  } elseif {[regexp {http://twitter.com/(.*)} $twittersearchvar match tsauthor]} {		    putserv "PRIVMSG $chan :$twittersearchlogo [recode "${textf}${tstitle} ${authorf}by ${tsauthor} ${linkf}${tslink}"]"			incr tscount		  }        }	putserv "PRIVMSG $chan :$twittersearchlogo ${textf} [expr ${tscount} - 1] results"	close $twittersearchsock    return 0 	      }    }  }}proc urlencode {string} {  return [subst [regsub -nocase -all {([^a-z0-9+])} $string {%[format %x [scan "\\&" %c]]}]]}proc recode { textin } {  return [string map {" \" · · & &} [subst [regsub -nocase -all {([0-9]{1,5});} $textin {\u\1}]]]}proc noop {} { return 1 }bind pub - ${twittersearchcmdchar}tsearch twittersearchsetudef flag tsearchputlog "TwitterSearch Script by Ford_Lawnmower successfully loaded!"

Link to comment
Share on other sites



×
×
  • Create New...