Twitter status problem

Help for those learning Tcl or writing their own scripts.
Post Reply
s
sdays
Halfop
Posts: 98
Joined: Sat Oct 21, 2006 4:46 am

Twitter status problem

Post by sdays »

Well I requested twitter status few days ago and no one even bothered to reply but anyways I'm having a problem with it I got this far the code prob sucks but it half works..

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"
    }
  }
}
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Re: Twitter status problem

Post by speechles »

Code: Select all

# Twitter by sdays v1.0a
# egghelp version.. YAY

set twitter(logo) "Twitter"
set twitter(agent) "Mozilla/4.75 (X11; U; Linux 2.2.17; i586; Nav)"

# check if http version 2.5 or greater is used
# if so, we can use utf-8 features, otherwise
# fall back to standard iso8859-1
if {[catch {package require http 2.5} e] != 0]} {
  set twitter(noutf8) 1
  package require http
}
setudef flag twitter

bind pub - !twitter proc:twitter

proc proc:twitter {nick uhand handle chan input} {
  if {[channel get $chan twitter]} {
    global twitter
    if {![llength [split $input]]} {
      putserv "PRIVMSG $chan :Please be more specific I need a user name example: !twitter username"
    } else {
      # spam our header message before we attempt to get data..
      putquick "PRIVMSG $chan :\002$twitter(logo)\002: Getting Status For: $input..."
      # proper support for utf-8; twitter uses utf-8
      # *requires http 2.5+
      if {[info exists twitter(noutf8)]} {
        set http [::http::config -useragent $twitter(agent)]
      } else {
        set http [::http::config -useragent $twitter(agent) -urlencoding "utf-8"]
      }
      # fancy url constructor; utf-8 safe; special character safe
      # *uses http packages format query
      foreach word [split $input] {
        lappend query [lindex [split [http::formatQuery a $word] =] 1]
      }
      # error catching
      catch { set http [::http::geturl "http://twitter.com/[join $query +]" -timeout 5000 } error
      # error condition 1, socket error
      if {![string match -nocase "::http::*" $error]} {
        putserv "privmsg $chan :\002$twitter(logo)\002: [string totitle [string map {"\n" " | "} $error]] \( $query \)"
        return 0
      }
      # error condition 2, http error
      if {![string equal -nocase [::http::status $http] "ok"]} {
        putserv "privmsg $chan :\002$twitter(logo)\002: [string totitle [::http::status $http]] \( $query \)"
        return 0
      }
      # no error, get data
      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>} $html - totaltweets]} {set totaltweets [string trim $totaltweets]}
      if {[regexp -- {<span class="entry-content">(.+?)</span>} $html - ltweet]} {
        set ltweet [string trim $ltweet]
        # scrub html elements out
        regsub -all -- {<a class=.*?>} $ltweet "" ltweet
        regsub -all -- {<a href=.*?>} $ltweet "" ltweet
        regsub -all -- {</a>} $ltweet "" ltweet
      }
      # check if a variable we scraped exists
      if {[info exists following]} {
        # if so, spamtastic!
        putserv "PRIVMSG $chan :Following: $following; Followers: $followers; Listed: $listed; Total Tweets: $totaltweets"
        putserv "PRIVMSG $chan :Last Tweet: $ltweet"
        putserv "PRIVMSG $chan :$query"
      } else {
        # if not, give a funny message, bascially the regexp's above are
        # broken and need maintenance when this message appears.
        putserv "PRIVMSG $chan :Houston, we have a problem. Oxygen level is low. Atmospheric pressure is dropping."
      }
    }
  }
}
s
sdays
Halfop
Posts: 98
Joined: Sat Oct 21, 2006 4:46 am

Post by sdays »

Thanks speechless I found few bugs which wouldn't let it work so I played around with it and fixed it and added user/protected tweaks check as well. Anyways Here is the script now just if anyone wants to use it or edit or something.

Edited updated.

Code: Select all

# Twitter by Warlord v1.1a
# Rewrite by egghelp and tweaked by warlord.. 
# Type in partyline: ".chanset #channel +twitter" to enable it.

