Jump to content

Archived

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

chain

!twitter

Recommended Posts

  • Administrators

!twitter and will display most recent post for requested name. modifiable.

 

Currently it works with any TWITTER screen name. And irc users can assign a twitter name to their $nick. This will be added to a hast table according to the network this occurred on. (this is for bots that live on multiple networks, allowing $nick to twitter links separate)

 

See commands located in the code for basic command instructions.

 

It is setup right now to grab all the data from the xml page and set them to all to corresponding variables.(long list of if statements) To view what it returns, just comment out the unset %t_* at the bottom of the script. execute the script (ex: !twitter eqrunner) and then look at your variables.

 

 

>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; twitter ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; by eqrunner ;;;v1.0;; /*!twitter $null                           Will return default name for said network - see: if (%t_2 == $null)!twitter [twittername|irc nick]          Will return said users posting(s) (if not already assigned to a irc $nick)!twitter [twittername] [s|stats|status]  Will return following/follower data!twitter [twittername] [last|time]       Will return with date and time of last post (GMT) time!twitter Register [twittername]          Will assign said twitter name with that $nick that send this command in that $network !twitter Remove [twittername]            Will remove the nick from the hash tag registry */ on *:CONNECT: {  var %twitter_file  $+(twitter_,$network)  hmake %twitter_file 100  if ($isfile($+(%twitter_file,.dat))) { hload %twitter_file $+(%twitter_file,.dat) }}ON *:DISCONNECT: {  var %twitter_file  $+(twitter_,$network)  if ($hget(%twitter_file)) { hsave -o %twitter_file $+(%twitter_file,.dat) }} on *:TEXT:!twitter*:#: {  unset %t_*  set %t_nick $nick  set %t_chan $chan  set %t_network $network  set %t_2 $2  set %t_3 $3  if ($3 == s) || ($3 == stats) || ($3 == status) { set %t_3 stats | set %t_info_req ON }  if ($3 == last) || ($3 == time) { set %t_3 last | set %t_info_req ON }   if (%t_2 == $null) {    ; set a default for a network and/or a chan so anyone can callup the primary for that chan    if (%t_network == EFnet) set %t_url $+(/statuses/user_timeline.xml?screen_name=,eqrunner)    if (%t_network == iPocalypse) set %t_url $+(/statuses/user_timeline.xml?screen_name=,ShoutDRIVE)    if (%t_network == Hawkee) && (%t_chan == #bots) set %t_url $+(/statuses/user_timeline.xml?screen_name=,HawkeeBot)    if (%t_network == WebChat) && (%t_chan == #thehome) set %t_url $+(/statuses/user_timeline.xml?screen_name=,HawkeeBot)  }  if (%t_2 != $null) {    var %twitter_reg $($+(twitter_,$network))    if (%t_2 == register) && (%t_3 != $null) {      hadd -m %twitter_reg %t_nick %t_3      .msg %t_nick You are now linked to %t_3      set %t_2 $hget(%twitter_reg,%t_nick)    }    if (%t_2 == remove) && (%t_3 != $null) {      hdel %twitter_reg %t_nick      .msg %t_nick You twitter association was removed      twitter_cleanup    }    if ($hget(%twitter_reg,%t_2) != $null ) {      set %t_2 $hget(%twitter_reg,%t_2)    }    set %t_url $+(/statuses/user_timeline.xml?screen_name=,%t_2)  }  sockopen twitter www.twitter.com 80} on *:sockopen:twitter: {  sockwrite -n $sockname GET %t_url  sockwrite -n $sockname www.twitter.com} on *:sockread:twitter: {  sockread %t_temp  if ( isin %t_temp) && (%t_id == $null) set %t_id $remove(%t_temp,,,$chr(9),$chr(32))  if ( isin %t_temp) && (%t_name == $null) set %t_name $remove(%t_temp,,,$chr(9))  if ( isin %t_temp) && (%t_screen_name == $null) set %t_screen_name $remove(%t_temp,,,$chr(9),$chr(32))  if ( isin %t_temp) && (%t_location == $null) set %t_location $remove(%t_temp,,,$chr(9),$chr(32))  if ( isin %t_temp) && (%t_description == $null) set %t_description $remove(%t_temp,,,$chr(9),$chr(32))   if ( isin %t_temp) && (%t_followers_count == $null) set %t_followers_count $remove(%t_temp,,,$chr(9),$chr(32))  if ( isin %t_temp) && (%t_friends_count == $null) set %t_friends_count $remove(%t_temp,,,$chr(9),$chr(32))  if ( isin %t_temp) && (%t_favourites_count == $null) set %t_favourites_count $remove(%t_temp,,,$chr(9),$chr(32))  if ( isin %t_temp) && (%t_time_zone == $null) set %t_time_zone $remove(%t_temp,,,$chr(9),$chr(32))  if ( isin %t_temp) && (%t_statuses_count == $null) set %t_statuses_count $remove(%t_temp,,,$chr(9),$chr(32))   if ( isin %t_temp) inc %t_i  if ( isin %t_temp) set $+(%,t_created_at,%t_i) $remove(%t_temp,,,$chr(9))  if ( isin %t_temp) set $+(%,t_text,%t_i) $remove(%t_temp,,,$chr(9))  if ( isin %t_temp) set $+(%,t_source,%t_i) $remove(%t_temp,,,$chr(9))  if ( isin %t_temp) set %t_error ON} on *:sockclose:twitter: {  if (%t_error == ON) {    msg %t_chan Sorry, %t_2 was not found    twitter_cleanup  }  if (%t_error == $null) {    if (%t_info_req != ON) msg %t_chan %t_screen_name $+ : %t_text1    if (%t_3 == stats) msg %t_chan %t_screen_name $+ : Following: %t_friends_count Followers: %t_followers_count Updates: %t_statuses_count    if (%t_3 == last) msg %t_chan %t_screen_name Last updated: %t_created_at1   }  twitter_cleanup} alias twitter_cleanup {  unset %t_*} 

