SwiftIRC
IRC Discussion and Support
 
  Index  •  FAQ  •  Search  

It is currently Fri Sep 03, 2010 8:12 am




Post new topic Reply to topic  [ 8 posts ] 
 Twitter status update script 
Author Message
 Post subject: Twitter status update script
PostPosted: Sat Mar 21, 2009 10:30 pm 
User
User

Joined: Tue Jan 15, 2008 11:31 am
Posts: 133
Location: England
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


Offline
 Profile  
 
 Post subject: Re: Twitter status update script
PostPosted: Mon Mar 23, 2009 11:59 pm 
Newbie
Newbie

Joined: Sat Dec 20, 2008 6:31 pm
Posts: 13
NICE NICE XD =P


Offline
 Profile  
 
 Post subject: Re: Twitter status update script
PostPosted: Wed Mar 25, 2009 9:15 am 
Support Team
Support Team

Joined: Fri May 18, 2007 12:29 am
Posts: 1319
eh scripting isnt half bad, nice work

_________________
(Tim) Awong, the helpops are scaring me.


Offline
 Profile  
 
 Post subject: Re: Twitter status update script
PostPosted: Wed Mar 25, 2009 1:31 pm 
User
User

Joined: Tue Jan 15, 2008 11:31 am
Posts: 133
Location: England
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


Offline
 Profile  
 
 Post subject: Re: Twitter status update script
PostPosted: Wed Aug 19, 2009 2:10 pm 
Newbie
Newbie

Joined: Wed Aug 19, 2009 2:05 pm
Posts: 2
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>"


Offline
 Profile E-mail  
 
 Post subject: Re: Twitter status update script
PostPosted: Wed Aug 19, 2009 3:31 pm 
User avatar
User
User

Joined: Fri Aug 08, 2008 3:42 pm
Posts: 138
Location: Somebody find me!
Looks good, nice work :)


Offline
 Profile  
 
 Post subject: Re: Twitter status update script
PostPosted: Wed Aug 19, 2009 4:34 pm 
User
User

Joined: Tue Jul 28, 2009 5:01 am
Posts: 57
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)".


Offline
 Profile E-mail  
 
 Post subject: Re: Twitter status update script
PostPosted: Wed Aug 19, 2009 10:40 pm 
Newbie
Newbie

Joined: Wed Aug 19, 2009 2:05 pm
Posts: 2
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?


Offline
 Profile E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 


 Who is online 

Users browsing this forum: Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 
Index  |  FAQ  |  Search

phpBB skin developed by: John Olson
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group