[mIRC] Twitter Followers Tracker

By Jonesy44 on May 30, 2010

Screenshots

I was curious how quickly people "followed" peoples pages, the popular ones that is.. seems a lot.. well that was pointless. So here you are.

Syntax: /TrackFollowers

To get the icon,

  1. Download it first from Twitter at http://a1.twimg.com/a/1274899949/images/favicon.ico
  2. Remove the ";" from ";icon favicon.ico"
  3. Run app
alias TrackFollowers {
  set %Twitter.Track $1
  dialog $iif($dialog(TrackFollowers),-v,-m) TrackFollowers TrackFollowers
  sockopen $+(TrackFollowers.,$ticks) twitter.com 80
}
on *:Sockopen:TrackFollowers.*: {
  sockwrite -nt $sockname GET $+(/,%Twitter.Track) HTTP/1.1
  sockwrite -nt $sockname Host: twitter.com
  sockwrite -nt $sockname $crlf
}
on *:Sockread:TrackFollowers.*: {
  var %x | sockread %x
  if $regex(%x,<span id="follower_count" class="stats_count numeric">(.*) </span>) {
    var %c = $calc($remove($regml(1),$chr(44)) - $remove($did(TrackFollowers,202),$chr(44)))
    did -ra TrackFollowers 302 $iif($did(TrackFollowers,202),$iif(%c > 0,%c ( $+ $calc($ctime - %Twitter.Last) secs),$did(TrackFollowers,302)),n/a)
    did -ra TrackFollowers 202 $regml(1)
    did -ra TrackFollowers 400 Updated: $fulldate
    set %Twitter.Last $ctime
    sockopen $+(TrackFollowers.,$ticks) twitter.com 80
    .sockclose $sockname
  }
}
dialog TrackFollowers {
  size -1 -1 250 130
  option pixel
  icon favicon.ico
  title "Track Twitter Followers"
  text "Name", 101, 10 13 100 14
  edit %Twitter.Track, 102, 120 10 120 20, read
  text "Followers", 201, 10 38 100 14
  edit "", 202, 120 35 120 20, read
  text "Change", 301, 10 63 100 14
  edit "", 302, 120 60 120 20, read
  edit "", 400, 10 90 230 20, read center
}
on *:Dialog:TrackFollowers:close:*:.sockclose TrackFollowers.*

Comments

Sign in to comment.
Jonesy44   -  Jun 03, 2010

I'm with you! hehe, very true. I always avoided using sockmarks because they always seemed to be extra work when you can just declare a little variable. I think that's since i removed the timer, it's fixed now.

 Respond  
Jethro   -  Jun 03, 2010

Jonesy, your script's got a persistent error upon closing the dialog: > * Invalid parameters: $did (line 19, testing.mrc)Perhaps you should make a check to see if it's closed or not?

Sorry, i meant like, how the sockmark overcomes the issue of looping? :\
Ok, I think I missed your point... But still, I believe you don't need the updatefollowers alias and just use:

alias TrackFollowers {
  set -e %Twitter.Track $$1
  dialog $iif($dialog(TrackFollowers),-v,-m) trackfollowers trackfollowers
  sockopen $+(TrackFollowers.,$ticks) twitter.com 80
}
on *:Sockopen:TrackFollowers.*: {
  sockwrite -nt $sockname GET $+(/,%Twitter.Track) HTTP/1.1
  sockwrite -nt $sockname Host: twitter.com
  sockwrite -nt $sockname $crlf
}
on *:Sockread:TrackFollowers.*: {
  var %x | sockread %x
  if $regex(%x,<span id="follower_count" class="stats_count numeric">(.*) </span>) {
    var %c = $calc($remove($regml(1),$chr(44)) - $remove($did(TrackFollowers,202),$chr(44)))
    did -ra TrackFollowers 302 $iif($did(TrackFollowers,202),$iif(%c > 0,%c ( $+ $calc($ctime - %Twitter.Last) secs),$did(TrackFollowers,302)),n/a)
    did -ra TrackFollowers 202 $regml(1)
    did -ra TrackFollowers 400 Updated: $fulldate
    set -e %Twitter.Last $ctime
    sockopen $+(TrackFollowers.,$ticks) twitter.com 80
    .sockclose $sockname
  }
}

Which saves you 3 bytes. :p

 Respond  
Jonesy44   -  Jun 02, 2010

Sorry, i meant like, how the sockmark overcomes the issue of looping? :\

 Respond  
Jethro   -  Jun 02, 2010

jonesy44 Wrote:
Although, I'm not quite sure what you mean by the sockmarks.The /sockmark command basically acts like a temporary storage (it holds up to 512 bytes) for you to input data, and you can then use $sock($sockname).mark for reference later during the socket operation. It's quite nifty really, and it doesn't act like a global variable where you have to unset it. It clears itself when it finishes its task.

 Respond  
Jonesy44   -  Jun 02, 2010

I've added the -e flag to the global, good shout. Although, I'm not quite sure what you mean by the sockmarks. the update alias is to keep a loop after the end of each socket connection :/

 Respond  
Jonesy44   -  Jun 01, 2010

Ahh i was using a timer to update each second instead of re-updating once one run is complete. I'll remove it now. Thanks :D

 Respond  
Jethro   -  Jun 01, 2010

Nice work, Jonsey44!

But I think you could improve it a bit:

I believe you could get rid of the updatefollowers alias and do:

alias trackfollowers {
  dialog $iif($dialog(TrackFollowers),-v,-m) TrackFollowers TrackFollowers
  sockopen $+(TrackFollowers.,$ticks) twitter.com 80
  sockmark UpdateFollowers $iif($$1 isnum,$v1)
}

You can use /sockmark command to set for $1, and you may need to make sure it's a number, not something else. The $$ ensures that $1 is supplied.
Then in this bit, you do:

sockwrite -nt $sockname GET $+(/,$sock(trackfollowers).mark) HTTP/1.1

And lastly, you may need to add a -e switch so that the variable gets unset when mirc closes or exists:

set -e %Twitter.Last $ctime

I mean, it's a good practice to always keep the variables clean.

P.S. I don't understand why > .timerTrack off Either I missed or didn't see the timer.

 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.