# This is the twitter logo.
set twitter(logo) "\[\002\00311Twitter\002\003]:"

# Set user agent.
set twitter(agent) "Mozilla/4.75 (X11; U; Linux 2.2.17; i586; Nav)"

# Chanset command.
setudef flag twitter

# check if http version 2.5 or greater is used
# if so, we can use utf-8 features, otherwise
# fall back to standard iso8859-1
if {[catch {package require http 2.5} e] != 0} { 
  set twitter(noutf8) 1
  package require http
}

bind pub - !twitter proc:twitter

proc proc:twitter {nick uhand handle chan input} {
  if {[channel get $chan twitter]} {
    global twitter
    if {![llength [split $input]]} {
      putserv "PRIVMSG $chan :$twitter(logo) Please be more specific I need a user name example: !twitter username"
      } else {
      # spam our header message before we attempt to get data..
      putquick "PRIVMSG $chan :$twitter(logo) Getting Status For: $input..."
      # proper support for utf-8; twitter uses utf-8
      # *requires http 2.5+
      if {[info exists twitter(noutf8)]} {
        set http [::http::config -useragent $twitter(agent)]
        } else {
        set http [::http::config -useragent $twitter(agent) -urlencoding "utf-8"]
      }
      # fancy url constructor; utf-8 safe; special character safe
      # *uses http packages format query
      foreach word [split $input] {
        lappend query [lindex [split [http::formatQuery a $word] =] 1]
      }
      # error catching
      catch { set http [::http::geturl "http://twitter.com/[join $query +]" -timeout 5000]} error
        # error condition 1, socket error
        if {![string match -nocase "::http::*" $error]} {
          putserv "privmsg $chan :$twitter(logo) [string totitle [string map {"\n" " | "} $error]] \( $query \)"
          return 0
        }
        # error condition 2, http error
        if {![string equal -nocase [::http::status $http] "ok"]} {
          putserv "privmsg $chan :$twitter(logo) [string totitle [::http::status $http]] \( $query \)"
          return 0
        } 
        # Get data.	
        set html [::http::data $http]
        regsub -all "\n" $html "" html
        #checks if the person protected their profile.

        	#checks to see if there is a username
        	if {[regexp -- {<h2>Sorry, that page doesn.t exist!</h2>} $html]} {		
        putserv "privmsg $chan :$twitter(logo) There is no such username"
        	return 0
      }
      		        	
      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>} $html - totaltweets]} {set totaltweets [string trim $totaltweets]}
      if {[regexp -- {<span class="entry-content">(.+?)</span>} $html - ltweet]} { 
        set ltweet [string trim $ltweet]
        # scrub html elements out
        regsub -all -- {<a class=.*?>} $ltweet "" ltweet
        regsub -all -- {<a href=.*?>} $ltweet "" ltweet
        regsub -all -- {</a>} $ltweet "" ltweet
      }
      # check if a variable we scraped exists
      if {[info exists following]} {
        # if so, spamtastic!
        	  if {[regexp -- {<div class="protected-box">} $html]} {
          putserv "PRIVMSG $chan :$twitter(logo) Following: $following; Followers: $followers; Listed: $listed; Total Tweets: Tweets Protected."		
          putserv "privmsg $chan :$twitter(logo) This person has protected their tweets."
          } else {
          	  putserv "PRIVMSG $chan :$twitter(logo) Following: $following; Followers: $followers; Listed: $listed; Total Tweets: $totaltweets."
          	  if {[info exists ltweet]} {
            putserv "PRIVMSG $chan :$twitter(logo) Last Tweet: $ltweet"
            	  } else {
            	  putserv "PRIVMSG $chan :$twitter(logo) I'm sorry, this user has no tweets."
          	  }
        	  }
        	  putserv "PRIVMSG $chan :$twitter(logo) http://twitter.com/$query"
        } else {
        # if not, give a funny message, bascially the regexp's above are
        # broken and need maintenance when this message appears.
        putserv "PRIVMSG $chan :Houston, we have a problem. Oxygen level is low. Atmospheric pressure is dropping."
      }
    }
  }
}

