Eggdrop script that searches Twitter for mentions of a word(s) and returns the results to the channel.
**Requires Openssl and tls
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 <!Ford> !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 <!Ford> !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) ##
##############################################################################################
#package require http
package require tls
##############################################################################################
## ## Start Setup. ## ##
##############################################################################################
## Change the character between the "" below to change the command character/trigger. ##
namespace eval twittersearch {
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 "\00304"
set authorf "\002\00314"
## Change twittersearchmax to change the maximum results returned to the channel. ##
set twittersearchmax 3
##############################################################################################
## ## End Setup. ## ##
##############################################################################################
set twittersearchsite "twitter.com"
if {$search == ""} {
putserv "PRIVMSG $chan :$twittersearchlogo ${textf} You must provide at least one search term!"
} else {
set twittersearch [urlencode $search]
set twittersearchurl "/i/search/timeline?type=relevance&include_available_features=1&include_entities=1&q=${twittersearch}"
set twittersearchfound ""
set tslink ""
set tsauthor ""
set tstitle ""
set tscount 1
if {[catch {set twittersearchsock [tls::socket $twittersearchsite 443]} sockerr]} {
putlog "$twittersearchsite $twittersearchurl $sockerr error"
return 0
} else {
puts $twittersearchsock "GET $twittersearchurl HTTP/1.0"
puts $twittersearchsock "Host: $twittersearchsite"
puts $twittersearchsock ""
flush $twittersearchsock
while {![eof $twittersearchsock]} {
set twittersearchvar " [gets $twittersearchsock] "
set twittersearchdata [string map {\\u003c < \\u003e > < < > > \\n "" \\\/ / " \" " " [ \\[ ] \\] $ \\$} $twittersearchvar]
set twittersearchresults [regexp -all -inline {<p\sclass=\\"js-tweet-text\stweet-text\\">(.*?)<\/p>} $twittersearchdata]
regsub -all {<.*?>} $twittersearchresults {} twittersearchresults
set twittersearchusers [regexp -all -inline {js-user-profile-link\sjs-nav\\"\shref=\\"\/(.*?)\\"} $twittersearchdata]
set count 1
set counter 1
while {$counter <= $twittersearchmax && [lindex $twittersearchusers $count] != ""} {
putchan $chan "${authorf}[recode [lindex $twittersearchusers $count]]: ${textf}[recode [lindex $twittersearchresults $count]]"
incr counter
incr count 2
}
}
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 twittersearch::twittersearch
setudef flag tsearch
putlog "TwitterSearch Script by Ford_Lawnmower successfully loaded!"
}
Hello Mr. FordLawnmower this Script Proper Install and no error. I follow your every step but i try use Syntax i get no result.
I use All Syntax:
~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
No result Show. IDK what the Problem why i not get Search Result.
Added advanced search description.
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 Advanced Search:
09:36:32 <!Ford> !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