mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
!afk user script #168171 04/01/07 09:07 PM
Joined: Apr 2005
Posts: 72
B
bodo0815 Offline OP
Babel fish
OP Offline
Babel fish
B
Joined: Apr 2005
Posts: 72
hello...
im searching an away-script that can use all members in a channel
its look like:

user1: !afk eat
bot: user1 is away @20:00:01
user2: user1?
bot: user1 is away (eat) since 20:00:01
.
.
user1: !back
bot: user1 is back from eat

any1 know a script or can help me?

bodo

Re: !afk user script [Re: bodo0815] #168175 04/01/07 10:18 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
Here is a very easy one. I didn't make it so it saves away messages if you (the bot) closes mIRC. I didn't think it made sense to have it do that because the people could return by the time the bot is started again. If you decide you want it saved, let me know.

Code:
on *:start: {
  hmake AwayTable 50
}

on *:text:!afk*:#yourchannel: {
  var %time = $ctime
  if (!$hget(AwayTable)) { hmake AwayTable 50 }
  hadd AwayTable $nick $iif($2,$2-,Unknown) %time
  msg $chan $nick is away @ $+ $time(%time)
}

on *:text:!back:#yourchannel: {
  if ($hget(AwayTable,$nick)) {
    msg $chan $nick is back from $gettok($v1,1- $calc($gettok($v1,0,32) - 1) $+ .  $nick was gone for $duration($calc($ctime - $gettok($v1,$gettok($v1,0,32),32))) $+ .
    hdel AwayTable $nick
  }
  else msg $chan You're not away.
}

on *:text:*:#yourchannel: {
  if ($right($1-,1) == ? && $hget(AwayTable,$left($1,-1)) && !$2) {
    var %data = $hget(AwayTable,$left($1,-1))
    msg $chan $left($1,-1) is away $chr(40) $+ $gettok(%data,1- $calc($gettok(%data,0,32) -1),32) $+ $chr(41) since $time($gettok(%data,$gettok(%data,0,32),32)) $+ .
  }
}

on *:part:#yourchannel: {
  if ($hget(AwayTable,$nick)) {
    hdel AwayTable $nick
  }
}

on *:quit: {
  if ($hget(AwayTable,$nick)) {
    hdel AwayTable $nick
  }
}


Use:

<nick> !afk reason
<bot> nick is away @time.

<user2> nick?
<bot> nick is away (reason) since time.

<nick> !back
<bot> nick is back from reason. nick was gone for 1min 5secs.

You need the ? after the nick and nothing else for the bot to respond with the away info for that user.

Change the #yourchannel to the channel name that you want to use this on. If you want it for more channels, you can, but it's really designed for one and going away in one will make you away in all and so on.


Invision Support
#Invision on irc.irchighway.net
Re: !afk user script [Re: Riamus2] #168225 05/01/07 02:57 PM
Joined: Apr 2005
Posts: 72
B
bodo0815 Offline OP
Babel fish
OP Offline
Babel fish
B
Joined: Apr 2005
Posts: 72
hello and thx :-)
!back dont work :-(
"* Invalid format: $gettok (line 14, afk.mrc)"

is it possible users use only the nick without "?" if they call an away-user? sry my fault.

ty bodo

Re: !afk user script [Re: bodo0815] #168227 05/01/07 03:57 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
Sorry, missed a ). I changed it to work without the ?. I did that because that's how your example was.

Code:
on *:start: {
  hmake AwayTable 50
}

on *:text:!afk*:#yourchannel: {
  var %time = $ctime
  if (!$hget(AwayTable)) { hmake AwayTable 50 }
  hadd AwayTable $nick $iif($2,$2-,Unknown) %time
  msg $chan $nick is away @ $+ $time(%time)
}

on *:text:!back:#yourchannel: {
  if ($hget(AwayTable,$nick)) {
    msg $chan $nick is back from $gettok($v1,1- $calc($gettok($v1,0,32) - 1)) $+ .  $nick was gone for $duration($calc($ctime - $gettok($v1,$gettok($v1,0,32),32))) $+ .
    hdel AwayTable $nick
  }
  else msg $chan You're not away.
}

on *:text:*:#yourchannel: {
  if ($hget(AwayTable,$remove($strip($1),?)) && !$2) {
    var %data = $hget(AwayTable,$remove($strip($1),?))
    msg $chan $left($1,-1) is away $chr(40) $+ $gettok(%data,1- $calc($gettok(%data,0,32) -1),32) $+ $chr(41) since $time($gettok(%data,$gettok(%data,0,32),32)) $+ .
  }
}

