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