putlog "Twitter-1.1a - Originally by Warlord/Rewrite by egghelp and tweaked by warlord.."
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

here it is slightly tweaked further to trap 40* codes before grabbing html (error condition 3) also cleans up the url encoder to be faster, added http::cleanup, dynamic putserv messaging.

Code: Select all

# Twitter by Warlord v1.1b
# Rewrite by egghelp and tweaked by warlord..
# Type in partyline: ".chanset #channel +twitter" to enable it.

# -- config begins

# This is the twitter logo.
set twitter(logo) "\[\002\00311Twitter\002\003]:"

# Set user agent.
set twitter(agent) "Mozilla/4.75 (X11; U; Linux 2.2.17; i586; Nav)"

# Set the url base
set twitter(url) "http://twitter.com/"

# Set the output style here:
# %chan == $chan, %nick == $nick
# no other variables can be used
set twitter(output) "PRIVMSG %chan"

# -- script begins

# Chanset command.
setudef flag twitter

# check if http version 2.5 or greater is used
# if so, we can use utf-8 features, otherwise
# fall back to standard iso8859-1
if {[catch {package require http 2.5} e] != 0} {
  set twitter(noutf8) 1
  package require http
}

bind pub - !twitter proc:twitter

proc proc:twitter {nick uhand handle chan input} {
  if {[channel get $chan twitter]} {
    global twitter
    # string map in replacements for output
    set to [string map [list "%chan" $chan "%nick" $nick] $twitter(output)]
    if {![llength [split $input]]} {
      putserv "$to :$twitter(logo) Please be more specific I need a user name example: !twitter username"
    } else {
      # spam our header message before we attempt to get data..
      putquick "$to :$twitter(logo) Getting Status For: $input..."
      # proper support for utf-8; twitter uses utf-8
      # *requires http 2.5+
      if {[info exists twitter(noutf8)]} {
        set http [::http::config -useragent $twitter(agent)]
      } else {
        set http [::http::config -useragent $twitter(agent) -urlencoding "utf-8"]
      }
      # fancy url constructor; utf-8 safe; special character safe
      # *uses http packages format query
      foreach word [split $input] { lappend query [http::formatQuery $word] }
      # error catching, this also captures our url into the variable u
      catch { set http [::http::geturl "[set u "$twitter(url)[join $query +]"]" -timeout 5000]} error
      # error condition 1, socket error or other general error
      if {![string match -nocase "::http::*" $error]} {
        putserv "$to :$twitter(logo) [string totitle [string map {"\n" " | "} $error]] \( $u \)"
        return 0
      }
      # error condition 2, http error
      if {![string equal -nocase [::http::status $http] "ok"]} {
        putserv "$to :$twitter(logo) [string totitle [::http::status $http]] \( $u \)"
        return 0
      }
      # error condition 3, 40* error
      if {[string equal -nocase "40*" [::http::ncode $http]]} {
        putserv "$to :$twitter(logo) \[[::http::ncode $http]\] Sorry, that page doesn't exist! \( $u \)"
        return 0
      }
      # get data.   
      set html [::http::data $http]
      # cleanup http array
      ::http::cleanup $http
      regsub -all "\n" $html "" html          
      # scrape output    
      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>} $html - totaltweets]} {set totaltweets [string trim $totaltweets]}
      if {[regexp -- {<span class="entry-content">(.+?)</span>} $html - ltweet]} {
        # scrub html elements out
        regsub -all -- {<a class=.*?>} [string trim $ltweet] "" ltweet
        regsub -all -- {<a href=.*?>} $ltweet "" ltweet
        regsub -all -- {</a>} $ltweet "" ltweet
      }
      # check if a variable we scraped exists
      if {[info exists following]} {
        # protected tweets?
        if {[regexp -- {<div class="protected-box">} $html]} {
          # yes
          putserv "$to :$twitter(logo) Following: $following; Followers: $followers; Listed: $listed; Total Tweets: Tweets Protected."      
          putserv "$to :$twitter(logo) This person has protected their tweets."
        } else {
          # no
          putserv "$to :$twitter(logo) Following: $following; Followers: $followers; Listed: $listed; Total Tweets: $totaltweets."
          # a last tweet?
          if {[info exists ltweet]} {
            # yes
            putserv "$to :$twitter(logo) Last Tweet: $ltweet"
          } else {
            # no
            putserv "$to :$twitter(logo) I'm sorry, this user has no tweets."
          }
        }
        # give url for clickability
        putserv "$to :$twitter(logo) $u"
      } else {
        # if not, give a funny message, bascially the regexp's above are
        # broken and need maintenance when this message appears.
        putserv "$to :$twitter(logo) Houston, we have a problem. Oxygen level is low. Atmospheric pressure is dropping."
      }
    }
  }
}

