Twitter Status Update + Direct Message

By FordLawnmower on Apr 01, 2009

Just a little script to update your Twitter Status. I just made an account for writing this script, but this seems like it could be useful for updating your status. You could definitely use the alias twitterup to make a script to update your status from a timer. Anyway, I've tested this over and over, the only flaw I found, is that the "Remember Me" function, doesn't work if you have $decode disabled in mirc options. Other than that, I can't find anything wrong with it.
The character counter gets lost for a second, if you try to paste more than 140 characters into the update box, but as soon as you click the edit screen again, it catches up.
Image
Just added a direct message system with tons of new routines. If you have the old one, unload it first. Direct message is on the menu.
Image

;Twitter Status update Script by Ford_Lawnmower
;Added DirectMessage 04/02/2009
;If you have the Original Twitter Update loaded - Unload it before using this.  Alot of the same variable names are used in this.
;While I have constantly tested this with each change in code, there could still be some bugs in it. Please let me know if you find any. I know it's a monstrosity,
;There is also some code here that is only currently being used for my testing with twitters api. Enjoy :) I think it works very well. My next update will be a
;fully functional Twitter Home script :) I have a few other twitter related projects going too. Too see, you can follow me -> http://twitter.com/FordLawnmower
;This script is pretty straight forward. The dialog works just like the one on the site. Just enter your username and password, type your status update in the box,
;and click update. Your password is encrypted by mirc with mime encryption, so if you want to use the "Remember Me" function, You can't have $decode locked out
;in your mirc options. To see if you have it locked, goto tools, options, other, lock. Look to the right and see if decode is checked. Uncheck it to use the 
;"Remember Me" function. Using encryption to store the password was the only option that made any sense to me. If someone has a suggestion I'm all ears :P
;Questions, Comments, You can find me on WyldRyde in #Script-Help, SwiftIRC #Technical,#AtomReactor, Abjects #Technical, #AtomReactor, #USA-Chat
;And MindForge #Technical,#AtomReactor,#Hollywood,#USA,#Emule-USA
menu * {
  Twitter
  .TwitterUpdate:TwitterUpdate
  .TwitterDirectMessage:TwitterDirectMessage
}
dialog TwitterUpdate {
  title "TwitterUpdate"
  size -1 -1 112 128
  option dbu
  edit "", 1, 40 8 66 10, autohs
  edit "", 2, 40 24 66 10, pass autohs
  edit "", 3, 8 56 98 34, multi return autovs limit 140
  text "User Name:", 4, 0 8 33 8, right
  text "Password", 5, 0 24 33 8, right
  text "", 6, 80 48 25 8, right
  button "Update", 7, 12 96 37 12
  button "Close", 8, 65 96 37 12, cancel
  check "Remember Me", 9, 56 34 50 10, left
  text "", 10, 0 112 113 16, center
  button "Clear", 11, 10 43 23 12  
}
On *:Dialog:TwitterUpdate:Sclick:11: {
  did -r TwitterUpdate 3
  did -a TwitterUpdate 6 140
  did -a TwitterUpdate 10
}
On *:Dialog:TwitterUpdate:Sclick:9: {
  if ($did(TwitterUpdate,9).state)  {
    did -a TwitterUpdate 10 You can only set Remember if decode is enabled. Tools,options,other,lock to enable.
    if ($did(TwitterUpdate,9).state) { .timer 1 3 did -a TwitterUpdate 10 If you have decode blocked in options uncheck the Remember box. }
    .timer 1 9 did -a TwitterUpdate 10
  }
}
On *:Dialog:TwitterUpdate:Sclick:7: {
  if ($did(TwitterUpdate,9).state) && ($did(TwitterUpdate,1).text) && ($did(TwitterUpdate,2).text)  {
    set %Global.TwitterUpdate.info $encode($+($did(TwitterUpdate,1).text,:,$did(TwitterUpdate,2).text),m)
  }
  if (!$did(TwitterUpdate,1).text) {
    did -f TwitterUpdate 1
    did -a TwitterUpdate 10 You must enter your Registered Twitter user name
    .timer 1 4 did -a TwitterUpdate 10
    return
  }
  if (!$did(TwitterUpdate,2).text) {
    did -f TwitterUpdate 2
    did -a TwitterUpdate 10 You must enter your Registered Twitter Password
    .timer 1 4 did -a TwitterUpdate 10
    return
  }
  if (!$did(TwitterUpdate,3).text) {
    did -f TwitterUpdate 3
    did -a TwitterUpdate 10 You must enter Some text for your update ;/
    .timer 1 4 did -a TwitterUpdate 10
    return
  }
  if ($did(TwitterUpdate,9).state) && ($did(TwitterUpdate,1).text) && ($did(TwitterUpdate,2).text)  {
    set %Global.TwitterUpdate.info $encode($+($did(TwitterUpdate,1).text,:,$did(TwitterUpdate,2).text),m)
  }
  if (!$did(TwitterUpdate,9).state) { unset %Global.TwitterUpdate.info }
  TwitterUp $+($did(TwitterUpdate,1).text,:,$did(TwitterUpdate,2).text) $+($did(TwitterUpdate,3,1).text,$&
    $did(TwitterUpdate,3,2).text,$did(TwitterUpdate,3,3).text,$did(TwitterUpdate,3,4))
}
On *:Dialog:TwitterUpdate:Edit:3: {
  set %TwitterUpdate.Words $calc($did(TwitterUpdate,3,1).len + $did(TwitterUpdate,3,2).len + $did(TwitterUpdate,3,3).len + $did(TwitterUpdate,3,4).len)
  did -a TwitterUpdate 6 $calc(140 - %TwitterUpdate.Words)
}
On *:Dialog:TwitterUpdate:init:*: {
  if (%Global.TwitterUpdate.info) { 
    did -a TwitterUpdate 1 $gettok($decode(%Global.TwitterUpdate.info,m),1,58)
    did -a TwitterUpdate 2 $gettok($decode(%Global.TwitterUpdate.info,m),2,58)
    did -c TwitterUpdate 9 
  }
  did -a TwitterUpdate 6 140   
}
alias TwitterDirectMessage {
  if (!$dialog(Twitter_DM)) { dialog -m Twitter_DM Twitter_DM }
  else { echo -a TwitterDirectMessage already opened }
}
alias TwitterUpdate {
  if (!$dialog(TwitterUpdate)) { dialog -m TwitterUpdate TwitterUpdate }
  else { echo -a TwitterUpdate is already opened }
}
alias -l TwitterUp.timeout {
  if ($dialog(TwitterUpdate)) {
    did -a TwitterUpdate 10 Unknown Error - Update Not complete
    .timer 1 4 did -a TwitterUpdate 10
  }
  else {
    echo -a Unknown Error - Update Not complete
  }     
  TwitterUp.clear
}
alias -l TwitterUp.clear {
  unset %TwitterUp*
  sockclose TwitterUp
  .timer-TwitterUp off
  halt
}
;Syntax $1=username:password $2-=Twitter Update message
alias TwitterUp {
  sockclose TwitterUp
  .set %TwitterUp.Info $encode($1,m)
  set %TwitterUp.Update $+(status=,$fixurl($2-))
  set %TwitterUpurl /statuses/update.xml
  set %TwitterUpsite twitter.com
  sockopen TwitterUp %TwitterUpsite 80
  .timer-TwitterUp 1 15 TwitterUp.timeout
}
on *:sockopen:TwitterUp: {
  sockwrite -n $sockname POST %TwitterUpurl HTTP/1.1
  sockwrite -n $sockname Host: %TwitterUpsite
  sockwrite -n $sockname User-Agent: Twitter-IRC
  sockwrite -n $sockname Authorization: Basic %TwitterUp.info
  sockwrite -n $sockname Content-Type: application/x-www-form-urlencoded
  sockwrite -n $sockname Content-Length: $len(%TwitterUp.Update)
  sockwrite -n $sockname
  sockwrite -n $sockname %TwitterUp.Update
  sockwrite -n $sockname 
}
on *:sockread:TwitterUp: {
  if ($sockerr > 0) { echo -a Unknown Socket error | TwitterUp.clear }
  else {
    var %TwitterUpvar | sockread %TwitterUpvar
    if (HTTP/1.1 401 isin %TwitterUpvar) {
      if ($dialog(TwitterUpdate)) {
        did -a TwitterUpdate 10 Password/Username Error --> %TwitterUpvar
        did -f TwitterUpdate 2
        .timer 1 6 did -a TwitterUpdate 10
      }
      else {
        echo -a Password/Username Error --> %TwitterUpvar
      }
      TwitterUp.Clear      
    }
    if (HTTP/1.1 502 isin %TwitterUpvar) || (HTTP/1.1 503 isin %TwitterUpvar) {
      if ($dialog(TwitterUpdate)) {
        did -a TwitterUpdate 10 Server Busy Error --> %TwitterUpvar
        .timer 1 6 did -a TwitterUpdate 10
      }
      else {
        echo -a Server Busy Error --> %TwitterUpvar
      }
      TwitterUp.Clear      
    }
    if (HTTP/1.1 500 isin %TwitterUpvar) {
      if ($dialog(TwitterUpdate)) {
        did -a TwitterUpdate 10 Server Side Error --> %TwitterUpvar
        .timer 1 6 did -a TwitterUpdate 10
      }
      else {
        echo -a Server Side Error --> %TwitterUpvar
      }
      TwitterUp.Clear      
    }
    if (HTTP/1.1 403 isin %TwitterUpvar) {
      if ($dialog(TwitterUpdate)) {
        did -a TwitterUpdate 10 Connection Actively Refused --> %TwitterUpvar
        .timer 1 6 did -a TwitterUpdate 10
      }
      else {
        echo -a Connection Actively Refused --> %TwitterUpvar
      }
      TwitterUp.Clear      
    }
    if (HTTP/1.1 400 isin %TwitterUpvar) {
      if ($dialog(TwitterUpdate)) {
        did -a TwitterUpdate 10 Unknown Error --> %TwitterUpvar
        .timer 1 6 did -a TwitterUpdate 10
      }
      else {
        echo -a Unknown Error --> %TwitterUpvar
      }
      TwitterUp.Clear
    }
    if (HTTP/1.1 200 isin %TwitterUpvar) {
      if ($dialog(TwitterUpdate)) {
        did -a TwitterUpdate 10 Updating Status Please Wait.........
      }
      else {
        echo -a Updating Status Please Wait.........
      }
    }
    if (</status> isin %TwitterUpvar) {
      if ($dialog(TwitterUpdate)) {
        .timer 1 3 did -a Twitterupdate 10 Your Status has been updated :)
      }
      else {
        .timer 1 3 echo -a Your Status has been updated :)
      }
      TwitterUp.Clear
    }
  }
}
;alias fixurl by GiGiGlum - Thanks GiGi :)
alias -l fixurl return $regsubex($1-,/([^a-z0-9])/ig,% $+ $base($asc(\t),10,16,2))
alias -l httpstrip {
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;)
  return %x
}
;Start of scripts for DirectMessage
;Start twitterfriends alias
alias -l TwitterFriends.timeout {
  did -a Twitter_DM 10 Unknown Error - Friends Update Not complete
  .timer 1 4 did -a Twitter_DM 10
  TwitterFriends.clear
}
alias -l TwitterFriends.clear {
  unset %TF*
  unset %TwitterFriends*
  sockclose TwitterFriends
  .timer-TwitterFriends off
  halt
}
;Syntax $1=username:password
alias TwitterFriends {
  if (!$hget(TwitterFriends)) { hmake -s TwitterFriends 10 }
  sockclose TwitterFriends
  .set %TwitterFriends.Info $encode($1,m)
  set %TwitterFriendsurl /statuses/friends.xml
  set %TwitterFriendssite twitter.com
  sockopen TwitterFriends %TwitterFriendssite 80
  .timer-TwitterFriends 1 25 TwitterFriends.timeout
}
on *:sockopen:TwitterFriends: {
  sockwrite -n $sockname GET %TwitterFriendsurl HTTP/1.0
  sockwrite -n $sockname Host: %TwitterFriendssite
  sockwrite -n $sockname User-Agent: Twitter-IRC
  sockwrite -n $sockname Authorization: Basic %TwitterFriends.info
  sockwrite -n $sockname Content-Type: application/x-www-form-urlencoded
  sockwrite -n $sockname 
}
on *:sockread:TwitterFriends: {
  if ($sockerr > 0) { echo -a Unknown Socket error | TwitterFriends.clear }
  else {
    var %TwitterFriendsvar | sockread %TwitterFriendsvar
    if (HTTP/1.1 401 isin %TwitterFriendsvar) {
      did -a Twitter_DM 10 Password/Username Error --> %TwitterFriendsvar
      ;need to add a call to login here
      did -f Twitter_DM 2
      .timer 1 6 did -a Twitter_DM 10
      TwitterFriends.Clear      
    }
    if (HTTP/1.1 502 isin %TwitterFriendsvar) || (HTTP/1.1 503 isin %TwitterFriendsvar) {
      did -a Twitter_DM 10 Server Busy Error --> %TwitterFriendsvar
      .timer 1 6 did -a Twitter_DM 10
      TwitterFriends.Clear      
    }
    if (HTTP/1.1 500 isin %TwitterFriendsvar) {
      did -a Twitter_DM 10 Server Side Error --> %TwitterFriendsvar
      .timer 1 6 did -a Twitter_DM 10
      TwitterFriends.Clear      
    }
    if (HTTP/1.1 403 isin %TwitterFriendsvar) {
      did -a Twitter_DM 10 Connection Actively Refused --> %TwitterFriendsvar
      .timer 1 6 did -a Twitter_DM 10
      TwitterFriends.Clear      
    }
    if (HTTP/1.1 400 isin %TwitterFriendsvar) {
      did -a Twitter_DM 10 Unknown Error --> %TwitterFriendsvar
      .timer 1 6 did -a Twitter_DM 10
      TwitterFriends.Clear
    }
    if (HTTP/1.1 200 isin %TwitterFriendsvar) {
      did -a Twitter_DM 10 Updating Status Please Wait.........
      hdel -w TwitterFriends *
    }
    if (<name> isin %TwitterFriendsvar) {
      if (%TF.name) { hadd  TwitterFriends %TF.name $+(<sn>,%TF.sname,</sn>,<i>,%TF.image,</i>,<t>,%TF.text,</t>,<u>,%TF.url,</u>,<d>,%TF.desc,</d>,<l>,%TF.loc,</l>) }
      set %TF.name $replace($remove(%TwitterFriendsvar,<name>,</name>),$chr(32),$chr(7))
    }
    if (<Screen_name> isin %TwitterFriendsvar) { set %TF.sname $remove(%TwitterFriendsvar,<screen_name>,</screen_name>) }
    if (<profile_image_url> isin %TwitterFriendsvar) { set %TF.image $remove(%TwitterFriendsvar,<profile_image_url>,</profile_image_url>) }
    if (<text> isin %TwitterFriendsvar) { set %TF.text $remove(%TwitterFriendsvar,<text>,</text>) }
    if (<url> isin %TwitterFriendsvar) { set %TF.url $remove(%TwitterFriendsvar,<url>,</url>) }
    if (<description> isin %TwitterFriendsvar) { set %TF.desc $remove(%TwitterFriendsvar,<description>,</description>) }
    if (<location> isin %TwitterFriendsvar) { set %TF.loc $remove(%TwitterFriendsvar,<location>,</location>) }
    if (</users> isin %TwitterFriendsvar) { 
      hadd  TwitterFriends %TF.name $+(<sn>,%TF.sname,</sn>,<i>,%TF.image,</i>,<t>,%TF.text,</t>,<u>,%TF.url,</u>,<d>,%TF.desc,</d>,<l>,%TF.loc,</l>)
      did -a Twitter_DM 10
      TwitterFriends.Clear 
    }
  }
}
alias listfriends {
  var %listcount = $hget(TwitterFriends,0).item
  while %listcount {
    echo -a %listcount $hget(TwitterFriends,%listcount).item $hget(TwitterFriends,%listcount).data
    dec %listcount
  }
}
alias -l TwitterDM.timeout {
  did -a Twitter_DM 10 Unknown Error - Update Not complete
  .timer 1 4 did -a Twitter_DM 10
  TwitterDM.clear
}
alias -l TwitterDM.clear {
  unset %TwitterDM*
  sockclose TwitterDM
  .timer-TwitterDM off
  halt
}
;Syntax $1=username:password $2=DirectName $3-=Twitter Update message
alias TwitterDM {
  sockclose TwitterDM
  set %TwitterDM.User $fixurl($2)
  .set %TwitterDM.Info $encode($1,m)
  set %TwitterDM.Update $+(text=,$fixurl($3-))
  set %TwitterDMurl /direct_messages/new.xml
  set %TwitterDMsite twitter.com
  sockopen TwitterDM %TwitterDMsite 80
  .timer-TwitterDM 1 15 TwitterDM.timeout
}
on *:sockopen:TwitterDM: {
  sockwrite -n $sockname POST %TwitterDMurl HTTP/1.1
  sockwrite -n $sockname Host: %TwitterDMsite
  sockwrite -n $sockname User-Agent: Twitter-IRC
  sockwrite -n $sockname Authorization: Basic %TwitterDM.info
  sockwrite -n $sockname Content-Type: application/x-www-form-urlencoded
  sockwrite -n $sockname Content-Length: $calc(6 + $len(%TwitterDM.User) + $len(%TwitterDM.Update))
  sockwrite -n $sockname
  sockwrite -n $sockname user= $+ %TwitterDM.User $+ & $+ %TwitterDM.Update
  sockwrite -n $sockname
}
on *:sockread:TwitterDM: {
  if ($sockerr > 0) { echo -a Unknown Socket error | TwitterDM.clear }
  else {
    var %TwitterDMvar | sockread %TwitterDMvar
    if (HTTP/1.1 401 isin %TwitterDMvar) {
      did -a Twitter_DM 10 Password/Username Error --> %TwitterDMvar
      did -f Twitter_DM 2
      .timer 1 6 did -a Twitter_DM 10
      TwitterDM.Clear      
    }
    if (HTTP/1.1 502 isin %TwitterDMvar) || (HTTP/1.1 503 isin %TwitterDMvar) {
      did -a Twitter_DM 10 Server Busy Error --> %TwitterDMvar
      .timer 1 6 did -a Twitter_DM 10
      TwitterDM.Clear      
    }
    if (HTTP/1.1 500 isin %TwitterDMvar) {
      did -a Twitter_DM 10 Server Side Error --> %TwitterDMvar
      .timer 1 6 did -a Twitter_DM 10
      TwitterDM.Clear      
    }
    if (HTTP/1.1 403 isin %TwitterDMvar) {
      did -a Twitter_DM 10 Connection Actively Refused --> %TwitterDMvar
      .timer 1 6 did -a Twitter_DM 10
      TwitterDM.Clear      
    }
    if (HTTP/1.1 400 isin %TwitterDMvar) {
      did -a Twitter_DM 10 Unknown Error --> %TwitterDMvar
      .timer 1 6 did -a Twitter_DM 10
      TwitterDM.Clear
    }
    if (HTTP/1.1 200 isin %TwitterDMvar) {
      did -a Twitter_DM 10 Sending Message Please Wait.........
    }
    if (</direct_message> isin %TwitterDMvar) {
      did -r Twitter_DM 2
      did -a Twitter_DM 11 140
      .timer 1 3 did -a Twitter_DM 10 Message Sent :)
      .timer 1 6 did -a Twitter_DM 10
      TwitterDM.Clear
    }
  }
}
;Start Twitter followers - Direct message Dialogs
dialog Twitter_Login {
  title "Twitter Login"
  size -1 -1 104 57
  option dbu
  edit "", 1, 32 8 66 10, autohs
  edit "", 2, 32 24 66 10, pass autohs
  check "Remember Me", 3, 48 34 50 10, left
  text "User Name", 4, 0 9 33 8, center
  text "Password", 5, 0 25 33 8, center
  button "Accept", 6, 6 45 29 12
  button "Cancel", 7, 70 45 29 12
}
dialog Twitter_DM {
  title "Twitter Direct Message"
  size -1 -1 146 200
  option dbu
  combo 1, 24 48 76 10, drop
  edit "", 2, 8 64 130 26, multi
  button "Send", 3, 106 92 29 12
  button "InBox", 4, 32 104 29 12
  button "Sent", 5, 72 104 29 12
  edit "" ,6, 8 120 130 58, multi read hsbar vsbar
  button "Close", 7, 32 178 77 12, cancel
  text "Send", 8, 0 49 21 8, right
  text "A Direct Message", 9, 100 49 47 8, center
  text "", 10, 0 192 145 8, center
  text "", 11, 9 90 25 8
  edit "", 12, 40 8 58 10, autohs
  edit "", 13, 40 24 58 10, pass autohs
  text "User Name", 14, 0 9 33 8, center
  text "Password", 15, 0 25 33 8, center
  check "Remember Me", 16, 48 34 50 10, left
  button "Login/Update", 17, 104 24 37 12
}
On *:Dialog:Twitter_DM:Sclick:17: {
  if ($did(Twitter_DM,12).text) && ($did(Twitter_DM,13).text) {
    Twitterfollowers $+($did(Twitter_DM,12).text,:,$did(Twitter_DM,13).text)
    .timer 1 3 TwitterDMR $+($did(Twitter_DM,12).text,:,$did(Twitter_DM,13).text)
    if ($did(Twitter_DM,16).state) { set %Global.TwitterUpdate.info $encode($+($did(Twitter_DM,12).text,:,$did(Twitter_DM,13).text),m) }
  }
  else {
    did -a Twitter_DM 10 User Name and Password Needed
    did -f Twitter_DM 12
    .timer 1 3 did -a Twitter_DM 10
  }
}
On *:Dialog:Twitter_DM:Sclick:16: {
  if ($did(Twitter_DM,16).state) {
    if ($did(Twitter_DM,12).text) && ($did(Twitter_DM,13).text) {
      set %Global.TwitterUpdate.info $encode($+($did(Twitter_DM,12).text,:,$did(Twitter_DM,13).text),m)
    }
  }
  else { unset %Global.TwitterUpdate.info }
}
On *:Dialog:Twitter_DM:Sclick:5: {
  if ($did(Twitter_DM,12).text) && ($did(Twitter_DM,13).text) {
    TwitterDMS $+($did(Twitter_DM,12).text,:,$did(Twitter_DM,13).text)
  }
  else {
    did -a Twitter_DM 10 User Name and Password Needed
    did -f Twitter_DM 12
    .timer 1 3 did -a Twitter_DM 10
  }
}
On *:Dialog:Twitter_DM:Sclick:4: {
  if ($did(Twitter_DM,12).text) && ($did(Twitter_DM,13).text) {
    TwitterDMR $+($did(Twitter_DM,12).text,:,$did(Twitter_DM,13).text)
  }
  else {
    did -a Twitter_DM 10 User Name and Password Needed
    did -f Twitter_DM 12
    .timer 1 3 did -a Twitter_DM 10
  }
}
On *:Dialog:Twitter_DM:Sclick:3: {
  if ($did(Twitter_DM,12).text) && ($did(Twitter_DM,13).text) {
    if (!$did(Twitter_DM,1).sel) {
      did -a Twitter_DM 10 Select a Follower from the list to send your message to.
      did -f Twitter_DM 1
      .timer 1 3 did -a Twitter_DM 10
      return
    }
    if (!$did(Twitter_DM,2).text) {
      did -a Twitter_DM 10 Type some text in the box to send to $did(Twitter_DM,1).seltext
      did -f Twitter_DM 2
      .timer 1 3 did -a Twitter_DM 10
      return
    }
    var %TwitterDM.Message = $left($+($did(Twitter_DM,2,1).text,$did(Twitter_DM,2,2).text,$did(Twitter_DM,2,3).text),140)
    TwitterDM $+($did(Twitter_DM,12).text,:,$did(Twitter_DM,13).text) $did(Twitter_DM,1).seltext %TwitterDM.Message
  }
  else {
    did -a Twitter_DM 10 User Name and Password Needed
    did -f Twitter_DM 12
    .timer 1 3 did -a Twitter_DM 10
  }
}
On *:Dialog:Twitter_DM:Edit:2: {
  set %TwitterFollowers.Words $calc($did(Twitter_DM,2,1).len + $did(Twitter_DM,2,2).len + $did(Twitter_DM,2,3).len + $did(Twitter_DM,2,4).len)
  did -a Twitter_DM 11 $calc(140 - %TwitterFollowers.Words)
}
On *:Dialog:Twitter_DM:init:*: {
  if (%Global.TwitterUpdate.info) { 
    did -a Twitter_DM 12 $gettok($decode(%Global.TwitterUpdate.info,m),1,58)
    did -a Twitter_DM 13 $gettok($decode(%Global.TwitterUpdate.info,m),2,58)
    did -c Twitter_DM 16
    TwitterFollowers $decode(%global.twitterupdate.info,m)
    .timer 1 3 TwitterDMR $decode(%global.twitterupdate.info,m)
  }
  else { did -f Twitter_DM 12 }
}
alias -l TwitterFollowers.timeout {
  did -a Twitter_DM 10 Unknown Error - Update Not complete
  .timer 1 4 did -a Twitter_DM 10
  TwitterFollowers.clear
}
alias -l TwitterFollowers.clear {
  unset %TL*
  unset %TwitterFollowers*
  sockclose TwitterFollowers
  .timer-TwitterFollowers off
  halt
}
;Syntax $1=username:password
alias TwitterFollowers {
  if (!$hget(TwitterFollowers)) { hmake -s TwitterFollowers 10 }
  sockclose TwitterFollowers
  .set %TwitterFollowers.Info $encode($1,m)
  set %TwitterFollowersurl /statuses/followers.xml
  set %TwitterFollowerssite twitter.com
  sockopen TwitterFollowers %TwitterFollowerssite 80
  .timer-TwitterFollowers 1 25 TwitterFollowers.timeout
}
on *:sockopen:TwitterFollowers: {
  sockwrite -n $sockname GET %TwitterFollowersurl HTTP/1.0
  sockwrite -n $sockname Host: %TwitterFollowerssite
  sockwrite -n $sockname User-Agent: Twitter-IRC
  sockwrite -n $sockname Authorization: Basic %TwitterFollowers.info
  sockwrite -n $sockname Content-Type: application/x-www-form-urlencoded
  sockwrite -n $sockname 
}
on *:sockread:TwitterFollowers: {
  if ($sockerr > 0) { echo -a Unknown Socket error | TwitterFollowers.clear }
  else {
    var %TwitterFollowersvar | sockread %TwitterFollowersvar
    if (HTTP/1.1 401 isin %TwitterFollowersvar) {
      did -a Twitter_DM 10 Password/Username Error --> %TwitterFollowersvar
      did -f Twitter_DM 2
      .timer 1 6 did -a Twitter_DM 10
      TwitterFollowers.Clear      
    }
    if (HTTP/1.1 502 isin %TwitterFollowersvar) || (HTTP/1.1 503 isin %TwitterFollowersvar) {
      did -a Twitter_DM 10 Server Busy Error --> %TwitterFollowersvar
      .timer 1 6 did -a Twitter_DM 10
      TwitterFollowers.Clear      
    }
    if (HTTP/1.1 500 isin %TwitterFollowersvar) {
      did -a Twitter_DM 10 Server Side Error --> %TwitterFollowersvar
      .timer 1 6 did -a Twitter_DM 10
      TwitterFollowers.Clear      
    }
    if (HTTP/1.1 403 isin %TwitterFollowersvar) {
      did -a Twitter_DM 10 Connection Actively Refused --> %TwitterFollowersvar
      .timer 1 6 did -a Twitter_DM 10
      TwitterFollowers.Clear      
    }
    if (HTTP/1.1 400 isin %TwitterFollowersvar) {
      did -a Twitter_DM 10 Unknown Error --> %TwitterFollowersvar
      .timer 1 6 did -a Twitter_DM 10
      TwitterFollowers.Clear
    }
    if (HTTP/1.1 200 isin %TwitterFollowersvar) {
      did -a Twitter_DM 10 Updating Status Please Wait.........
      hdel -w TwitterFollowers *
    }
    if (</user> isin %TwitterFollowersvar) { 
      hadd  TwitterFollowers %TL.sname $+(<n>,%TL.name,</n>,<i>,%TL.image,</i>,<t>,%TL.text,</t>,<u>,%TL.url,</u>,<d>,%TL.desc,</d>,<l>,%TL.loc,</l>) 
    }
    if (<name> isin %TwitterFollowersvar) { set %TL.name $nospace($remove(%TwitterFollowersvar,<name>,</name>)) }
    if (<Screen_name> isin %TwitterFollowersvar) { set %TL.sname $remove(%TwitterFollowersvar,<screen_name>,</screen_name>) }
    if (<profile_image_url> isin %TwitterFollowersvar) { set %TL.image $remove(%TwitterFollowersvar,<profile_image_url>,</profile_image_url>) }
    if (<text> isin %TwitterFollowersvar) { set %TL.text $remove(%TwitterFollowersvar,<text>,</text>) }
    if (<url> isin %TwitterFollowersvar) { set %TL.url $remove(%TwitterFollowersvar,<url>,</url>) }
    if (<description> isin %TwitterFollowersvar) { set %TL.desc $remove(%TwitterFollowersvar,<description>,</description>) }
    if (<location> isin %TwitterFollowersvar) { set %TL.loc $remove(%TwitterFollowersvar,<location>,</location>) }
    if (</users> isin %TwitterFollowersvar) { 
      hadd  TwitterFollowers %TL.sname $+(<n>,%TL.sname,</n>,<i>,%TL.image,</i>,<t>,%TL.text,</t>,<u>,%TL.url,</u>,<d>,%TL.desc,</d>,<l>,%TL.loc,</l>)
      var %FCount = $hget(TwitterFollowers,0).item
      did -r Twitter_DM 1
      while (%FCount) {
        did -a Twitter_DM 1 $hget(TwitterFollowers,%FCount).item
        dec %FCount
      }
      did -a Twitter_DM 10 End Update
      .timer 1 3 did -a Twitter_DM 10
      TwitterFollowers.Clear 
    }
  }
}
alias listfollowers {
  var %listcount = $hget(TwitterFollowers,0).item
  while %listcount {
    echo -a %listcount $hget(TwitterFollowers,%listcount).item $hget(TwitterFollowers,%listcount).data
    dec %listcount
  }
}
alias -l nospace {
  var %remspace = $1
  while ($left(%remspace,1) == $chr(32)) {
    %remspace = $right(%remspace,$calc($len(%remspace) - 1))
  }
  return %remspace
}
;start Direct Message Recieved
alias -l TwitterDMR.timeout {
  did -a Twitter_DM 10 Unknown Error - Update Not complete
  .timer 1 4 did -a Twitter_DM 10
  TwitterDMR.clear
}
alias -l TwitterDMR.clear {
  unset %TDMR*
  unset %TwitterDMR*
  sockclose TwitterDMR
  .timer-TwitterDMR off
  halt
}
;Syntax $1=username:password
alias TwitterDMR {
  if (!$hget(TwitterDMR)) { hmake -s TwitterDMR 10 }
  sockclose TwitterDMR
  .set %TwitterDMR.Info $encode($1,m)
  set %TwitterDMRurl /direct_messages.xml
  set %TwitterDMRsite twitter.com
  sockopen TwitterDMR %TwitterDMRsite 80
  .timer-TwitterDMR 1 25 TwitterDMR.timeout
}
on *:sockopen:TwitterDMR: {
  sockwrite -n $sockname GET %TwitterDMRurl HTTP/1.0
  sockwrite -n $sockname Host: %TwitterDMRsite
  sockwrite -n $sockname User-Agent: Twitter-IRC
  sockwrite -n $sockname Authorization: Basic %TwitterDMR.info
  sockwrite -n $sockname Content-Type: application/x-www-form-urlencoded
  sockwrite -n $sockname 
}
on *:sockread:TwitterDMR: {
  if ($sockerr > 0) { echo -a Unknown Socket error | TwitterDMR.clear }
  else {
    var %TwitterDMRvar | sockread %TwitterDMRvar
    if (HTTP/1.1 401 isin %TwitterDMRvar) {
      did -a Twitter_DM 10 Password/Username Error --> %TwitterDMRvar
      did -f Twitter_DM 2
      .timer 1 6 did -a Twitter_DM 10
      TwitterDMR.Clear      
    }
    if (HTTP/1.1 502 isin %TwitterDMRvar) || (HTTP/1.1 503 isin %TwitterDMRvar) {
      did -a Twitter_DM 10 Server Busy Error --> %TwitterDMRvar
      .timer 1 6 did -a Twitter_DM 10
      TwitterDMR.Clear      
    }
    if (HTTP/1.1 500 isin %TwitterDMRvar) {
      did -a Twitter_DM 10 Server Side Error --> %TwitterDMRvar
      .timer 1 6 did -a Twitter_DM 10
      TwitterDMR.Clear      
    }
    if (HTTP/1.1 403 isin %TwitterDMRvar) {
      did -a Twitter_DM 10 Connection Actively Refused --> %TwitterDMRvar
      .timer 1 6 did -a Twitter_DM 10
      TwitterDMR.Clear      
    }
    if (HTTP/1.1 400 isin %TwitterDMRvar) {
      did -a Twitter_DM 10 Unknown Error --> %TwitterDMRvar
      .timer 1 6 did -a Twitter_DM 10
      TwitterDMR.Clear
    }
    if (HTTP/1.1 200 isin %TwitterDMRvar) {
      did -a Twitter_DM 10 Updating Status Please Wait.........
      hdel -w TwitterDMR *
    }
    if (</direct_message isin %TwitterDMRvar) { 
      hadd  TwitterDMR %TDMR.id  $+(<ssn>,%TDMR.ssn,</ssn>,<t>,%TDMR.text,</t>)
    }
    if (<direct_message> isin %TwitterDMRvar) { set %TDMR.Start 1 }
    if (%TDMR.Start) {
      if (<id> isin %TwitterDMRvar) { set %TDMR.id $remove(%TwitterDMRvar,<id>,</id>) | set %TDMR.Start 0 }
    }
    if (<text> isin %TwitterDMRvar) { set %TDMR.text $remove(%TwitterDMRvar,<text>,</text>) }
    if (<sender_screen_name> isin %TwitterDMRvar) { set %TDMR.ssn $remove(%TwitterDMRvar,<sender_screen_name>,</sender_screen_name>) }
    if (</direct-messages> isin %TwitterDMRvar) { 
      var %FCount = $hget(TwitterDMR,0).item
      did -r Twitter_DM 6
      while (%FCount) {
        did -i Twitter_DM 6 1 $between($hget(TwitterDMR,%FCount).data,<ssn>,</ssn>,1) $between($hget(TwitterDMR,%FCount).data,<t>,</t>,1)
        dec %FCount
      }
      did -a Twitter_DM 10
      TwitterDMR.Clear 
    }
  }
}
alias listDMR {
  var %listcount = $hget(TwitterDMR,0).item
  while %listcount {
    echo -a %listcount $hget(TwitterDMR,%listcount).item $hget(TwitterDMR,%listcount).data
    dec %listcount
  }
}
;Start Direct Message Sent
alias -l TwitterDMS.timeout {
  did -a Twitter_DM 10 Unknown Error - Update Not complete
  .timer 1 4 did -a Twitter_DM 10
  TwitterDMS.clear
}
alias -l TwitterDMS.clear {
  unset %TDMS*
  unset %TwitterDMS*
  sockclose TwitterDMS
  .timer-TwitterDMS off
  halt
}
;Syntax $1=username:password
alias TwitterDMS {
  if (!$hget(TwitterDMS)) { hmake -s TwitterDMS 10 }
  sockclose TwitterDMS
  .set %TwitterDMS.Info $encode($1,m)
  set %TwitterDMSurl /direct_messages/sent.xml
  set %TwitterDMSsite twitter.com
  sockopen TwitterDMS %TwitterDMSsite 80
  .timer-TwitterDMS 1 25 TwitterDMS.timeout
}
on *:sockopen:TwitterDMS: {
  sockwrite -n $sockname GET %TwitterDMSurl HTTP/1.0
  sockwrite -n $sockname Host: %TwitterDMSsite
  sockwrite -n $sockname User-Agent: Twitter-IRC
  sockwrite -n $sockname Authorization: Basic %TwitterDMS.info
  sockwrite -n $sockname Content-Type: application/x-www-form-urlencoded
  sockwrite -n $sockname 
}
on *:sockread:TwitterDMS: {
  if ($sockerr > 0) { echo -a Unknown Socket error | TwitterDMS.clear }
  else {
    var %TwitterDMSvar | sockread %TwitterDMSvar
    if (HTTP/1.1 401 isin %TwitterDMSvar) {
      did -a Twitter_DM 10 Password/Username Error --> %TwitterDMSvar
      did -f Twitter_DM 2
      .timer 1 6 did -a Twitter_DM 10
      TwitterDMS.Clear      
    }
    if (HTTP/1.1 502 isin %TwitterDMSvar) || (HTTP/1.1 503 isin %TwitterDMSvar) {
      did -a Twitter_DM 10 Server Busy Error --> %TwitterDMSvar
      .timer 1 6 did -a Twitter_DM 10
      TwitterDMS.Clear      
    }
    if (HTTP/1.1 500 isin %TwitterDMSvar) {
      did -a Twitter_DM 10 Server Side Error --> %TwitterDMSvar
      .timer 1 6 did -a Twitter_DM 10
      TwitterDMS.Clear      
    }
    if (HTTP/1.1 403 isin %TwitterDMSvar) {
      did -a Twitter_DM 10 Connection Actively Refused --> %TwitterDMSvar
      .timer 1 6 did -a Twitter_DM 10
      TwitterDMS.Clear      
    }
    if (HTTP/1.1 400 isin %TwitterDMSvar) {
      did -a Twitter_DM 10 Unknown Error --> %TwitterDMSvar
      .timer 1 6 did -a Twitter_DM 10
      TwitterDMS.Clear
    }
    if (HTTP/1.1 200 isin %TwitterDMSvar) {
      did -a Twitter_DM 10 Updating Status Please Wait.........
      hdel -w TwitterDMS *
    }
    if (</direct_message isin %TwitterDMSvar) { 
      hadd  TwitterDMS %TDMS.id  $+(<rsn>,%TDMS.rsn,</rsn>,<t>,%TDMS.text,</t>)
    }
    if (<direct_message> isin %TwitterDMSvar) { set %TDMS.Start 1 }
    if (%TDMS.Start) {
      if (<id> isin %TwitterDMSvar) { set %TDMS.id $remove(%TwitterDMSvar,<id>,</id>) | set %TDMS.Start 0 }
    }
    if (<text> isin %TwitterDMSvar) { set %TDMS.text $remove(%TwitterDMSvar,<text>,</text>) }
    if (<recipient_screen_name> isin %TwitterDMSvar) { set %TDMS.rsn $remove(%TwitterDMSvar,<recipient_screen_name>,</recipient_screen_name>) }
    if (</direct-messages> isin %TwitterDMSvar) { 
      var %FCount = $hget(TwitterDMS,0).item
      did -r Twitter_DM 6
      while (%FCount) {
        did -i Twitter_DM 6 1 $between($hget(TwitterDMS,%FCount).data,<rsn>,</rsn>,1) $between($hget(TwitterDMS,%FCount).data,<t>,</t>,1)
        dec %FCount
      }
      did -a Twitter_DM 10
      TwitterDMS.Clear 
    }
  }
}
On *:Exit: {
  hfree TwitterDMR | hfree TwitterDMS | hfree TwitterFriends | hfree TwitterFollowers
}
alias listDMS {
  var %listcount = $hget(TwitterDMS,0).item
  while %listcount {
    echo -a %listcount $hget(TwitterDMS,%listcount).item $hget(TwitterDMS,%listcount).data
    dec %listcount
  }
}
;alias by Gummo
alias -l between { 
  noop $regex($1,/\Q $+ $2 $+ \E(.*?)\Q $+ $3 $+ \E/gi) 
  return $regml($4) 
}

