mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2014
Posts: 40
Feyl0rd Offline OP
Ameglian cow
OP Offline
Ameglian cow
Joined: Dec 2014
Posts: 40
I need help coming up with a way to queue multiple commands that are requested at one time.
EX:
user1:!buytickets 1
user2:!buytickets 5
user3:!buytickets 8
user4:!buytickets 55
This floods the bot and it will only (probably) spit out only the first one. I need a way to where it keeps track of all of them and executes all of them. This is what I'm working with:

on *:TEXT:!buyticket &:#:{
if (!%raffle) { msg $chan Raffle is currently closed! }
else {
if ($int($2) < 1) { msg $chan Do you really want to buy no tickets?, $nick $+ ..? }
elseif ($int($2) > 10) { msg $chan Sorry $nick but you can only buy up to 10 at a Time. }
else {
var %i = 0, %ticket = $int($2)
var %topic = $+(#,.,$nick), %user = $readini(Points.ini,%topic,Points), %end = 10 * %ticket, %delete = %user - %end
if (%delete > 0) {
writeini -n $qt(Points.ini) %topic Points %delete
while (%i < %ticket) {
write $qt(Raffle.txt) $nick
inc %i
}
msg $chan $nick you have bought %ticket tickets with %end reputation.
}
}
}
}

Joined: Nov 2014
Posts: 149
J
Vogon poet
Offline
Vogon poet
J
Joined: Nov 2014
Posts: 149
See:

https://forums.mirc.com/ubbthreads.php/topics/249755/Krawalli#Post249755

In this post I answered a similar question by subject anti flood.

Joined: Dec 2014
Posts: 40
Feyl0rd Offline OP
Ameglian cow
OP Offline
Ameglian cow
Joined: Dec 2014
Posts: 40
Unfortunately this isn't what I'm looking for. By extension what I'm asking for in itself will act as flood control. I need to find a way to have the bot store up the commands in a queue if they get flooded and execute them until the "queue" is empty; essentially being able to carry out multiple spammed !command's.

Joined: Nov 2014
Posts: 149
J
Vogon poet
Offline
Vogon poet
J
Joined: Nov 2014
Posts: 149
Originally Posted By: Feyl0rd
Unfortunately this isn't what I'm looking for. By extension what I'm asking for in itself will act as flood control. I need to find a way to have the bot store up the commands in a queue if they get flooded and execute them until the "queue" is empty; essentially being able to carry out multiple spammed !command's.


I do not understand why the store and have bot commands in a queue.

The code I offered in the other post, makes flood control for each command independently, with the same or different times for everyone.

I also foresee, that run the same user or a different one.

Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
What you're asking for is something like this: when someone does a command, let's say "!test". All other commands will not work for a set period of time, if someone else tries to use "!test2" while the cooldown is active, a timer will start and "!test2" will be used once the cooldown has ended. Upon using "!test2" you also want to set a new cooldown so that the next command "!test3" that was also used while the cooldown of "!test" same as "!test2" will be used after the cooldown of "!test2" ends. Right?

I don't see a way for this to happen dynamically unless you have all your events as aliases. Otherwise you'd have to add a static timercheck on each remote command and that's one hell of an ugly solution.
So if you want this to happen, I suggest you re-do all your current commands to aliases. If you don't know what I mean, see this:
Code:
on *:text:!test:#: { msg # $nick used a test }
;would be 
alias commandtest { msg $1 $2 used a test }
on *:text:!test:#: { commandtest # $nick } 


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Jun 2014
Posts: 248
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Jun 2014
Posts: 248
A command queue is probably the proper way to handle this kind of stuff, so good call here. The one I use unfortunately can't really be pulled out of my bot and shared separately.

You could just use the normal if (%spammed) { return } variable
but instead of returning write your response to a file or hash table. Then you'd have a timed event which reads from that table/file. So as an example

Code:
on *:text:!version:#: {
  ;set a var for our response
  var %r Current Version 0.12.14.14 V. $+ $version 
  ;make sure the nick using the command is an op
  if ($nick isop #) { 
    ;make sure the %spam variable doesn't exist, if it does skip to elseif
    if (%spam >= 1) {
      ;no spam variable so we can ust send this message
      .msg $chan %r
      ;inc spam variable
      inc %spam 2
      ;quit
      return
    }
    ;see if the message is already in the table, if it is quit
    elseif ($hfind(messages, %r, 0, w).data >= 1) { return }
    ;add message to table
    hadd messages $ctime %r
  }
}