on *:part:#yourchannel: {
  if ($hget(AwayTable,$nick)) {
    hdel AwayTable $nick
  }
}

on *:quit: {
  if ($hget(AwayTable,$nick)) {
    hdel AwayTable $nick
  }
}


It now triggers the away message for:

nick
nick?

and also works if colors are used. It only displays if only the nick is on the line.


Invision Support
#Invision on irc.irchighway.net
Re: !afk user script [Re: Riamus2] #168229 05/01/07 04:35 PM
Joined: Apr 2005
Posts: 72
B
bodo0815 Offline OP
Babel fish
OP Offline
Babel fish
B
Joined: Apr 2005
Posts: 72
okay... ty all works fine but:
!back
"* Too few parameters: $gettok (line 14, afk.mrc)"

bodo

Re: !afk user script [Re: bodo0815] #168237 05/01/07 07:25 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
I wish I could test it... these are stupid mistakes.

Change line 14 to:
Code:
msg $chan $nick is back from $gettok($v1,1- $calc($gettok($v1,0,32) - 1),32) $+ .  $nick was gone for $duration($calc($ctime - $gettok($v1,$gettok($v1,0,32),32))) $+ .



Invision Support
#Invision on irc.irchighway.net
Re: !afk user script [Re: Riamus2] #168250 05/01/07 11:08 PM
Joined: Apr 2005
Posts: 72
B
bodo0815 Offline OP
Babel fish
OP Offline
Babel fish
B
Joined: Apr 2005
Posts: 72
now it works fine :-) thx

can u add a !away trigger thats show all away-user in a channel?
like:

user1: !away
bot: user2 is away (test) @02:04:00
bot: user3 is away (test) @02:05:00
bot: user4 is away (test) @02:06:00

bodo

Last edited by bodo0815; 05/01/07 11:32 PM.
Re: !afk user script [Re: bodo0815] #168260 06/01/07 01:36 AM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
Code:
on *:start: {
  hmake AwayTable 50
}

on *:text:!afk*:#yourchannel: {
  var %time = $ctime
  if (!$hget(AwayTable)) { hmake AwayTable 50 }
  hadd AwayTable $nick $iif($2,$2-,Unknown) %time
  msg $chan $nick is away @ $+ $time(%time)
}

on *:text:!back:#yourchannel: {
  if ($hget(AwayTable,$nick)) {
    msg $chan $nick is back from $gettok($v1,1- $calc($gettok($v1,0,32) - 1),32) $+ .  $nick was gone for $duration($calc($ctime - $gettok($v1,$gettok($v1,0,32),32))) $+ .
    hdel AwayTable $nick
  }
  else msg $chan You're not away.
}

on *:text:!away:#yourchannel: {
  var %cnt = 1
  var %total = $hget(AwayTable,0).item
  while (%cnt <= %total) {
    var %name = $hget(AwayTable,%cnt).item
    var %data = $hget(AwayTable,%cnt).data
    write afk.tmp %name is away $chr(40) $+ $gettok(%data,1- $calc($gettok(%data,0,32) -1),32) $+ $chr(41) since $time($gettok(%data,$gettok(%data,0,32),32)) $+ .
    inc %cnt
  }
  .play $chan afk.tmp 1500
  .remove afk.tmp
}

on *:text:*:#yourchannel: {
  if ($hget(AwayTable,$remove($strip($1),?)) && !$2) {
    var %data = $hget(AwayTable,$remove($strip($1),?))
    msg $chan $left($1,-1) is away $chr(40) $+ $gettok(%data,1- $calc($gettok(%data,0,32) -1),32) $+ $chr(41) since $time($gettok(%data,$gettok(%data,0,32),32)) $+ .
  }
}

on *:part:#yourchannel: {
  if ($hget(AwayTable,$nick)) {
    hdel AwayTable $nick
  }
}

on *:quit: {
  if ($hget(AwayTable,$nick)) {
    hdel AwayTable $nick
  }
}


Invision Support
#Invision on irc.irchighway.net
Re: !afk user script [Re: Riamus2] #168283 06/01/07 10:47 AM
Joined: Apr 2005
Posts: 72
B
bodo0815 Offline OP
Babel fish
OP Offline
Babel fish
B
Joined: Apr 2005
Posts: 72
great :-) thx

bodo

Re: !afk user script [Re: Riamus2] #168307 06/01/07 08:11 PM
Joined: Oct 2006
Posts: 82
B
BritishGent Offline
Babel fish
Offline
Babel fish
B
Joined: Oct 2006
Posts: 82
Originally Posted By: Riamus2
Code:
on *:start: {
  hmake AwayTable 50
}