Comments

Sign in to comment.
Callumlord   -  Mar 12, 2011

Ah ok thanks :)

 Respond  
FordLawnmower   -  Mar 12, 2011

This script currently does not work Callumlord.
Only this one is currently working -->> http://www.hawkee.com/snippet/7945/

 Respond  
Callumlord   -  Mar 12, 2011

It says to me, 'Password/username error --> HTTP:1.1 404 unauthorised'

 Respond  
FordLawnmower   -  Sep 05, 2010

Yes Grimnir. I'm currently working on HMAC-SHA1 routines and waiting on XAuth approvial from twitter.

 Respond  
Grimnir   -  Sep 05, 2010

with twitter switching to OAuth this script no longer works. I'm just wondering if it is going to be updated.
Thanks

 Respond  
Amiga600   -  Aug 21, 2010

Ahh Cool, Thanks dude!

 Respond  
FordLawnmower   -  Aug 21, 2010

That would be a different scrip Amiga600. This is for your personal client.
Bot script is here -->> http://www.hawkee.com/snippet/6942/

 Respond  
Amiga600   -  Aug 21, 2010

what this script is missing, is an ability to have other users use it, once they register with the script..

for example:

/msg Bot !twreg twittername twitterpass You are now registered under your Nickname "Me" to perform twitter updates type !tweet [whatever] on a channel. !tweet last night I met fred.. blah -Bot- Posted your Update to Twitter under Twittername "twittername"
 Respond  
