mIRC Home    About    Download    Register    News    Help

Print Thread
Help with !uptime command. #253272 06/06/15 08:06 PM
Joined: Jun 2014
Posts: 77
K
Khonor Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Jun 2014
Posts: 77
I have this script and I was wondering if someone could help me, because from one moment to the other I leave to function the command and not know why.

Any help is appreciated!

Regards,
-Khonor



on *:TEXT:!uptime:#:{
set -u10 %target $iif($2,$2,$mid(#,2-))
set -u10 %channel #
uptime
}

alias uptime {
sockclose uptime
sockopen uptime nightdev.com 80
}

on *:sockopen:uptime:{
if ($sockerr) { sockclose $sockname | halt }
sockwrite -n $sockname GET /hosted/uptime.php?channel= $+ %target HTTP/1.1
sockwrite -n $sockname Host: www.nightdev.com
sockwrite -n $sockname $crlf
}

on *:sockread:uptime:{
if ($sockerr) { sockclose $sockname }
var %data
sockread %data
tokenize 32 %data
if ($1 isnum) && ($2) { msg %channel %target has been streaming for $1- $+ . Since $date(dd) $date(mmm) $date(yyyy) at $asctime(hh:nn:ss) $+ . }
elseif (%data == The channel is not live.) msg %channel %target is currently not online.
}

Re: Help with !uptime command. [Re: Khonor] #253273 06/06/15 08:17 PM
Joined: May 2015
Posts: 249
splinny Offline
Fjord artisan
Offline
Fjord artisan
Joined: May 2015
Posts: 249
Shows correct uptime for me.


Dont give a fish - teach to fish!
Re: Help with !uptime command. [Re: splinny] #253274 06/06/15 08:26 PM
Joined: May 2015
Posts: 249
splinny Offline
Fjord artisan
Offline
Fjord artisan
Joined: May 2015
Posts: 249
But your way of saving data (#channel and stream_channel) is not reliable. If two users type !uptime for different channels at the same time it will probably return uptime for one of two channels twice. To avoid this you need not to save it at temp_variables (with -u10) but send it to uptime alias as parameters like "uptime $chan $iif($2,$2,$mid($chan,2))" and in /uptime-alias use "/sockmark uptime $1-" to send it again to on-sockopen event so you can use "tokenize 32 $sock($sockname).mark" to use those params no-matter-how-much-times simultaneously (after tokenize it will be $1 for $channel and $2 for stream).


Dont give a fish - teach to fish!
Re: Help with !uptime command. [Re: splinny] #253275 06/06/15 08:47 PM
Joined: Dec 2008
Posts: 1,511
westor Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,511
Or you can use /sockmark command and $sock(SOCKNAME).mark after /sockopen command.

/help /sockmark

Re: Help with !uptime command. [Re: splinny] #253276 06/06/15 09:02 PM
Joined: Jun 2014
Posts: 77
K
Khonor Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Jun 2014
Posts: 77
Thanks I'll see how to do to fix it.

Re: Help with !uptime command. [Re: splinny] #253287 07/06/15 05:07 PM
Joined: Jun 2014
Posts: 77
K
Khonor Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Jun 2014
Posts: 77
You could help me fix it splinny? Because I did not find the way back.

Re: Help with !uptime command. [Re: Khonor] #253288 07/06/15 05:33 PM
Joined: May 2015
Posts: 249
splinny Offline
Fjord artisan
Offline
Fjord artisan
Joined: May 2015
Posts: 249
It was working as i said, but why do you need it for many channels? Do it just for one which bot is assigned to.


Dont give a fish - teach to fish!
Re: Help with !uptime command. [Re: splinny] #253290 07/06/15 06:22 PM
Joined: Jun 2014
Posts: 77
K
Khonor Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Jun 2014
Posts: 77
If to work on many channels.