on *:text:!afk*:#yourchannel: {
  var %time = $ctime
  if (!$hget(AwayTable)) { hmake AwayTable 50 }
  hadd AwayTable $nick $iif($2,$2-,Unknown) %time
  msg $chan $nick is away @ $+ $time(%time)
}

on *:text:!back:#yourchannel: {
  if ($hget(AwayTable,$nick)) {
    msg $chan $nick is back from $gettok($v1,1- $calc($gettok($v1,0,32) - 1),32) $+ .  $nick was gone for $duration($calc($ctime - $gettok($v1,$gettok($v1,0,32),32))) $+ .
    hdel AwayTable $nick
  }
  else msg $chan You're not away.
}

on *:text:!away:#yourchannel: {
  var %cnt = 1
  var %total = $hget(AwayTable,0).item
  while (%cnt <= %total) {
    var %name = $hget(AwayTable,%cnt).item
    var %data = $hget(AwayTable,%cnt).data
    write afk.tmp %name is away $chr(40) $+ $gettok(%data,1- $calc($gettok(%data,0,32) -1),32) $+ $chr(41) since $time($gettok(%data,$gettok(%data,0,32),32)) $+ .
    inc %cnt
  }
  .play $chan afk.tmp 1500
  .remove afk.tmp
}

on *:text:*:#yourchannel: {
  if ($hget(AwayTable,$remove($strip($1),?)) && !$2) {
    var %data = $hget(AwayTable,$remove($strip($1),?))
    msg $chan $left($1,-1) is away $chr(40) $+ $gettok(%data,1- $calc($gettok(%data,0,32) -1),32) $+ $chr(41) since $time($gettok(%data,$gettok(%data,0,32),32)) $+ .
  }
}

on *:part:#yourchannel: {
  if ($hget(AwayTable,$nick)) {
    hdel AwayTable $nick
  }
}

on *:quit: {
  if ($hget(AwayTable,$nick)) {
    hdel AwayTable $nick
  }
}


Is it at all possible to add the date after the time ?


Never ASSUME!!!

As it often makes and ASS out of U and ME!!
Re: !afk user script [Re: BritishGent] #168317 07/01/07 05:28 AM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
Just change the $time( ) part to include the formatting options that you want to use.

/help $time

For example, at the end, you could put:

,hh:nntt mmm dd yyyy)

... instead of just the )

Just look at the help file and choose how you want it to look. You can add colors and control codes inside there and if you want to include a comma, use $chr(44).


Invision Support
#Invision on irc.irchighway.net
Re: !afk user script [Re: Riamus2] #168389 08/01/07 03:49 AM
Joined: Oct 2006
Posts: 82
B
BritishGent Offline
Babel fish
Offline
Babel fish
B
Joined: Oct 2006
Posts: 82
i have noticed that the !away command has a slight glitch with it.

my friend marked themselves away in my channel as you can see below at the specified time:

[00:52] <CHIEFY> !afk making coffee
[00:52] <^Merlin> CHIEFY is away @12:52am Jan 08 2007

Yet some hours later i did the !away command to see how it was working and i got this responce:

[03:31] <Tallulah> cool!
[03:34] <^Silent_Runner^> !away
[03:34] <^Merlin> CHIEFY is away (making coffee) since 03:34:35 on 08/01/07.
[03:35] <Tallulah> cool, I knew you had done that, but couldn't remember what the command was

and as you can see the time being reported as my friend being away is completely wrong from the time of the command being issued.

If anyone could help me with this i would be grateful smile

Many Thanks


Never ASSUME!!!

As it often makes and ASS out of U and ME!!
Re: !afk user script [Re: BritishGent] #168396 08/01/07 05:10 AM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
Are you sure he didn't do !afk again? Try having someone do !afk, then check !away after a minute or two.


Invision Support
#Invision on irc.irchighway.net
Re: !afk user script [Re: Riamus2] #168399 08/01/07 05:17 AM
Joined: Oct 2006
Posts: 82
B
BritishGent Offline
Babel fish
Offline
Babel fish
B
Joined: Oct 2006
Posts: 82
yes i am sure he didn't go !afk again. checked and double checked and tried it myself, it returns the time when !away is used everytime frown


Never ASSUME!!!

