mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
#272454 03/03/24 11:36 AM
Joined: May 2022
Posts: 78
F
Fernet Offline OP
Babel fish
OP Offline
Babel fish
F
Joined: May 2022
Posts: 78
I wish my bot to send a message every XXX seconds.
I wrote a list of messages saved in a file frasibot.txt
Then I set a timer :

.timerbot 0 300 msg #channel $read(addons\miefrasibot\frasibot.txt)

My problem is that .timerbot repeat always the same message every 6 mins (I have more than 300 messages), instead of to change it (random message)

Thanks

Fernet #272456 03/03/24 01:50 PM
Joined: Jan 2012
Posts: 323
Pan-dimensional mouse
Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 323
This can be done through a separate alias, for example with the name "rand_msg", which will be activated by a timer every 300 secs.
The body of this alias will contain a command for sending to the #channel a random message from your file.

Try using this script code:
Code
alias timer_start { rand_msg | .timerRANDMSG 0 300 rand_msg }
alias timer_stop { .timerRANDMSG off }
alias -l rand_msg { msg #channel $read(addons\miefrasibot\frasibot.txt) }

Command to start the timer: /timer_start
Command to stop the timer: /timer_stop


Screenshot with an example of sending a message every 10 secs:

     [Linked Image from i.ibb.co]


🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Epic #272457 03/03/24 04:56 PM
Joined: May 2022
Posts: 78
F
Fernet Offline OP
Babel fish
OP Offline
Babel fish
F
Joined: May 2022
Posts: 78
Originally Posted by Epic
This can be done through a separate alias, for example with the name "rand_msg", which will be activated by a timer every 300 secs.
The body of this alias will contain a command for sending to the #channel a random message from your file.

Try using this script code:
Code
alias timer_start { rand_msg | .timerRANDMSG 0 300 rand_msg }
alias timer_stop { .timerRANDMSG off }
alias -l rand_msg { msg #channel $read(addons\miefrasibot\frasibot.txt) }

Command to start the timer: /timer_start
Command to stop the timer: /timer_stop


Screenshot with an example of sending a message every 10 secs:

     [Linked Image from i.ibb.co]

I only changed .timerRANDMSG 0 300 rand_msg with .timerRANDMSG 0 60 rand_msg for a fast test and...

[img]https://ibb.co/9WVKcsR[/img]

Doesn't work

Epic #272458 03/03/24 07:27 PM
Joined: May 2022
Posts: 78
F
Fernet Offline OP
Babel fish
OP Offline
Babel fish
F
Joined: May 2022
Posts: 78
Is almost perfect sir !!!

That's what I made (I asked about it also in another topic):


Code
on *:TEXT:!ON:#channel:{
  /bs say $chan Va beh...nessuno parla allora parlo io...
  /timer_start 
}
on *:TEXT:*:#channel:{
  /timer_stop
}
alias timer_start { 
  rand_msg | .timerRANDMSG 0 60 rand_msg
}
alias timer_stop { 
  .timerRANDMSG off 
}
alias -l rand_msg { 
  /bs say #channel $read(addons\miefrasibot\frasibot.txt) 
}

Now just miss a string that send the command !ON to the bot if nobody write any word after (for example) 1800sec.

Fernet #272459 03/03/24 11:10 PM
Joined: Jan 2012
Posts: 323
Pan-dimensional mouse
Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 323
Hmm... It’s not very clear why you use the Service Bot to send messages to the channel instead of your mIRC Bot doing it directly, because this complicates everything.
Nevertheless, it seems to me that the puzzle of your idea has almost come together into something understandable and therefore I have added some improvements to your latest code.

Try using this variant code:
Code
on *:TEXT:*:#channel:{
  if ($nick == ServiceBot) { return }
  if ($nick isop $chan && $1 == !ON) { bot_stop | bot_start $chan }
  elseif ($nick isop $chan && $1 == !OFF) { bot_stop }
  else { bot_stop | .timerBOTSTART 1 1800 bot_start $chan }
}
alias -l bot_start {
  bs say $1 Va beh...nessuno parla allora parlo io...
  rand_msg $1 | .timerRANDMSG 0 60 rand_msg $1
}
alias -l bot_stop { .timerBOTSTART off | .timerRANDMSG off }
alias -l rand_msg { bs say $1 $read(addons\miefrasibot\frasibot.txt) }