putlog "Twitter-1.1b - Originally by Warlord/Rewrite by egghelp and tweaked by warlord.."
s
sdays
Halfop
Posts: 98
Joined: Sat Oct 21, 2006 4:46 am

Post by sdays »

[13:52:27] <@Warlord> !twitter gov
[13:52:28] <@ps3> [Twitter]: Getting Status For: gov...
[13:52:28] <@ps3> [Twitter]: Houston, we have a problem

So I tried adding this code and nothing..

Code: Select all

if {[regexp -- {<body class="static" id="suspended">} $html]} {
   putserv "$to :$twitter(logo) Sorry, the profile you were trying to view has been suspended due to strange activity."
   return 0
        }
The main url is: http://twitter.com/gov but it redirects to http://twitter.com/suspended not sure if the redirect messes it up or what, any idea?
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

This will trap redirects as errors and display the message. (error condition 4)...

Code: Select all

Code:
# Twitter by Warlord v1.1b
# Rewrite by egghelp and tweaked by warlord..
# Type in partyline: ".chanset #channel +twitter" to enable it.

# -- config begins

# This is the twitter logo.
set twitter(logo) "\[\002\00311Twitter\002\003]:"

# Set user agent.
set twitter(agent) "Mozilla/4.75 (X11; U; Linux 2.2.17; i586; Nav)"

# Set the url base
set twitter(url) "http://twitter.com/"

# Set the output style here:
# %chan == $chan, %nick == $nick
# no other variables can be used
set twitter(output) "PRIVMSG %chan"

# -- script begins

# Chanset command.
setudef flag twitter

# check if http version 2.5 or greater is used
# if so, we can use utf-8 features, otherwise
# fall back to standard iso8859-1
if {[catch {package require http 2.5} e] != 0} {
  set twitter(noutf8) 1
  package require http
}

bind pub - !twitter proc:twitter