findfriend   -  Apr 30, 2010

I want to create by using socket for comment in guestbook, but I don't know that,
how can i create the first code by using socket. How to do this?

sane as this link:
http://www.hack0wn.com/view.php?xroot=81.0&cat=sources

I hope someone else can be ans about my sillyfools ;-). Thanks.

 Respond  
findfriend   -  Apr 30, 2010

Hey! I founded This script on mircscripts.org. I tried to post the message in Thai lanng but it not support. How can I do it post on Thai langusge?

Sorry do bad for my English. Thanks any user for your answer. :)

 Respond  
Hawkee   -  Apr 23, 2010

fashionsblogs, this is for mIRC which is a chat program, not the web.

 Respond  
fashionsblogs   -  Apr 23, 2010

Well, I am no coder, but this looks super cool. How would I incorporate this into a site design. Bundle it into some kind of javascript and then call the action? Im sorry for my novice question, but would really like to try this.

 Respond  
Atr   -  Jul 28, 2009

Just loaded the code there into my remotes and got

* /dialog: 'TwitterUpdate' invalid table, in 'text' 10 (line 92, Twitter-IRC.ini)

when I tried to click on 'Twitter Update'

No idea why..

P.S: I look forward to the new dialog design ;)

 Respond  
FordLawnmower   -  Jul 27, 2009