Description:

  • Every time someone on the channel writes something, the timer will restart, starting again to count down 1800 secs before the start of sending random messages.
  • In the code need to change the nick "ServiceBot" to the nick of your service bot on the channel to prevent the timer from being activated after its messages.
  • Only the channel operator with the @ sign will be able to execute the "!ON" and "!OFF" commands.
  • When sending the "!ON" command, the bot bypasses the wait and immediately begins writing random phrases with a delay of 60 seconds.
  • When the "!OFF" command is sent, the bot stops both timers.


🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Epic #272460 04/03/24 09:30 AM
Joined: Jul 2006
Posts: 4,182
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,182
Hey, $unsafe was used for a reason, whenever you are passing unknown data to timer's command you must use $unsafe to prevent double evaluation.
Both $chan and $1 are unknown in your timer's command.
You're also not preventing evaluation in your $read call with the n switch either, and it's good habit to use $read's 't' switch to prevent the first line from being interpreted incorrectly.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Epic #272463 04/03/24 04:45 PM
Joined: May 2022
Posts: 78
F
Fernet Offline OP
Babel fish
OP Offline
Babel fish
F
Joined: May 2022
Posts: 78
Originally Posted by Epic
Hmm... It’s not very clear why you use the Service Bot to send messages to the channel instead of your mIRC Bot doing it directly, because this complicates everything.
Nevertheless, it seems to me that the puzzle of your idea has almost come together into something understandable and therefore I have added some improvements to your latest code.

Try using this variant code:
Code
on *:TEXT:*:#channel:{
  if ($nick == ServiceBot) { return }
  if ($nick isop $chan && $1 == !ON) { bot_stop | bot_start $chan }
  elseif ($nick isop $chan && $1 == !OFF) { bot_stop }
  else { bot_stop | .timerBOTSTART 1 1800 bot_start $chan }
}
alias -l bot_start {
  bs say $1 Va beh...nessuno parla allora parlo io...
  rand_msg $1 | .timerRANDMSG 0 60 rand_msg $1
}
alias -l bot_stop { .timerBOTSTART off | .timerRANDMSG off }
alias -l rand_msg { bs say $1 $read(addons\miefrasibot\frasibot.txt) }


Description:

  • Every time someone on the channel writes something, the timer will restart, starting again to count down 1800 secs before the start of sending random messages.
  • In the code need to change the nick "ServiceBot" to the nick of your service bot on the channel to prevent the timer from being activated after its messages.
  • Only the channel operator with the @ sign will be able to execute the "!ON" and "!OFF" commands.
  • When sending the "!ON" command, the bot bypasses the wait and immediately begins writing random phrases with a delay of 60 seconds.
  • When the "!OFF" command is sent, the bot stops both timers.

This is really amazing perfect sir! Everythink work as I wished. Now I'll develope it because it also has to work aside of a trivia Bot: in a word, trivia maybe noise if someone is chatting in a chan, so has someone start to chat, TriviaBot must stop and let users to chat. When they stop, it can restart his work ^^
Last thing: is there a command for random color for a text? I know about ctrl+k and a number can choose 1 color. But is there a combination to set a random color to a text?
Thanks again sir

Wims #272465 04/03/24 05:53 PM
Joined: May 2022
Posts: 78
F
Fernet Offline OP
Babel fish
OP Offline
Babel fish
F
Joined: May 2022
Posts: 78
Originally Posted by Wims
Hey, $unsafe was used for a reason, whenever you are passing unknown data to timer's command you must use $unsafe to prevent double evaluation.
Both $chan and $1 are unknown in your timer's command.
You're also not preventing evaluation in your $read call with the n switch either, and it's good habit to use $read's 't' switch to prevent the first line from being interpreted incorrectly.

Not clear sir. Can Yu please explain me better?
Thanks

Fernet #272466 04/03/24 05:59 PM
Joined: Jul 2006
Posts: 4,182
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,182
My post was adressed to Epic, not to you Fernet smile

Edit: but I was saying you should update these three lines:

else { bot_stop | .timerBOTSTART 1 1800 bot_start $chan }
to
else { bot_stop | .timerBOTSTART 1 1800 bot_start $unsafe($chan) }

rand_msg $1 | .timerRANDMSG 0 60 rand_msg $1
to
rand_msg $1 | .timerRANDMSG 0 60 rand_msg $unsafe($1)