Link to comment
Share on other sites

  • Administrators
Script was written at the request of lilibox

This script was made to post your friends timeline on a irc channel so that people who have twitter.com blocked at work can still see their updates.

 

While this script does accomplish this task, I designed it to have an @Twitter window that will keep track of your friends timeline so you don't have to open your browser to see their updates.

 

In addition, any non-command that you type in the @Twitter window will automatically update the twitter account that you added in the setup.

 

Getting Started:

**Load the script into a new remote and save with a unique filename.

**Find Twitter Channel on any menu and scroll down to setup.

 

**Click Set UserName and Password

 

**Enter Your username and password

**All Done. @Twitter will open in about 60 seconds :)

 

Advanced Options:

**You can change the delay from setup but the minimum is 30 seconds.

**You can change the output from @Twitter to echo -at

**You can change the output to a #channel.(Make sure you open the menu from the network the #channel is in to change this setting.)

 

 

 

;Twitter Channel by Ford_Lawnmower irc.mindforge.org #USA-Chat

menu * {

  .Twitter Channel

  ..$iif($timer(mIRCTwitter),Off,On): { 

    if ($timer(mIRCTwitter)) { .timermIRCTwitter off }

    else {

      mIRCTwitter

      .timermIRCTwitter -o 0 $iif($hget(mIRCTwitter,Delay),$hget(mIRCTwitter,Delay),60) mIRCTwitter 

    }

  }

  ..SetUp

  ...Set UserName and Password:TwitterAuthCheck $+($$?="Enter your Username",:,$$?*="Enter your Password")

  ...Set Delay:hadd -m mIRCTwitter Delay $iif($$?="Enter Delay in Seconds" > 29,$!,60) | mtsave

  ...Set Method of Output

  ....Bot Message(.msg #Channel):hadd mIRCTwitter Method $network .msg $$?="Enter the Channel Name including the #prefix" | mtsave

  ....Message(msg #Channel):hadd mIRCTwitter Method $network msg $$?="Enter the Channel Name including the #prefix" | mtsave

  ....Echo(Echo -at):hadd mIRCTwitter Method echo -at | mtsave

  ....Window(Echo -t @Twitter):hadd mIRCTwitter Method echo -t @Twitter | mtsave

}

alias -l mIRCTwitter { 

  if ($hget(mIRCTwitter,Active)) { GetmIRCTwitter $v1 $gettok($decode($v1,m),1,58) }

  else {

    .timermIRCTwitter off

    echo -a Error!! No UserName:Password Data. Please return to the menu and setup the script properly

  }

}

alias -l GetmIRCTwitter {

  var %sockname $+(mIRCTwitter,$network,$2,$ticks)

  sockopen %sockname twitter.com 80

  sockmark %sockname $+(/statuses/home_timeline/,$2,.rss?since_id=,$iif($hget(mirctwitter,last_id),$hget(mirctwitter,last_id),1)) $1 0 1 0

}

On *:sockopen:mIRCTwitter*: {

  if (!$sockerr) {

    sockwrite -nt $sockname GET $gettok($sock($sockname).mark,1,32) HTTP/1.0

    sockwrite -n $sockname Host: twitter.com

    sockwrite -nt $sockname Authorization: Basic $gettok($sock($sockname).mark,2,32)

    sockwrite -n $sockname $str($crlf,2)

  }

  else { echo -st Socket Error $nopath($script) | sockclose $sockname | return }

}

On *:sockread:mIRCTwitter*: {

  if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }

  else {

    var %mIRCTwitter | sockread %mIRCTwitter

    if ( isin %mIRCTwitter) { sockmark $sockname $puttok($sock($sockname).mark,1,3,32) }

    elseif ($gettok($sock($sockname).mark,4,32)) && ($regex(%mIRCTwitter,//([^/]*)/)) {

      hadd mIRCTwitter Last_ID $regml(1)

      sockmark $sockname $puttok($sock($sockname).mark,0,4,32)      

    }

    elseif ($gettok($sock($sockname).mark,3,32)) && ($regex(%mIRCTwitter,(.*))) {

      sockmark $sockname $puttok($sock($sockname).mark,$calc($gettok($sock($sockname).mark,5,32) + 1),5,32)

      var %Method $hget(mIRCTwitter,Method)

      if (%Method == echo -at) { %Method $fix($+(0904) $gettok($regml(1),2-,58)) }

      elseif ($me ison $gettok(%Method,3,32)) {

        .timer 1 $gettok($sock($sockname).mark,5,32) $gettok(%Method,2-,32) $fix($+(0904) $gettok($regml(1),2-,58))

      }

      else {

        if (!$window(@Twitter)) { window -e @Twitter }

        echo -t @Twitter $fix($+(0904) $gettok($regml(1),2-,58))       

      }

    }

  }

}

alias -l urlencode return $regsubex($1-,/([^a-z0-9])/ig,$+(%,$base($asc(\t),10,16,2)))

alias -l TwitterAuthCheck {

  var %sockname $+(mTwitterAuthCheck,$network,$2,$ticks)

  sockopen %sockname twitter.com 80

  sockmark %sockname /account/verify_credentials.xml $encode($1,m)

}

On *:sockopen:mTwitterAuthCheck*: {

  if (!$sockerr) {

    sockwrite -nt $sockname GET $gettok($sock($sockname).mark,1,32) HTTP/1.0

    sockwrite -n $sockname Host: twitter.com

    sockwrite -n $sockname Authorization: Basic $gettok($sock($sockname).mark,2,32)

    sockwrite -n $sockname $crlf

  }

  else { echo -st Socket Error $nopath($script) | sockclose $sockname | return }

}

On *:sockread:mTwitterAuthCheck*: {

  if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }

  else {

    var %mTwitterAuthCheck | sockread %mTwitterAuthCheck

    if (HTTP/1.1 401 Unauthorized isin %mTwitterAuthCheck) { 

      echo -a Incorrect UserName:Password Combination!! Please Try Again with the Correct Information.

      sockclose $sockname

      return

    }

    elseif ($regex(%mTwitterAuthCheck,/(.*)/)) { 

      echo -a $regml(1) Your Account has been Verified and Your Information has been Stored in my Secure Encrypted Database.

      hadd -m mIRCTwitter Active $gettok($sock($sockname).mark,2,32)

      mtsave

      sockclose $sockname

    }

  }

}

alias -l mIRCTweet {

  if ($hget(mIRCTwitter,Active)) { mTwitterUpdate $v1 echo -a $1- }

}

;mTwitterUpdate mimeEncodedAuth method place UnEncodedUpdate

alias -l mTwitterUpdate {

  var %sockname $+(mTwitterUpdate,$network,$2,$ticks)

  sockopen %sockname twitter.com 80

  sockmark %sockname $2-3 /statuses/update.xml $1 $+(status=,$urlencode($left($4-,140)))

}

On *:sockopen:mTwitterUpdate*: {

  if (!$sockerr) {

    sockwrite -nt $sockname POST $gettok($sock($sockname).mark,3,32) HTTP/1.1

    sockwrite -n $sockname Host: twitter.com

    sockwrite -nt $sockname Authorization: Basic $gettok($sock($sockname).mark,4,32)

    sockwrite -n $sockname Content-Type: application/x-www-form-urlencoded

    sockwrite -n $sockname Content-Length: $len($gettok($sock($sockname).mark,5,32))

    sockwrite -n $sockname $crlf

    sockwrite -nt $sockname $gettok($sock($sockname).mark,5,32)

    sockwrite -n $sockname $crlf

  }

  else { echo -st Socket Error $nopath($script) | sockclose $sockname | return }

}

On *:sockread:mTwitterUpdate*: {

  if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }

  else {

    var %mTwitterUpdate | sockread %mTwitterUpdate

    if (HTTP/1.1 401 isin %mTwitterUpdate) { 

      $gettok($sock($sockname).mark,1-2,32) Username/Password Incorrect. Please message me to properly setup your account.

    }

    elseif (HTTP/1.1 502 isin %mTwitterUpdate) || (HTTP/1.1 503 isin %TwitterUpvar) {

      $gettok($sock($sockname).mark,1-2,32) Servers are Busy. Please try again Later.

    }

    elseif (HTTP/1.1 500 isin %mTwitterUpdate) { $gettok($sock($sockname).mark,1-2,32) Internal Server Error. }

    elseif (HTTP/1.1 403 isin %mTwitterUpdate) { $gettok($sock($sockname).mark,1-2,32) Connection was actively refused. }

    elseif (HTTP/1.1 400 isin %mTwitterUpdate) { $gettok($sock($sockname).mark,1-2,32) Unknown Error }

    elseif (HTTP/1.1 200 isin %mTwitterUpdate) { $gettok($sock($sockname).mark,1-2,32) Updating Status.. Please Wait... }

    elseif ( isin %mTwitterUpdate) { .timer 1 3 $gettok($sock($sockname).mark,1-2,32) Status Updated. }   

  }

}

On *:input:@Twitter: {

  if ($left($1,1) != /) {

    haltdef

    echo -t @Twitter $+(0709) $1-

    mIRCTweet $1-

  }

}

alias -l fix { return $replace($regsubex($1-,/\&\#([0-9]{1,});/g,$utf8(\t)),",",&,&,>,>,<,,$chr(9),$chr(32)) }

alias -l UTF8 {

  if ($1 = 256) && ($1 = 2048) && ($1 = 65536) && ($1 

Link to comment
Share on other sites



×
×
  • Create New...