As it often makes and ASS out of U and ME!!
Re: !afk user script [Re: BritishGent] #168408 08/01/07 10:05 AM
Joined: Mar 2003
Posts: 612
B
billythekid Offline
Fjord artisan
Offline
Fjord artisan
B
Joined: Mar 2003
Posts: 612
i there some $time error perhaps, a MM instead of an NN or something? I know that wouldn't give the results you show with the data but just another idea in the ring...

[edit] in fact i'm pretty sure it's a $time problem as the returned time is the same as the timestamp in your example...

[03:34] <^Merlin> CHIEFY is away (making coffee) since 03:34:35 on 08/01/07.

[/edit]


btk

Last edited by billythekid; 08/01/07 10:07 AM.

billythekid
Re: !afk user script [Re: BritishGent] #168418 08/01/07 02:08 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
Well, I just tried the script I posted above and it works as expected. Perhaps when you added the date information, you entered it incorrectly. Paste the msg line in the !away section.

Also, you might want to change this:
Code:
on *:text:*:#yourchannel: {
  if ($hget(AwayTable,$remove($strip($1),?)) && !$2) {
    var %data = $hget(AwayTable,$remove($strip($1),?))
    msg $chan $left($1,-1) is away $chr(40) $+ $gettok(%data,1- $calc($gettok(%data,0,32) -1),32) $+ $chr(41) since $time($gettok(%data,$gettok(%data,0,32),32)) $+ .
  }
}


to this:
Code:
on *:text:*:#yourchannel: {
  if ($hget(AwayTable,$remove($strip($1),?)) && !$2) {
    var %data = $hget(AwayTable,$remove($strip($1),?))
    msg $chan $remove($strip($1),?) is away $chr(40) $+ $gettok(%data,1- $calc($gettok(%data,0,32) -1),32) $+ $chr(41) since $time($gettok(%data,$gettok(%data,0,32),32)) $+ .
  }
}


I forgot to change that msg line when I made it work without the ? at the end.


Invision Support
#Invision on irc.irchighway.net
Re: !afk user script [Re: Riamus2] #168470 09/01/07 01:25 AM
Joined: Oct 2006
Posts: 82
B
BritishGent Offline
Babel fish
Offline
Babel fish
B
Joined: Oct 2006
Posts: 82
This is how i have the script at present and all works superb with the exception of the !away function.

Code:
on *:start: {
  hmake AwayTable 50
}

on *:text:!afk*:#Simons-Forums: {
  var %time = $ctime
  if (!$hget(AwayTable)) { hmake AwayTable 50 }
  hadd AwayTable $nick $iif($2,$2-,Unknown) %time 
  msg $chan $nick is away @ $+ $time(%time,hh:nn mmm dd yyyy)
}

on *:text:!back:#Simons-Forums: {
  if ($hget(AwayTable,$nick)) {
    msg $chan $nick is back from $gettok($v1,1- $calc($gettok($v1,0,32) - 1),32) $+ .  $nick was gone for $duration($calc($ctime - $gettok($v1,$gettok($v1,0,32),32))) $+ .
    hdel AwayTable $nick
  }
  else msg $chan You're not away.
}

on *:text:!away:#Simons-Forums: {
  var %cnt = 1
  var %total = $hget(AwayTable,0).item
  while (%cnt <= %total) {
    var %name = $hget(AwayTable,%cnt).item
    var %data = $hget(AwayTable,%cnt).data
    write afk.tmp %name is away $chr(40) $+ $gettok(%data,1- $calc($gettok(%data,0,32) -1),32) $+ $chr(41) since $time on $date($gettok(%data,$gettok(%data,0,32),32)) $+ .
    inc %cnt
  }
  .play $chan afk.tmp 1500
  .remove afk.tmp
}

on *:text:*:#Simons-Forums: {
  if ($hget(AwayTable,$remove($strip($1),?)) && !$2) {
    var %data = $hget(AwayTable,$remove($strip($1),?))
    msg $chan $remove($strip($1),?) is away $chr(40) $+ $gettok(%data,1- $calc($gettok(%data,0,32) -1),32) $+ $chr(41) since $time($gettok(%data,$gettok(%data,0,32),32)) $+ .
  }
}

on *:action:*:#Simons-Forums: {
  if ($hget(AwayTable,$remove($strip($1),?)) && !$2) {
    var %data = $hget(AwayTable,$remove($strip($1),?))
    msg $chan $left($1,-1) is away $chr(40) $+ $gettok(%data,1- $calc($gettok(%data,0,32) -1),32) $+ $chr(41) since $time on $date($gettok(%data,$gettok(%data,0,32),32)) $+ .
  }
}