alias -l rand_msg { bs say $1 $read(addons\miefrasibot\frasibot.txt) }
to
alias -l rand_msg { bs say $1 $read(addons\miefrasibot\frasibot.txt,tn) }

Last edited by Wims; 04/03/24 06:33 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Wims #272469 04/03/24 06:38 PM
Joined: May 2022
Posts: 78
F
Fernet Offline OP
Babel fish
OP Offline
Babel fish
F
Joined: May 2022
Posts: 78
Originally Posted by Wims
My post was adressed to Epic, not to you Fernet smile

Edit: but I was saying you should update these three lines:

else { bot_stop | .timerBOTSTART 1 1800 bot_start $chan }
to
else { bot_stop | .timerBOTSTART 1 1800 bot_start $unsafe($chan) }

rand_msg $1 | .timerRANDMSG 0 60 rand_msg $1
to
rand_msg $1 | .timerRANDMSG 0 60 rand_msg $unsafe($1)

alias -l rand_msg { bs say $1 $read(addons\miefrasibot\frasibot.txt) }
to
alias -l rand_msg { bs say $1 $read(addons\miefrasibot\frasibot.txt,tn) }

Thanks sir, I'll try this one too. Thanks for details

Wims #272471 04/03/24 07:48 PM
Joined: Jan 2012
Posts: 323
Pan-dimensional mouse
Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 323
Originally Posted by Wims
Hey, $unsafe was used for a reason, whenever you are passing unknown data to timer's command you must use $unsafe to prevent double evaluation.
Both $chan and $1 are unknown in your timer's command.
You're also not preventing evaluation in your $read call with the n switch either, and it's good habit to use $read's 't' switch to prevent the first line from being interpreted incorrectly.
In this script there is no external influence and no transmission of any text data from outside by other users that this code could use, except for the user file that the author creates independently at his own responsibility. The passed identifiers $chan and $1 are known to the script. Therefore, there was no need to specify the additional $unsafe() identifier. However, thanks for reminding us about this and also to the new hooligans (hackers) about this vulnerability that can be present in any mIRC code.

Yes, of course, this can be added to the code so that everything is fine, we can sleep peacefully and the bot is safe in case of fire [Linked Image from i.ibb.co][Linked Image from i.ibb.co]

The only thing is that I didn’t pay attention to the absence of the necessary switches in $read(), because I automatically used the line created by the author of the post.


🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Fernet #272472 04/03/24 08:05 PM
Joined: Jan 2012
Posts: 323
Pan-dimensional mouse
Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 323
Originally Posted by Fernet
Last thing: is there a command for random color for a text? I know about ctrl+k and a number can choose 1 color. But is there a combination to set a random color to a text?
I added something to the code so that your random messages from the file will be colored in a random color.

So, after updating, taking into account all the remarks and suggestions, you can try using this script code:
Code
on *:TEXT:*:#channel:{
  if ($nick == ServiceBot) { return }
  if ($nick isop $chan && $1 === !ON) { bot_stop | bot_start $chan }
  elseif ($nick isop $chan && $1 === !OFF) { bot_stop }
  else { bot_stop | .timerBOTSTART 1 1800 bot_start $unsafe($chan) }
}
alias -l bot_start {
  bs say $1 Va beh...nessuno parla allora parlo io...
  rand_msg $1 | .timerRANDMSG 0 60 rand_msg $unsafe($1)
}
alias -l bot_stop { .timerBOTSTART off | .timerRANDMSG off }
alias -l rand_msg {
  var %colors 2,3,4,5,6,7,8,9,10,11,12,13
  var %rc $gettok(%colors,$rand(1,$numtok(%colors,44)),44)
  bs say $1 $+(,%rc,$read(addons\miefrasibot\frasibot.txt,nt),)
}

You can add (separated by commas) or remove the desired colors in the variable value: var %colors 2,3,4,5,6,7,8,9,10,11,12,13


🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Epic #272474 05/03/24 08:07 AM
Joined: Jul 2006
Posts: 4,182
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,182
Quote
In this script there is no external influence and no transmission of any text data from outside by other users that this code could use, except for the user file that the author creates independently at his own responsibility. The passed identifiers $chan and $1 are known to the script. Therefore, there was no need to specify the additional $unsafe() identifier.
The event react to #channel, which will at best will be changed to an hardcoded channel, but could very well be changed to # to work on all channels, making you vulnerable as $chan alone can be used for exploit


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Epic #272475 05/03/24 07:56 PM
Joined: May 2022
Posts: 78
F
Fernet Offline OP
Babel fish
OP Offline
Babel fish
F
Joined: May 2022
Posts: 78
Originally Posted by Epic
Originally Posted by Fernet
Last thing: is there a command for random color for a text? I know about ctrl+k and a number can choose 1 color. But is there a combination to set a random color to a text?
I added something to the code so that your random messages from the file will be colored in a random color.

