mIRC Home    About    Download    Register    News    Help

Print Thread
#64250 16/12/03 11:11 PM
Joined: Dec 2003
Posts: 6
C
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Dec 2003
Posts: 6
Hi folks,

Welcome a total newb who finds herself way too confused. I use a registered version of mIRC 6.12 . My network has a services bot, nickserv, that writes output like this:

List of entries matching *|*:
Dan|AFK [Hidden]
Dan|Away [Hidden]
Dan|School [Hidden]
Dan|Sleep [Hidden]
Dark_Razer|Work [Hidden]

. . .

y}}Pq}[e| [Hidden]
z|[j^J|_ [Hidden]
{j|[} [Hidden]
{_|_} BigB@staff.XXXXXXXXXX.net
|d{M}]^{Q [Hidden]
|O|{F\Wp [Hidden]
|WoRkInGbAsTaRd| ~mucas@XXXXXXXXXXXX.com
]\``E{|fX [Hidden]

End of list - 27/27 matches shown.

It turns out that some of these are the registered nicks of spammers of whom we'd like to purge our list. I've written a script which at first blush I thought pretty promising, but doesn't act as I expect.

#Spammerrec off
on *:NOTICE:*:*: { if ($nick == NickServ) {
if (List of entries matching isin $1-) {
./hmake -s Spamlist 10
/set %c 1
}
elseif (End != $1) && ([Hidden] == $2) {
/hadd Spamlist %c $1
/inc %c 1
}
elseif (End == $1) {
/dec %c 1
/while %c != 0 {
set -u %halt 1
.timerhalt. 1 0 if ($input(Drop $hget(Spamlist,%c) $+ ?,nqv,DROP USER?)) == $yes {
/unset %halt
/Echo 0,12 $hget(Spamlist,%c)
/msg nickserv info $hget(Spamlist,%c)
}
.timerhalt. -e
/dec %c 1
if %halt { halt }
}
./hfree -s Spamlist
/unset %c
}
}
}
#Spammerrec end

I must admit to being new to the concept of function identifiers that don't operate within a script, but on the basis of speed of execution I can understand why it is deemed necessary. I used some code I gleened from one of your posts within the while loop but must admit that I don't comprehend the necessity of the halt parameter/variable as a flag. The operative line seems to be .timerhalt. 1 0 if ($input(Drop $hget(Spamlist,%c) $+ ?,nqv,DROP USER?)). I understand the use of ./timerhalt 1 0 to be to time displace the $input until after the script operates. The rest of the line, if ($input(Drop $hget(Spamlist,%c) $+ ?,nqv,DROP USER?)), I comprehend places an "Input Window" on the screen showing a question mark (-q), returns an identifier; $yes, $no, $ok, or $cancel, (-v), and shows the yes, no, and cancel buttons (-n). It seems to handle the visual aspects of this fine and sequentially asks if I'd care to drop the user one by one in the reverse order in which they were loaded into the Spammer hash table. I intended the lines following to function according to the returned identifier value, but of course whereas they operate within the script and the $input windows operate after the script completes, they do not do what I expect. In short my timing is off. The script is obviously shown off in this example but when it runs it runs. What I do get is echo of each of the names entered into the hash table, and subsequently output from the same bot for information about each of the users named. Sample of output follows:

]\``E{|fX
info ]\``E{|fX
|O|{F\Wp
info |O|{F\Wp
|d{M}]^{Q
info |d{M}]^{Q
{j|[}
info {j|[}
z|[j^J|_
info z|[j^J|_
y}}Pq}[e|
info y}}Pq}[e|

. . .

Dark_Razer|Work
info Dark_Razer|Work
Dan|Sleep
info Dan|Sleep
Dan|School
info Dan|School
Dan|Away
info Dan|Away
Dan|AFK
info Dan|AFK


]\``E{|fX is yvpu
]\``E{|fX is currently online.
Time registered: Dec 09 17:11:54 2003 CST
== Unknown command
|O|{F\Wp is PKX.com
Time registered: Dec 08 19:38:28 2003 CST
Last seen time: Dec 08 19:40:43 2003 CST
== Unknown command
|d{M}]^{Q is EVuaC.org
Time registered: Dec 08 02:04:27 2003 CST
Last seen time: Dec 08 02:05:48 2003 CST
== Unknown command
{j|[} is jgq.com
Time registered: Dec 08 03:27:48 2003 CST
Last seen time: Dec 08 03:28:32 2003 CST
== Unknown command
z|[j^J|_ is sHSsYQNknC.org
Time registered: Dec 08 17:36:12 2003 CST
Last seen time: Dec 08 17:36:21 2003 CST
== Unknown command
y}}Pq}[e| is emVSMIyO.net
Time registered: Dec 09 01:11:04 2003 CST
Last seen time: Dec 09 01:12:18 2003 CST
== Unknown command

. . .

Dark_Razer|Work is dark
Time registered: Nov 20 21:09:44 2003 CST
Last seen time: Nov 20 21:12:07 2003 CST
Last quit message: Quit: Oh NOZ!!! IMA ETCHU!! IMA ETCHU!!
== Unknown command
Dan|Sleep is blah
Time registered: Aug 24 05:11:22 2003 CDT
Last seen time: Dec 09 07:41:46 2003 CST
Last quit message: Ping timeout
== Unknown command
Dan|School is blah
Time registered: Sep 22 11:15:07 2003 CDT
Last seen time: Dec 09 16:21:38 2003 CST
Last quit message: Ping timeout
== Unknown command
Dan|Away is blah
Time registered: Aug 25 17:38:40 2003 CDT
Last seen time: Nov 30 17:53:41 2003 CST
== Unknown command
Dan|AFK is blah
Time registered: Aug 24 17:34:41 2003 CDT
Last seen time: Dec 07 03:28:23 2003 CST
Last quit message: Ping timeout
== Unknown command

So I query, what purpose if any will the %halt flag serve, can the return from the $input be tested presumably in another script with another trigger than the "on NOTICE," if so what is a return from a $input designated (i.e., on what?), and finally, if these $input actions are taking place after my initial script is executed and if I've released the hash table, how are the names surviving the script to be in the $input action after the script completes?

Puzzled,

Caitlain

Joined: Nov 2003
Posts: 227
H
Fjord artisan
Offline
Fjord artisan
H
Joined: Nov 2003
Posts: 227
Long post, well i read through it, and I would think the timer might give some problems, so i thought i would be an idea only to start asking you if you wanted to delete the nicks after nickserv had finished listing them.
its not tested, but I changed a few things and ended up with a new alias that should be triggered when you get the end of the list, used timer because cant use $input with an event like on notice (as you know)
Code:
#Spammerrec off
on *:NOTICE:*:?: { 
  if ($nick == NickServ) {
    if ($1-4 == List of entries matching) {
      hmake Spamlist 10
      return
    }
    if (End != $1) && ([Hidden] == $2) {
      ; making list with nicknames as items (no data)
      ; means you don't need a variable for item names
      hadd Spamlist $1
      return
    }
    if ($1-3 == End of list) {
      ; as you know need a timer because you cant have $input on notice event
      .disable #Spammerrec
      ; disable group, you will probably have something to enable it
      ; when you ask nickserv for the list of names.
      .timerfreespamers 1 0 freespamers
    }
  }
}
#Spammerrec end

alias freespammers {
  var %c = $hget(spamlist,0).item
  while (%c) {
    ; while (%c) is just short for while %c != 0
    if ($input(Drop $hget(Spamlist,%c).item $+ ?,nqv,DROP USER?) == $yes) {
      echo 0,12 $hget(Spamlist,%c)
      .msg nickserv info $hget(Spamlist,%c).item
    }
    hfree Spamlist
  }
}

probably needs things changed, but maybe it will help a little

Joined: Dec 2002
Posts: 102
M
Vogon poet
Offline
Vogon poet
M
Joined: Dec 2002
Posts: 102
No worries, what you should do is create an alias that will run on your timer. Essentially the timer is like an event, when it runs it triggers it's own code but in and of itself it doesn't do anything else...

What your code is doing is causing the red code below to be executed one time zero seconds from when the original function ran.

.timerhalt. 1 0 if ($input(Drop $hget(Spamlist,%c) $+ ?,nqv,DROP USER?)[color:blue]) == $yes ) {[/color]

When this bit of code tries to run it b0rkes pretty bad and that's why you're getting the == unknown command errors. Essentially you have an extra bracket before the operator, (blue) so the command being issued for your "then" portion is: == $yes {

I think you should have had the ) after the $yes, however it still won't be able to access subsequent lines when the timer triggers so you need to change the structure a little.

The remaining part of your code is run immediately after your timer is created, not when the timer runs:

/while %c != 0 {
set -u %halt 1
.timerhalt. 1 0 if ($input(Drop $hget(Spamlist,%c) $+ ?,nqv,DROP USER?)) == $yes {
/unset %halt
/Echo 0,12 $hget(Spamlist,%c)
/msg nickserv info $hget(Spamlist,%c)
}

.timerhalt. -e
/dec %c 1
if %halt { halt }
}

If you like you can create an alias to execute that block of code external to the original function. Replace your timer with one that will call an alias wherein the code will reside:

on *:notice:*:*:{
*** stuff here ***
.timer 1 0 spammerrec
*** more stuff ***
}
alias spammerrec {
; this code will execute each time the timer is called.
if ($input(Drop $hget(Spamlist,%c) $+ ?,nqv,DROP USER?) == $yes) {
Echo 0,12 $hget(Spamlist,%c)
msg nickserv info $hget(Spamlist,%c)
} }

or similar (I didn't test this for functionality, just pointing out how the code flows...)

In addition you asked about the entries themselves. A hash table is a storage mechanism, you can keep stuff in ram until you decide to close mIRC, free the table or if you'd like you can write the tables' contents to disk.


-
MIMP
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
We get new admins by the second. >:P

p.s. Where do I sign up? >:P


-KingTomato
Joined: Dec 2002
Posts: 102
M
Vogon poet
Offline
Vogon poet
M
Joined: Dec 2002
Posts: 102
New admins? I've been a moderator here since August of 2002... I'm just lazy like no other...

Oh, and to answer your question, I think the signup sheet has been full for a long time, and Karen forgot to photocopy it first... mad


-
MIMP
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
lol.. Darn Karen-- That's it, para gets all the PB cookies in stock. I was considering sharing, but guess not after all. >:D


-KingTomato
Joined: Dec 2003
Posts: 6
C
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Dec 2003
Posts: 6
Excellent posts gentlemen, accept they don't actually work and, not to put too fine a point on it, but none of your posts actually answer the questions I asked. I'm still working on it and hope to stumble across a solution.

You might also answer this: how can I set a variable to the resolved value of one of the elements of the hash table on the fly. For instance how would I declare %a to be the information in $hget(Spamlist,%c)? /set %a = $hget(Spamlist,%c) yields me, in variables, %a = $hget(Spamlist,%c) rather than the nick acquired from the list represented by the information in that location.

Thanks

Caitlain

Maybe I'm partially wrong, maybe you did partially answer one of them. However, it seems that I can't pass the hash file data out to the called alias. Once the line goes behind a timer command the line can't resolve the data from the hash table.

Caitlain

Last edited by Caitlain; 17/12/03 10:07 PM.
Joined: Nov 2003
Posts: 227
H
Fjord artisan
Offline
Fjord artisan
H
Joined: Nov 2003
Posts: 227
you can get the elements from a hash table 2 ways, 1) by name with $hget(table,name) , 2) by number with $hget(table,N).data , in my example i was keeping the nicks in the element name of the hash table and not adding any data to it, in this case $hget(table,name) would return null, as there is no data.
However you can still get the data by number with $hget(table,N).item and loop though $hget(table,0) to get all the data or element names as they really are.

Joined: Dec 2003
Posts: 6
C
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Dec 2003
Posts: 6
I build an alias /spamrec in my alias table: /spamrec /timer 1 1 set %c $input(Drop %b $+ ?,nqv,DROP USER?) . %b is assigned the value of $hget(Spamlist,%i), %c is intended to collect up the return. I call the alias from my script and I still get "* $input: cannot use in an event (line 18, aliases.ini)". This is utterly frustrating, and frankly silly. What good is a scripting identifier that takes user input needed in a script and make it unable to work within a script? I mean where's the manual that explains the reasons for this? ...and don't tell me to read the help file. I've been running around in that for the last three weeks to get nowhere.

$input returns $yes, $no, $ok, or $cancel. In my case no $ok. Simply, how do I get that returned value tested in my script? I want it to do one thing for $yes, another thing for $no, still a third thing for $cancel. I don't want to test for just one particular return, I need to distinguish between them. There seems no way to do this. Why? Wouldn't something like this be necessary to actually make scripting usefull?

I'm sorry if I seem to be taking my frustration out on you folk, but this is just stupid.

Caitlain

Joined: Nov 2003
Posts: 227
H
Fjord artisan
Offline
Fjord artisan
H
Joined: Nov 2003
Posts: 227
First things first, don't panic.

Yes you can't have any $input type things working with remote events.
however if you use a timer you can kind it trick your way into it. put this in your remotes
Code:
on *:text:test:?:{ timer 1 0 testinput }
alias testinput {
  echo -a $input(does this work?,y)
}

type //msg $me test

should work ok, does for me on 6.12 anyway

thats why i showed that example of the event collecting all the nicks to the hash table, then after then end of list message from nickserv, i had a timer trigger the alias, then the alias go though all the nicks in the table asking if you wanted to remove.

Last edited by Hitchhiker; 18/12/03 01:58 AM.
Joined: Dec 2003
Posts: 6
C
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Dec 2003
Posts: 6
Yeah, it opens a query window to me.

[20:55] <Caitlain> test
[20:56] <Caitlain> test
[20:56] <Caitlain> test

Cait

Joined: Nov 2003
Posts: 227
H
Fjord artisan
Offline
Fjord artisan
H
Joined: Nov 2003
Posts: 227
/ctcp Caitlain version

Joined: Dec 2003
Posts: 6
C
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Dec 2003
Posts: 6
No return from that, but from the help|about mIRC v6.12

Caitlain

Joined: Nov 2003
Posts: 227
H
Fjord artisan
Offline
Fjord artisan
H
Joined: Nov 2003
Posts: 227
the little test script from before should work, maybe you have another on text messing it up, try putting it in the top of a new file. but the point is that it does work and it can be done.

Joined: Dec 2003
Posts: 6
C
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Dec 2003
Posts: 6
??????

You weren't paying attention? The small script you sent me did work.

I ran it three times. It reported that three times.

Anyway, thanks for the help. I'll keep at it. Something will smack me in the face soon I'm sure.

Caitlain



Link Copied to Clipboard