Thanks Ayon :)
Thanks ScriptN00b :)
I got a little busy/distracted for a bit there. I need to expand on this script.
I've written routines for every feature of twitter. I just need to sit down and figure out how to implement them here.
The best thing I think I have is a alias that will delete all your direct messages. I hate those damn things.
I'll add this to my to do list :P

 Respond  
ScriptN00b   -  Jul 27, 2009

This is a kick ass snippet! Simple to use as 1.2.3 ...and appears to be bug free!

Thanks!!!!!!!!

 Respond  
Ayon   -  May 25, 2009

Nice script... Easy to use, and straight forward.

and also, I got to agree with ^Neptune..

 Respond  
^Neptune   -  May 25, 2009

FordLawnmower I would recommend using MDX over DCX unless you are planning on using obscure controls like ColorCombo and UpDown. DCX is actually alot more buggier than its older cousin, as it loads itself inside mIRC and often crashes it if a person is using another DCX enabled script.

 Respond  
PATX   -  May 25, 2009

@FordLawnmower i am having the same problem with oauth! i am actuly just using the giving example of the python google app engine, i have that running and yet there r still problems!

 Respond  
Jonesy44   -  May 25, 2009

wicked :) i look forward to seeing it ;D

 Respond  
FordLawnmower   -  May 24, 2009