proc proc:twitter {nick uhand handle chan input} {
  if {[channel get $chan twitter]} {
    global twitter
    # string map in replacements for output
    set to [string map [list "%chan" $chan "%nick" $nick] $twitter(output)]
    if {![llength [split $input]]} {
      putserv "$to :$twitter(logo) Please be more specific I need a user name example: !twitter username"
    } else {
      # spam our header message before we attempt to get data..
      putquick "$to :$twitter(logo) Getting Status For: $input..."
      # proper support for utf-8; twitter uses utf-8
      # *requires http 2.5+
      if {[info exists twitter(noutf8)]} {
        set http [::http::config -useragent $twitter(agent)]
      } else {
        set http [::http::config -useragent $twitter(agent) -urlencoding "utf-8"]
      }
      # fancy url constructor; utf-8 safe; special character safe
      # *uses http packages format query
      foreach word [split $input] { lappend query [http::formatQuery $word] }
      # error catching, this also captures our url into the variable u
      catch { set http [::http::geturl "[set u "$twitter(url)[join $query +]"]" -timeout 5000]} error
      # error condition 1, socket error or other general error
      if {![string match -nocase "::http::*" $error]} {
        putserv "$to :$twitter(logo) [string totitle [string map {"\n" " | "} $error]] \( $u \)"
        return 0
      }
      # error condition 2, http error
      if {![string equal -nocase [::http::status $http] "ok"]} {
        putserv "$to :$twitter(logo) [string totitle [::http::status $http]] \( $u \)"
        return 0
      }
      # error condition 3, 40* error
      if {[string equal -nocase "40*" [::http::ncode $http]]} {
        putserv "$to :$twitter(logo) \[[::http::ncode $http]\] Sorry, that page doesn't exist! \( $u \)"
        return 0
      }
      # error condition 4, 30* error , these redirect to special pages (suspended, etc)
      if {[string equal -nocase "30*" [::http::ncode $http]]} {
        putserv "$to :$twitter(logo) \[[::http::ncode $http]\] Sorry, the profile you were trying to view has been suspended due to strange activity. \( $u \)"
        return 0
      }
      # get data.   
      set html [::http::data $http]
      # cleanup http array
      ::http::cleanup $http
      regsub -all "\n" $html "" html         
      # scrape output   
      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>} $html - totaltweets]} {set totaltweets [string trim $totaltweets]}
      if {[regexp -- {<span class="entry-content">(.+?)</span>} $html - ltweet]} {
        # scrub html elements out
        regsub -all -- {<a class=.*?>} [string trim $ltweet] "" ltweet
        regsub -all -- {<a href=.*?>} $ltweet "" ltweet
        regsub -all -- {</a>} $ltweet "" ltweet
      }
      # check if a variable we scraped exists
      if {[info exists following]} {
        # protected tweets?
        if {[regexp -- {<div class="protected-box">} $html]} {
          # yes
          putserv "$to :$twitter(logo) Following: $following; Followers: $followers; Listed: $listed; Total Tweets: Tweets Protected."     
          putserv "$to :$twitter(logo) This person has protected their tweets."
        } else {
          # no
          putserv "$to :$twitter(logo) Following: $following; Followers: $followers; Listed: $listed; Total Tweets: $totaltweets."
          # a last tweet?
          if {[info exists ltweet]} {
            # yes
            putserv "$to :$twitter(logo) Last Tweet: $ltweet"
          } else {
            # no
            putserv "$to :$twitter(logo) I'm sorry, this user has no tweets."
          }
        }
        # give url for clickability
        putserv "$to :$twitter(logo) $u"
      } else {
        # if not, give a funny message, bascially the regexp's above are
        # broken and need maintenance when this message appears.
        putserv "$to :$twitter(logo) Houston, we have a problem. Oxygen level is low. Atmospheric pressure is dropping."
      }
    }
  }
}

putlog "Twitter-1.1b - Originally by Warlord/Rewrite by egghelp and tweaked by warlord.."
s
sdays
Halfop
Posts: 98
Joined: Sat Oct 21, 2006 4:46 am

Post by sdays »

putserv "$to :$twitter(logo) Houston, we have a problem. Oxygen level is low. Atmospheric pressure is dropping."

I get that message than the profile has been locked.
F
Football
Master
Posts: 205
Joined: Fri Dec 26, 2008 3:08 pm
Location: Quakenet, #Football

Post by Football »

This is a really great script, any chance for a link to the fixed script?
Idling at #Football, Quakenet.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Took some time to actually test this myself and fixed a few bugs here and there. Also expanded the syntax for the last tweet. This will allow tweets to carry over the url's mentioned when parsing syntax. Rather than scrubbing all html elements out, this cleverly leaves them intact but neatly. This should look more professional. ;)

