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,
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.*
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
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.
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.