So, after updating, taking into account all the remarks and suggestions, you can try using this script code:
Code
on *:TEXT:*:#channel:{
  if ($nick == ServiceBot) { return }
  if ($nick isop $chan && $1 === !ON) { bot_stop | bot_start $chan }
  elseif ($nick isop $chan && $1 === !OFF) { bot_stop }
  else { bot_stop | .timerBOTSTART 1 1800 bot_start $unsafe($chan) }
}
alias -l bot_start {
  bs say $1 Va beh...nessuno parla allora parlo io...
  rand_msg $1 | .timerRANDMSG 0 60 rand_msg $unsafe($1)
}
alias -l bot_stop { .timerBOTSTART off | .timerRANDMSG off }
alias -l rand_msg {
  var %colors 2,3,4,5,6,7,8,9,10,11,12,13
  var %rc $gettok(%colors,$rand(1,$numtok(%colors,44)),44)
  bs say $1 $+(,%rc,$read(addons\miefrasibot\frasibot.txt,nt),)
}

You can add (separated by commas) or remove the desired colors in the variable value: var %colors 2,3,4,5,6,7,8,9,10,11,12,13

I have 2 Bot, one is miRC 7.65 and one is 6.35. Your update perfectly work on 7.65 but on 6.35 I got this error:
---> -BotServ- Channel isn't registered.
Of course I'm sure I correctly wrote #channel name
Thanks sir

Fernet #272478 06/03/24 07:00 AM
Joined: Jan 2012
Posts: 323
Pan-dimensional mouse
Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 323
I don't know what could be causing this error. Perhaps due to the use in this code of some new functions/methods/identifiers/switches, etc., for example $unsafe(), which have not yet been invented and implemented for mIRC 6.35. Therefore, I strongly recommend that you no longer use such an old version of mIRC and make sure to update mIRC to the latest version. And from now on always use only new versions, because the old version may not only contain similar errors that may prevent the use of new modern scripts, but may also contain vulnerabilities that can be exploited by intruders, young hooligans, newbie "hackers" or experienced scripters and professional coders, who have fallen to the dark side >:-]

You can read and study the full list of updates to see how much has been done and changed since the release of mIRC 6.35: https://www.mirc.com/versions.txt

I tested this script on mIRC v7.75.


🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Fernet #272479 06/03/24 07:58 AM
Joined: Jul 2006
Posts: 4,182
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,182
This is due to $unsafe which is a recent addition, it doesn't exist in 6.35, causing $chan and $1 to be $null.
Running script in 6.35 is a bad idea. The only valid reason for running 6.35 before was to able to use codepage still.
But recently mIRC added support back for codepage, so you can now use codepage on the latest version of mIRC, you have absolutely no reason to be using 6.35, for this reason I won't be giving you a replacement for $unsafe here, but if you have valid (read: you don't) argument as to why you're still using 6.35, I'll give you the replacement.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Epic #272480 06/03/24 02:26 PM
Joined: May 2022
Posts: 78
F
Fernet Offline OP
Babel fish
OP Offline
Babel fish
F
Joined: May 2022
Posts: 78
Originally Posted by Epic
I don't know what could be causing this error. Perhaps due to the use in this code of some new functions/methods/identifiers/switches, etc., for example $unsafe(), which have not yet been invented and implemented for mIRC 6.35. Therefore, I strongly recommend that you no longer use such an old version of mIRC and make sure to update mIRC to the latest version. And from now on always use only new versions, because the old version may not only contain similar errors that may prevent the use of new modern scripts, but may also contain vulnerabilities that can be exploited by intruders, young hooligans, newbie "hackers" or experienced scripters and professional coders, who have fallen to the dark side >:-]

You can read and study the full list of updates to see how much has been done and changed since the release of mIRC 6.35: https://www.mirc.com/versions.txt

I tested this script on mIRC v7.75.

Ok. I changed with 7.75. It was the problem, old version. Everything perfectly work. Thanks to both Epic & Wims. And sorry. So if I want the new Bot to talk as Fernet and not the BotService, (its nick on Mindforge is Fernet), I only need to change Controllore with Fernet?
Thanks