I'm going to add that sloth. It's not very hard to do. I've been trying to figure out how to get twitters new Oauth to work from mirc. They are going to discontinue the use of BASIC Auth ;/
If I get a few free hours I will add a user timeline window. Just check this post from time to time.
@Jonesy44 I know. After I get a few things sorted I'm going to DCX the dialogs..

 Respond  
sloth   -  May 24, 2009

Great code. Tweets from IRC and manage multiple accounts. I just wish there was a dialogue where I could read the tweets of everyone I was following. Oh well, I'll have to keep using Firefox for that.
Thanks, keep up the good work.

 Respond  
Jonesy44   -  May 24, 2009

Not a big fan of twitter :/ but hey, this addon seems pretty cool. the script itself is good, but the dialog is f'ugly man!

 Respond  
FordLawnmower   -  May 23, 2009

That looks pretty cool PATX :)

 Respond  
PATX   -  May 23, 2009

ok, da more i use twitter the more i am liking this. ty for that user agent link... going to be using that for http://h-twt.googlecode.com/ << my python twitter client :p

 Respond  
FordLawnmower   -  May 04, 2009

Thanks PATX. I actually use this script quite a bit. As twitter has become more and more popular, they've gotten backed up from time to time, but the API seems to always work :)

 Respond  
PATX   -  May 04, 2009

omg. i am gunna make a site that i can link to every time i see one of FordLawnmower's useful scripts.... (me getting tired of writing complements to the guy). but once again i love it because why? it is useful. keep up the good work FordLawnmower!!!!!

 Respond  
Jonesy44   -  Apr 17, 2009

Don't get me started on this shiite..

 Respond  
MaxEvans   -  Apr 17, 2009

It's not only popular, but Twitter is now a part of the Federal Emergency Response Network.

 Respond  
Firstmate   -  Apr 16, 2009

It seems like it's more for people who can do this at many times during the day >.>

The concept is good, and obviously it's popular, but eh.

 Respond  
MaxEvans   -  Apr 16, 2009

Twitter is pretty much anything. From personal to business. It's used by marketers, bloggers, developers, videographers, photographers, etc. There's no wrong or right way to use Twitter. It's just Twitter. Twitter means "brief rapid updates" pretty much, so that's all it is, really.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.