Here is the problem I'm having:
[23:48:31] <@Warlord> !twitter google
[23:48:33] <@Xbox360> Twitter Getting Status For: google.
[23:48:34] <@Xbox360> Following: 219 Followers: 2,110,984 Listed: 20,284 Total Tweets: 161
[23:48:34] <@Xbox360> Last Tweet: RT @<a class="tweet-url username" href="/googlenexusone">googlenexusone</a>: In case you missed it, check out Patrick Boivin's awesome Nexus One unboxing video <a href="http://bit.ly/6bAhxZ" class="tweet-url web" rel="nofollow" target="_blank">http://bit.ly/6bAhxZ</a> <a href="/search?q=%23ninja" title="#ninja" class="tweet-url hashtag">#ninja</a>
[23:48:36] <@Xbox360> http://twitter.com/google
It posts html code with the last tweet any idea?
Code: Select all
package require http
setudef flag twitter
set twitterlogo "Twitter"
bind pub - !twitter proc:twitter
set agent "Mozilla/4.75 (X11; U; Linux 2.2.17; i586; Nav)"
proc proc:twitter {nick uhand handle chan input} {
if {[lsearch -exact [channel info $chan] +twitter] != -1} {
global botnick agent twitterlogo
if {[llength $input]==0} {
putserv "PRIVMSG $chan :Please be more specific I need a user name example: !twitter username"
} else {
set query "http://twitter.com/"
for { set index 0 } { $index<[llength $input] } { incr index } {
set query "$query[lindex $input $index]"
if {$index<[llength $input]-1} then {
set query "$query+"
}
}
set http [::http::config -useragent $agent]
set http [::http::geturl $query]
set html [::http::data $http]
regsub -all "\n" $html "" html
if {[regexp -- {<span id="following_count" class="stats_count numeric">(.+?) </span>} $html - following]} {set following [string trim $following]}
if {[regexp -- {<span id="follower_count" class="stats_count numeric">(.+?) </span>} $html - followers]} {set followers [string trim $followers]}
if {[regexp -- {<span id="lists_count" class="stats_count numeric">(.+?) </span>} $html - listed]} {set listed [string trim $listed]}
if {[regexp -- {<span id="update_count" class="stat_count">(.+?)</span><span>Tweets</span></a></li>} $html - totaltweets]} {set totaltweets [string trim $totaltweets]}
if {[regexp -- {<span class="entry-content">(.+?)</span>} $html - ltweet]} {set ltweet [string trim $ltweet]}
putquick "PRIVMSG $chan :$twitterlogo Getting Status For: $input."
putserv "PRIVMSG $chan :Following: $following Followers: $followers Listed: $listed Total Tweets: $totaltweets"
putserv "PRIVMSG $chan :Last Tweet: $ltweet"
putserv "PRIVMSG $chan :$query"
}
}
}