mIRC Home    About    Download    Register    News    Help

Print Thread
#268356 14/01/21 05:36 PM
Joined: Jan 2021
Posts: 3
S
Suratka Offline OP
Self-satisfied door
OP Offline
Self-satisfied door
S
Joined: Jan 2021
Posts: 3
Hi everyone. I'm new to the forum.
i wrote two small scripts. The first goes to bot A, which should be placed in channel A, and which reads and sends all new nicknames that enter to bot B.

addon 2 that goes into bot B
receives nicknames from bot A and having the operator flag in channel B invites all nicknames to channel B.

The addons work.
but I want better.
I want invitations to be 1 in 20.
I'll explain:
There are two possible solutions.
Solution n1 Bot A counts new nicknames that enter and sends bot B only one nick every 20.

solution n 2
Bot B gets all the nicknames from bot A, but invites only one in 20.

I can't do it.
can you help me?

Code
  ;######|BOT A (LEGGE I NICK E LI INVIA AL BOT B)|##########
on 1:join:#x: {
  set %mexjoin Benvenuto in Shoganai ^^ | set %newjoin $nick
  if ($nick != $me) { .inc %joins 1 } {
    msg # %mexjoin $+ $nick sei il numero %joins | msg BotB %newjoin 
  }
  unset %newjoin
}  


;#######|BOT B (RICEVE IL NICK DAL BOT A, E MANDA L'INVITO)|######
On 1:text:*:?: {
  if ($nick == Bot-A) {
    set %nickinvite $1- { 
      msg #shoganai !invite %nickinvite | close -m  
    }
  }
  unset %nickinvite
}  

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
The script probably works better if all nicks joining #chanA are known by the bot in #chanB, and might even work better if the same bot is in both channels. For one thing, BotB needs to know which of the joined nicks is already in #chanB. If you're wanting to invite every 20th nick, you can have a counter (as a global variable or in a hashtable) which is incremented before each join to #chanA, then invites only when the counter is either 1 for the 1st of 20, or when the counter is at 20 for the last of 20. When the counter is above 20, it must be replaced by 1. You can also use "if ($rand(1,20) == 1)" to decide whether to invite each nick, but that will have random results, and after 20 joins to A could result in zero invites or 20 invites, though the most likely result is 1 join.

Things get a little more complicated if you need to resist "gaming the system", such as someone doing a /part-then-/join repeatedly until they win the invite lottery.

I'm curious how this actually works in practice, since the invite shows in status window unless you've checkboxed "options/irc/show-in-active=invite". Most people do not enable the "auto join channel on invite" option because it's not selective as to which joins are accepted, and people would rather auto-join nothing instead of finding themselves suddenly having a join window popping up for some unwanted channel.

Joined: Jan 2021
Posts: 3
S
Suratka Offline OP
Self-satisfied door
OP Offline
Self-satisfied door
S
Joined: Jan 2021
Posts: 3
Thank you. : following your instructions, even if it took a lot of time and effort, I succeeded. : D


Link Copied to Clipboard