on *:part:#Simons-Forums: {
  if ($hget(AwayTable,$nick)) {
    hdel AwayTable $nick
  }
}

on *:quit: {
  if ($hget(AwayTable,$nick)) {
    hdel AwayTable $nick
  }
}


I took onbaord comments earlier about time commands and edited and comments about changing lin structures.

I have just tested it and this is the result.

[01:14] <^Silent_Runner^> testing 3I Am Away From Keyboard script
[01:14] <^Silent_Runner^> !afk testing script
[01:14] <^Merlin> ^Silent_Runner^ is away @01:14 Jan 09 2007
[01:15] <^Silent_Runner^> right 01:14
[01:15] <^Silent_Runner^> give it a few mins and i'll check if it has recorded correct time
[01:15] <Tallulah> ok
[01:17] * ChanServ sets mode: +o ^Silent_Runner^
[01:17] -ChanServ:#Simons-Forums- OP command used for ^Silent_Runner^ by ^Silent_Runner^
[01:17] -ChanServ- Opped ^Silent_Runner^ on channel #Simons-Forums.
[01:17] * ^Silent_Runner^ sets mode: -o ^Silent_Runner^
[01:18] * ChanServ sets mode: +o ^Silent_Runner^
[01:18] -ChanServ:#Simons-Forums- OP command used for ^Silent_Runner^ by ^Silent_Runner^
[01:18] -ChanServ- Opped ^Silent_Runner^ on channel #Simons-Forums.
[01:18] * ^Silent_Runner^ sets mode: -o ^Silent_Runner^
[01:18] * ChanServ sets mode: +o ^Silent_Runner^
[01:18] -ChanServ:#Simons-Forums- OP command used for ^Silent_Runner^ by ^Silent_Runner^
[01:18] -ChanServ- Opped ^Silent_Runner^ on channel #Simons-Forums.
[01:18] * ^Silent_Runner^ sets mode: -o ^Silent_Runner^
[01:20] <^Silent_Runner^> nagh i give up with that one, i can not get it too work
[01:20] <^Silent_Runner^> !away
[01:20] <^Merlin> ^Silent_Runner^ is away (testing script) since 01:20:27 on 09/01/07.

As you can see it is still posting on the !away command the time that command is issued and not the time the !afk command was issued.

So i am none the wiser about what to do, any help would be greatly appreciated as this is a cool script thus far, i love it smile

Many Thanks


Never ASSUME!!!

As it often makes and ASS out of U and ME!!
Re: !afk user script [Re: BritishGent] #168484 09/01/07 05:15 AM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
Heh. Look at this line (from your !away part):

Code:
write afk.tmp %name is away $chr(40) $+ $gettok(%data,1- $calc($gettok(%data,0,32) -1),32) $+ $chr(41) since $time on $date($gettok(%data,$gettok(%data,0,32),32)) $+ .



And compare it to mine. Your $date part is fine, unless you want the month/day reversed, but you just have $time there... that will definitely just show the current time. The $time part should look identical to the $date part on that line, except that it says $time.


Invision Support
#Invision on irc.irchighway.net
Re: !afk user script [Re: Riamus2] #168495 09/01/07 09:16 AM
Joined: Oct 2006
Posts: 82
B
BritishGent Offline
Babel fish
Offline
Babel fish
B
Joined: Oct 2006
Posts: 82
Originally Posted By: Riamus2
Heh. Look at this line (from your !away part):

Code:
write afk.tmp %name is away $chr(40) $+ $gettok(%data,1- $calc($gettok(%data,0,32) -1),32) $+ $chr(41) since $time on $date($gettok(%data,$gettok(%data,0,32),32)) $+ .



And compare it to mine. Your $date part is fine, unless you want the month/day reversed, but you just have $time there... that will definitely just show the current time. The $time part should look identical to the $date part on that line, except that it says $time.


For give my stupidity here but i just do not get what you are saying.....


Never ASSUME!!!

As it often makes and ASS out of U and ME!!
Re: !afk user script [Re: BritishGent] #168503 09/01/07 02:12 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
Change that line to:

Code:
write afk.tmp %name is away $chr(40) $+ $gettok(%data,1- $calc($gettok(%data,0,32) -1),32) $+ $chr(41) since $time($gettok(%data,$gettok(%data,0,32),32)) on $date($gettok(%data,$gettok(%data,0,32),32)) $+ .



Notice that $time now matches what I originally gave you before you edited it for date.


Invision Support
#Invision on irc.irchighway.net
Page 1 of 2 1 2