SwiftIRC
http://forum.swiftirc.net/

Twitter status update script
http://forum.swiftirc.net/viewtopic.php?f=34&t=21826
Page 1 of 1

Author:  hixxy [ Sat Mar 21, 2009 10:30 pm ]
Post subject:  Twitter status update script

Copied directly from my post on the mIRC forums:

Code:
alias -l username return <your username>
alias -l password return <your password>

alias -l raiseerror {
  echo -a * /twitter: $1-
  halt
}
alias -l urlencode return $regsubex($1-,/([^a-z0-9])/ig,% $+ $base($asc(\t),10,16,2))

alias twitter {
  hfree -w twitter
  sockclose twitter
  sockopen twitter twitter.com 80
  sockmark twitter status= $+ $urlencode($1-)
}

on *:sockopen:twitter:{
  if ($sockerr) {
    sockclose twitter
    raiseerror socket error. Try again later.
  }
  var %s = sockwrite -n twitter
  %s POST /statuses/update.xml HTTP/1.1
  %s Host: twitter.com
  %s Authorization: Basic $encode($+($username,:,$password),m)
  %s Accept: */*, *.*
  %s Connection: close
  %s User-Agent: mIRC/ $+ $version
  %s Content-Type: application/x-www-form-urlencoded
  %s Content-Length: $len($sock(twitter).mark)
  %s
  %s $sock(twitter).mark
}
on *:sockread:twitter:{
  var %data
  sockread %data
  if ($regex(%data,/<error>(.+?)</error>/)) {
    hfree -w twitter
    sockclose twitter
    raiseerror $regml(1)
  }
  if ($regex(%data,/<(.+?)>(.+?)</\1>/)) hadd -m twitter $regml(1) $regml(2)
  elseif (%data == </status>) .signal twitterpost
}


Make sure you input your username and password at the top of the script. Once you've done this, simply type /twitter <status message> to set your message.

If you're not much of a scripter then just ignore this next bit..

I've made it so that the script fires off an event when the message has finished being posted. From this event you can access all kinds of information from the "twitter" hashtable, such as whether the message was truncated to 140 chars or not, etc.

Here is an example event to show you how to use it, and to show what kind of information the table holds:

Code:
on *:signal:twitterpost:{
  var %i = 1
  while ($hget(twitter,%i).item) {
    echo -a $v1 : $hget(twitter,%i).data
    inc %i
  }
  hfree twitter
}


For privacy reasons, you might wish to store an encoded copy of your password within the script.

To find out what your encoded password is, just type this in any window in mIRC:

Code:
//echo -a $encode(<your password>,m)


You should see something echoed into the active window. Now copy/paste that string, and use this as your password alias:

Code:
alias -l password return $decode(<string you just copied>,m)


Enjoy :D

Author:  internet [ Mon Mar 23, 2009 11:59 pm ]
Post subject:  Re: Twitter status update script

NICE NICE XD =P

Author:  Arconiaprime [ Wed Mar 25, 2009 9:15 am ]
Post subject:  Re: Twitter status update script

eh scripting isnt half bad, nice work

Author:  hixxy [ Wed Mar 25, 2009 1:31 pm ]
Post subject:  Re: Twitter status update script

internet wrote:
NICE NICE XD =P


Thanks :D

Arconiaprime wrote:
eh scripting isnt half bad, nice work


Cheers!

I've been scripting for about 6 years so I should hope I'm not terrible :P

Author:  xSlayer [ Wed Aug 19, 2009 2:10 pm ]
Post subject:  Re: Twitter status update script

I created a trigger for it using text, in case a user doesn't use their bot as their active name. For example, I run mIRC for scripts, but use chatzilla to chat, and trigger the scripts.

Code:
on 5:TEXT:-Status *:#: {
  hfree -w twitter
  sockclose twitter
  sockopen twitter twitter.com 80
  sockmark twitter status= $+ $urlencode( $2-)
}

The 5 is just a user level to prevent others from updating your status, so for any new users, when you open your script editor, go to "users" and type "5:<your name>"

Author:  Riffpilgrim [ Wed Aug 19, 2009 3:31 pm ]
Post subject:  Re: Twitter status update script

Looks good, nice work :)

Author:  Hypnotoad [ Wed Aug 19, 2009 4:34 pm ]
Post subject:  Re: Twitter status update script

xSlayer, you could have called the alias /twitter in the TEXT event (instead of recreating it).

Code:
on 5:TEXT:-Status *:#:{
  twitter $2-
}


Also, adding your nick to the User list doesn't allow you to use your (or my) script if you change your nick. It is more accurate to add your hostmask in the form of *!*user@*.host, which can be done by typing "//auser -a 5 $address(<your nick>,3)".

Author:  xSlayer [ Wed Aug 19, 2009 10:40 pm ]
Post subject:  Re: Twitter status update script

Oh, alright. Sorry, I really haven't been scripting long. =/
Thank you for clarifying, though.

Also, I was wondering if anyone could slap together one of these for FaceBook?

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/