This also falls in line with some of my other scripts. Meaning you can use Trf or zlib packages and make your twitter requests using Gzip saving you time and bandwidth. Falling in line also means "full support for utf-8" is a must, and also offered _if_ your bot is utf-8 patched. You can read tweets in any language. It's just fine alrighty if you do.. ;)
<speechles> !twitter whitehouse
<sp33chy> [Twitter]: Getting Status For: whitehouse...
<sp33chy> [Twitter]: Name: The White House; Location: Washington, DC USA; Following: 87; Followers: 1,694,567; Listed: 13,925; Total Tweets: 202.
<sp33chy> [Twitter]: Last Tweet: [about 4 hours ago] Hit him with your best shot: submit your questions for Obama, vote on others via YT. He answers Monday ( http://bit.ly/QaZPN )
<sp33chy> [Twitter]: http://twitter.com/whitehouse

<speechles> !twitter google
<sp33chy> [Twitter]: Getting Status For: google...
<sp33chy> [Twitter]: Name: A Googler; Location: Mountain View, CA; Following: 222; Followers: 2,119,659; Listed: 21,138; Total Tweets: 1,083.
<sp33chy> [Twitter]: Last Tweet: [41 minutes ago] Have you heard? The growth of Unicode on the web is nearing 50%. ( http://bit.ly/ddGFd9 ) #unicode ( http://twitter.com/search?q=%23unicode )
<sp33chy> [Twitter]: http://twitter.com/google
This is now a full featured script. Does not use cookies, or allow logins (yet *), but it does handle multiple redirects and should catch all messages (protected, suspended, and locked). Enjoy and have a fun ;P

For those who want to get it: Click here

* Note: I have special plans to add a second trigger to this script, which will allow you to set up individual accounts for each of your channels. It would work like this:
<Nick> !tweet Does this even work?
The bot then logs into the twitter account assigned to that specific channel the command was issued in and posts this as a tweet. The form the tweet takes would basically be, "<Nick> Does this even work?". Then later typing "!twitter <your channel's account name here>" would reveal the last person to use the !tweet command in that channel as well as the url to the full twitterings. This would fully integrate the capability of twitter onto IRC for your users. This is probably more than you had envisioned, but this would be rather interesting to see. This weekend it should be realized and available. Below is an example:
** in #eggdrop which is tied to the twitter account "mychan"...

<speechles> !tweet CAN YOU HEAR MY #EGGDROP http://forum.egghelp.org/viewtopic.php?p=91876
<sp33chy> [Twitter]: [#eggdrop@mychan] Your tweet was successful!

<speechles> !twitter mychan
<sp33chy> [Twitter]: Getting Status For: mychan...
<sp33chy> [Twitter]: Name: #eggdrop; Location: @My network; Following: 510; Followers: 48; Listed: 113; Total Tweets: 115.
<sp33chy> [Twitter]: Last Tweet: [32 seconds ago] <speechles> CAN YOU HEAR MY #EGGDROP ( http://twitter.com/search?q=%23EGGDROP ) ( http://forum.egghelp.org/viewtopic.php?p=91876 )
<sp33chy> [Twitter]: http://twitter.com/mychan
Stay tuned...
s
sdays
Halfop
Posts: 98
Joined: Sat Oct 21, 2006 4:46 am

Post by sdays »

Nice speechless so your planning on making it post text for yourchan account I found a script on google and edited it a bit I know it sucks but it may still work:

Code: Select all

set ::setup(trigger)   "!twitterp"

set ::setup(apibase)   "http://twitter.com/"
set ::setup(apiupdate) "statuses/update.json"
set ::setup(url)       $::setup(apibase)$::setup(apiupdate)

set ::setup(user)      "user"
set ::setup(pass)      "pass"
set ::setup(curl)      "/usr/bin/curl"

set ::setup(confirm)   "\002Success!\017 @ $::setup(apibase)$::setup(user)"

# binds
bind pub - $::setup(trigger) twitcl:twitter

############################################


proc twitcl:twitter {nick uhost handle channel text} {
  global twitcl
  set text [twitcl:mapevil $text]
  if {[catch {exec $::setup(curl) --basic --user "$::setup(user):$::setup(pass)" -d "status=($nick): $text" $::setup(url)} result]} {
    putquick "PRIVMSG $channel : $::setup(confirm)"
  } else {
  putquick "PRIVMSG $channel : \002Err.. Something b0rked!\017"

  }

}


# map 'em evil chars
proc twitcl:mapevil {string} {
  global twitcl
  return [string map {\< < \> >} $string]
}
F
Football
Master
Posts: 205
Joined: Fri Dec 26, 2008 3:08 pm
Location: Quakenet, #Football

Post by Football »

speechless, well done, I`ll look forward to this script it would be very much useful :-)
Idling at #Football, Quakenet.
Post Reply