So something like this, you just need a timed event to check the table and dec the anti spam variable.

Last edited by Belhifet; 16/12/14 04:37 AM.
Joined: Jun 2014
Posts: 248
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Jun 2014
Posts: 248
Code:
alias messages {
  if ($2 isop $1) { 
    if (%spam >= 1) {
      .msg $2 %r
      inc %spam 2
      return
    }
    elseif ($hfind(messages, %r, 0, w).data >= 1) { return }
    hadd messages $ctime %c %r
  }
}
on *:text:!version:#: {
  var %r Current Version 0.12.14.14 V. $+ $version
  messages $chan $nick
}
on *:CONNECT: {
  if (!$hget(messages)) { hmake messages }
    .timer.messages 0 1 messagequeue
  }
}
alias messagequeue {
  if (%spam > 0) { dec %spam 1 }
  if ($hget(messages, 0) > 1) {
    .msg $hget(messages, 1).data
    hdel messages $hget(messages, 1).item
    inc %spam 2
  }
}

Here's better example.

Last edited by Belhifet; 16/12/14 06:27 AM.
Joined: Dec 2014
Posts: 40
Feyl0rd Offline OP
Ameglian cow
OP Offline
Ameglian cow
Joined: Dec 2014
Posts: 40
Thanks. Yeah... if only I had the know how. I'll use what you've given me and try and build from there. My knowledge doesn't extend out to what I'm trying to do and it's a bit frustrating haha! Large ideas but still really new to irc. Thank you.

Joined: Jun 2014
Posts: 248
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Jun 2014
Posts: 248
Ok here's a version that actually works..heh.

Code:
alias messages {
    if (%spam <= 1) || (!%spam) {
      .msg $1 %r
      inc %spam 2
      return
    }
    else {
      var %i = 1, %n = $hget(messages,0).data, %match = $1 %r
      while (%i <= %n) {
        if ($hget(messages,%i).data == %match) { return }
        inc %i
      }    
      hadd messages $ctime $1 %r
    }
  }
on *:CONNECT: {
  if (!$hget(messages)) { hmake messages }
  .timer.messages 0 1 messagequeue
}
alias messagequeue {
  if (%spam > 0) { dec %spam 1 }
  if ($hget(messages,0).item > 0) {
    .msg $hget(messages, 1).data
    hdel messages $hget(messages, 1).item
    inc %spam 2
  }
}

This is the message queue. It hangs out on its own in a remote somewhere.

Code:
on *:text:!version:#: {
if ($nick isop #) {
  set -u0 %r Current Version 0.12.14.14 V. $+ $version
  messages $chan 
  }
}

Your on text events just set the message they wanna spew out at %r then call the messages alias word $chan sent along side so that the timed event knows where to send the message later on.

I don't think there is any problems with this version. Probably is though, cause I made it smile.

Last edited by Belhifet; 16/12/14 07:27 PM.
Joined: Dec 2014
Posts: 40
Feyl0rd Offline OP
Ameglian cow
OP Offline
Ameglian cow
Joined: Dec 2014
Posts: 40
Haha! I'll have to take a look at it and try and figure it all out. This is like day 9 of my exploration of iRC with mIRC. grin

Joined: Jun 2014
Posts: 248
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Jun 2014
Posts: 248
Oh well, On my day 9 I was still terrified of dynamic variables. It wasn't all that long ago so if you keep at it this stuff will eventually come to you easier.

Joined: Dec 2014
Posts: 40
Feyl0rd Offline OP
Ameglian cow
OP Offline
Ameglian cow
Joined: Dec 2014
Posts: 40
Any suggestions on materials that I could perhaps use as study?

Joined: Jun 2014
Posts: 248
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Jun 2014
Posts: 248
Just other people's scripts really; the other resources out there are hit and miss on just about everything.

Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
The help files
http://en.wikichip.org/wiki/mirc
Other codes (you'll find that people code differently though, and you'll find your own style eventually)


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net

Link Copied to Clipboard