|
Joined: May 2022
Posts: 84
Babel fish
|
OP
Babel fish
Joined: May 2022
Posts: 84 |
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
|
|
|
|
Joined: Jan 2012
Posts: 329
Pan-dimensional mouse
|
Pan-dimensional mouse
Joined: Jan 2012
Posts: 329 |
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:
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_startCommand to stop the timer: /timer_stopScreenshot with an example of sending a message every 10 secs:
|
|
|
|
Joined: May 2022
Posts: 84
Babel fish
|
OP
Babel fish
Joined: May 2022
Posts: 84 |
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:
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_startCommand to stop the timer: /timer_stopScreenshot with an example of sending a message every 10 secs: 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
|
|
|
|
Joined: May 2022
Posts: 84
Babel fish
|
OP
Babel fish
Joined: May 2022
Posts: 84 |
Is almost perfect sir !!! That's what I made (I asked about it also in another topic): 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.
|
|
|
|
Joined: Jan 2012
Posts: 329
Pan-dimensional mouse
|
Pan-dimensional mouse
Joined: Jan 2012
Posts: 329 |
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:
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.
|
|
|
|
Joined: Jul 2006
Posts: 4,188
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,188 |
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
|
|
|
|
Joined: May 2022
Posts: 84
Babel fish
|
OP
Babel fish
Joined: May 2022
Posts: 84 |
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:
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
|
|
|
|
Joined: May 2022
Posts: 84
Babel fish
|
OP
Babel fish
Joined: May 2022
Posts: 84 |
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
|
|
|
|
Joined: Jul 2006
Posts: 4,188
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,188 |
My post was adressed to Epic, not to you Fernet 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
|
|
|
|
Joined: May 2022
Posts: 84
Babel fish
|
OP
Babel fish
Joined: May 2022
Posts: 84 |
My post was adressed to Epic, not to you Fernet 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
|
|
|
|
Joined: Jan 2012
Posts: 329
Pan-dimensional mouse
|
Pan-dimensional mouse
Joined: Jan 2012
Posts: 329 |
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 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.
|
|
|
|
Joined: Jan 2012
Posts: 329
Pan-dimensional mouse
|
Pan-dimensional mouse
Joined: Jan 2012
Posts: 329 |
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:
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
|
|
|
|
Joined: Jul 2006
Posts: 4,188
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,188 |
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
|
|
|
|
Joined: May 2022
Posts: 84
Babel fish
|
OP
Babel fish
Joined: May 2022
Posts: 84 |
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:
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,13I 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
|
|
|
|
Joined: Jan 2012
Posts: 329
Pan-dimensional mouse
|
Pan-dimensional mouse
Joined: Jan 2012
Posts: 329 |
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.txtI tested this script on mIRC v7.75.
|
|
|
|
Joined: Jul 2006
Posts: 4,188
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,188 |
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
|
|
|
|
Joined: May 2022
Posts: 84
Babel fish
|
OP
Babel fish
Joined: May 2022
Posts: 84 |
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.txtI 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.
|
|
|
|
Joined: Jan 2012
Posts: 329
Pan-dimensional mouse
|
Pan-dimensional mouse
Joined: Jan 2012
Posts: 329 |
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.
|
|
|
|
Joined: May 2022
Posts: 84
Babel fish
|
OP
Babel fish
Joined: May 2022
Posts: 84 |
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:
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),)
|
|
|
|
Joined: Jan 2012
Posts: 329
Pan-dimensional mouse
|
Pan-dimensional mouse
Joined: Jan 2012
Posts: 329 |
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:
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),)
}
|
|
|
|
|