tglogo.png

Downloading File

Filename: Twitter single token status update
;twitter_statuses_update by Ford_Lawnmower irc.GeekShed.net #Script-Help
;;;;;;;;;;;;;;;;;
;::Start Setup::;
;;;;;;;;;;;;;;;;;
;Edit the lines below to reflect your Twitter Application info.
alias -l consumer_key return PutYourConsumerKeyHere
alias -l consumer_secret return PutYourConsumerSecretHere
alias -l oauth_token return PutYourOauthTokenHere
alias -l oauth_token_secret return PutYourOauthTokenSecretHere
;;;;;;;;;;;;;;;
;::End Setup::;
;;;;;;;;;;;;;;;
;Syntax quick_update update text here *note* requires that you complete setup
alias quick_update twitter_statuses_update echo -a $consumer_key $consumer_secret $oauth_token $oauth_token_secret $1-
;Syntax twitter_statuses_update echo -a consumer_key consumer_secret oauth_token oauth_token_secret status update here
;Note that echo -a can be changed to msg $chan or notice $nick ( must be two words )
alias twitter_statuses_update {
  var %ots $gmt, %sockname $+(twitter_statuses_update,$network,$ticks,$r(1,10000)), %once $md5(%sockname)
  var %os $signature(post,http://twitter.com/statuses/update.xml,$3,$4,$5,$6,%once,%ots,$+(status=,$tuenc($7-)))
  sockopen %sockname twitter.com 80
  sockmark %sockname $1-2 $space2comma($+(oauth_nonce=,$qt(%once)) $osmqt $+(oauth_timestamp=,$qt(%ots)) $+(oauth_consumer_key=,$qt($tuenc($3))) $&
    $+(oauth_token=,$qt($tuenc($5))) $+(oauth_signature=,$qt($tuenc(%os))) $overqt) $+(status=,$tuenc($7-))
}
on *:sockopen:twitter_statuses_update*: {
  if ($sockerr) echo -st Socket Error $nopath($script)
  else {
    tokenize 32 $sock($sockname).mark
    sockwrite -n $sockname POST /statuses/update.xml HTTP/1.1
    sockwrite -n $sockname Host: twitter.com
    sockwrite -n $sockname User-Agent: Lawnmower 9.64
    sockwrite -n $sockname Authorization: OAuth realm="/statuses/update.xml", $3
    sockwrite -n $sockname Content-Type: application/x-www-form-urlencoded
    sockwrite -n $sockname Content-Length: $len($4)
    sockwrite -n $sockname
    sockwrite -n $sockname $4
    sockwrite -n $sockname
  }
}
on *:sockread:twitter_statuses_update*: {
  if ($sockerr) { $gettok($sock($sockname).mark,1-2,32) Unknown Socket error $nopath($script) }
  else {
    var %twitter_statuses_updatevar | sockread %twitter_statuses_updatevar
    if (HTTP/1.1 401 isin %twitter_statuses_updatevar) {
      $gettok($sock($sockname).mark,1-2,32) Password/Username Error --> %twitter_statuses_updatevar
      sockclose $sockname | return
    }
    elseif (HTTP/1.1 502 isin %twitter_statuses_updatevar) || (HTTP/1.1 503 isin %twitter_statuses_updatevar) {
      $gettok($sock($sockname).mark,1-2,32) Server Busy Error --> %twitter_statuses_updatevar
      sockclose $sockname | return
    }
    elseif (HTTP/1.1 500 isin %twitter_statuses_updatevar) {
      $gettok($sock($sockname).mark,1-2,32) Server Side Error --> %twitter_statuses_updatevar
      sockclose $sockname | return      
    }
    elseif (HTTP/1.1 403 isin %twitter_statuses_updatevar) {
      $gettok($sock($sockname).mark,1-2,32) Connection Actively Refused --> %twitter_statuses_updatevar
      sockclose $sockname | return      
    }
    elseif (HTTP/1.1 400 isin %twitter_statuses_updatevar) {
      $gettok($sock($sockname).mark,1-2,32) Unknown Error --> %twitter_statuses_updatevar
      sockclose $sockname | return
    }
    elseif (HTTP/1.1 200 isin %twitter_statuses_updatevar) {
      $gettok($sock($sockname).mark,1-2,32) Updating Status Please Wait.........
    }
    elseif (</status> isin %twitter_statuses_updatevar) {
      .timer 1 3 $gettok($sock($sockname).mark,1-2,32) Your Status has been updated :)
      sockclose $sockname | return
    }
  }
}
;Syntax $signature(POST/GET,URL,consumer_key,consumer_secret,oauth_token,oauth_token_secret,oauth_nonce,oauth_timestamp,PostData)
alias -l signature {
  var %method $+($upper($1),&), %url $+($tuenc($2),&), %ck $tuenc&($+(oauth_consumer_key=,$3)), %ot $tuenc&($+(oauth_token=,$5))
  var %once $tuenc&($+(oauth_nonce=,$7)), %ots $tuenc&($+(oauth_timestamp=,$8)), %post $iif($9-,$tuenc($+(&,$9-)))
  return $hmacsha1($+($4,&,$iif($6,$6)),$+(%method,%url,%ck,%once,$tuenc&($osm),%ots,%ot,$tuenc($over),%post))
}
alias -l osm return oauth_signature_method=HMAC-SHA1
alias -l osmqt return oauth_signature_method="HMAC-SHA1"
alias -l over return oauth_version=1.0
alias -l overqt return oauth_version="1.0"
alias -l tuenc return $regsubex($replace($1-,+,$chr(32)),/([^a-z0-9._-])/ig,% $+ $base($asc(\t),10,16,2))
alias -l space2comma return $replace($1-,$chr(32),$chr(44))
alias -l hmacsha1 {
  var %key $iif($len($1) <= 64,$1,$hex2chr($sha1($1))), %ipad $xorall($str(6,64),%key), %opad = $xorall(%opad $str(\,64),%key), %message $2
  $iif($isid,return,echo -a) $encode($hex2chr($sha1($+(%opad,$hex2chr($sha1($+(%ipad,%message)))))),m)
}
alias -l hex2chr { return $regsubex($1,/(.{2})/g,$chr($base(\t,16,10))) }
alias -l xorall {
  var %end $iif($len($1) > $len($2),$len($1),$len($2)), %p $1, %k $2
  return $regsubex($str(.,%end),/(.)/g,$chr($xor($iif($asc($mid(%p,\n,1)),$v1,0),$iif($asc($mid(%k,\n,1)),$v1,0))))
}
alias -l tuenc& return $tuenc($+($1,&))


Related Files


Please note that on our website we use cookies necessary for the functioning of our website, cookies that optimize the performance. To learn more about our cookies, how we use them and their benefits, please read our Cookie Policy.
I Understand