Last edited by Fernet; 06/03/24 04:48 PM.
Fernet #272481 06/03/24 06:15 PM
Joined: Jan 2012
Posts: 323
Pan-dimensional mouse
Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 323
Originally Posted by Fernet
So if I want the new Bot to talk as Fernet and not the BotService, (its nick on Mindforge is Fernet), I only need to change Controllore with Fernet?
Obviously, when you use the "BotServ" command, you are controlling a service bot that you have access to and that is pinned and located on your channel under a nickname that is known to you. I can’t know exactly what teams and what bot nicknames are on this network, because I'm not there. In the script, you need to change "ServiceBot" to the nickname of the service bot that is currently present on your channel. If you want to kick out this bot and invite another bot with a different nickname, then in the script you will also need to specify a different nickname for the service bot on the channel so that the script does not react to its messages and does not start a timer with a delay.


🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Epic #272483 07/03/24 07:36 AM
Joined: May 2022
Posts: 78
F
Fernet Offline OP
Babel fish
OP Offline
Babel fish
F
Joined: May 2022
Posts: 78
Originally Posted by Epic
Originally Posted by Fernet
So if I want the new Bot to talk as Fernet and not the BotService, (its nick on Mindforge is Fernet), I only need to change Controllore with Fernet?
Obviously, when you use the "BotServ" command, you are controlling a service bot that you have access to and that is pinned and located on your channel under a nickname that is known to you. I can’t know exactly what teams and what bot nicknames are on this network, because I'm not there. In the script, you need to change "ServiceBot" to the nickname of the service bot that is currently present on your channel. If you want to kick out this bot and invite another bot with a different nickname, then in the script you will also need to specify a different nickname for the service bot on the channel so that the script does not react to its messages and does not start a timer with a delay.

I won't use a ServiceBot. I set a script named FERNET with 7.75 and so, I wish to speak with that nick. As You suggested "Hmm... It’s not very clear why you use the Service Bot to send messages to the channel instead of your mIRC Bot doing it directly, because this complicates everything."
That's what I did:

Code
on *:TEXT:*:#mychannel:{
  if ($nick == $me) { return }
  if ($nick isop $chan && $1 === !ON) { bot_stop | bot_start $chan }
  elseif ($nick isop $chan && $1 === !OFF) { bot_stop }
  else { bot_stop | .timerBOTSTART 1 600 bot_start $unsafe($chan) }
}
alias -l bot_start {
  /echo $chan  Va beh...nessuno parla allora parlo io...
  rand_msg $chan | .timerRANDMSG 0 600 rand_msg $unsafe($1)
}
alias -l bot_stop { .timerBOTSTART off | .timerRANDMSG off }
alias -l rand_msg {
  var %colors 2,3,4,5,6,7,8,9,10,11,12,13
  var %rc $gettok(%colors,$rand(1,$numtok(%colors,44)),44)
  /echo $chan  $+(,%rc,$read(addons\miefrasibot\frasibot.txt,nt),)

Fernet #272484 07/03/24 08:52 AM
Joined: Jan 2012
Posts: 323
Pan-dimensional mouse
Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 323
If you want the script to send messages not through the service bot, but directly through the mIRC bot, then change 2 lines in the code with the commands "bs say" to "msg".

After the change, the code script will look like this:
Code
on *:TEXT:*:#channel:{
  if ($nick == ServiceBot) { return }
  if ($nick isop $chan && $1 === !ON) { bot_stop | bot_start $chan }
  elseif ($nick isop $chan && $1 === !OFF) { bot_stop }
  else { bot_stop | .timerBOTSTART 1 1800 bot_start $unsafe($chan) }
}
alias -l bot_start {
  msg $1 Va beh...nessuno parla allora parlo io...
  rand_msg $1 | .timerRANDMSG 0 60 rand_msg $unsafe($1)
}
alias -l bot_stop { .timerBOTSTART off | .timerRANDMSG off }
alias -l rand_msg {
  var %colors 2,3,4,5,6,7,8,9,10,11,12,13
  var %rc $gettok(%colors,$rand(1,$numtok(%colors,44)),44)
  msg $1 $+(,%rc,$read(addons\miefrasibot\frasibot.txt,nt),)
}


🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Page 1 of 2 1 2

Link Copied to Clipboard