mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Sep 2013
Posts: 61
E
Babel fish
OP Offline
Babel fish
E
Joined: Sep 2013
Posts: 61
So, I've been re-coding my bot, and have been working to add custom commands into the bot from the chat. This works, which is a good thing, however, the command !cmd pulls and reads the .ini file.

This is not a bad thing, as the whisper system works, but... It pulls each line individually.

Below is the code behind it:
Quote:
on *:TEXT:!cmd:#: {
if (%CADD.On. [ $+ [ $network ] ] [ $+ [ . ] ] [ $+ [ $chan ] ] != $null) {
var %command_file = rcdradio_commands.ini
var %k = $+($network,-,$chan)
var %x = $ini(%command_file,%k,0)
var %kk = ''

if (%x) {
.msg # .w $nick == Customized Command List for channel: $capital2($chan) $+ ..
while (%x) {
%kk = $ini(%command_file,%k,%x)
.msg # .w $nick = ! $+ %kk => $readini(%command_file,n,%k,%kk)
dec %x
}
}
.msg # .w $nick == End of Custom Command List
else {
msg $chan I'm sorry $capital($nick) $+ , there are no custom commands currently available.
}
}
}


And this is the output:
Quote:

== Customized Command List for channel: #Eggfriedcheese..
= !test3 => test
= !test2 => test
= !test => /me is testing the command add
== End of Custom Command List


I need this command to display everything as one long list, with separators, based on the worry that the Twitch Shadow Ban System kicks into effect.

If anyone has any ideas, be grateful to hear them!

Thanks
Eggy <3


Twitch Live-Streamer:
Synth Riders
Beat Saber
www.twitch.tv/eggfriedcheese
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
If by long list you mean showing everything in 1 line so you don't get flagged as a spammer, you can clear a variable, then build it again to contain the list of commands. In effect, you're doing something the first line when you could instead do the 2nd:

Code:
//var %i 10 |             while (%i isnum 1-10) { echo -a command $rand(0,9)              | dec %i }
//var %i 10 | var %text | while (%i isnum 1-10) { var %text %text command $rand(0,9) $(|) | dec %i } | echo -a $gettok(%text,1-,124)



The $gettok() at the end is for stripping the trailing separator after the last command.

There's a limit to how long a line can be, but as long as your list isn't too long, you won't have to worry about chopping it into several lines.

Joined: Sep 2013
Posts: 61
E
Babel fish
OP Offline
Babel fish
E
Joined: Sep 2013
Posts: 61
So, the command list, works across channels. Would that still only pull up to the end of the command list per channel, or would that display the whole text file?

If it would display everything, that's not an issue, but I just wanted to know how it could distinguish between the different lines.

At the moment, this is the content of the commands file:

Quote:
[-#eggfriedcheese]
test=/me is testing the command add
test2=test
test3=test


So each channel, would have that first separator, and then the commands run underneath this.


Twitch Live-Streamer:
Synth Riders
Beat Saber
www.twitch.tv/eggfriedcheese
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
The way you're doing it, with %k being the name of the [section] and %x being the number of items within that [section], it's displaying only the items within that [section]. The only way it would pull from other groups would be if you used $ini(commandfile,0) to identify the total number of [sections] and grabbed from other [sections] besides the one named after the current channel.

Joined: Sep 2013
Posts: 61
E
Babel fish
OP Offline
Babel fish
E
Joined: Sep 2013
Posts: 61
When I've tried to integrate %i into the command, it now only whispers the first line, and doesn't pull anything now from the document. frown


Twitch Live-Streamer:
Synth Riders
Beat Saber
www.twitch.tv/eggfriedcheese
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
I wasn't saying to literally use %i, i was giving an example of now to change your existing code. The section where you have:

Code:
while (%x) {
  %kk = $ini(%command_file,%k,%x)
  .msg # .w $nick = ! $+ %kk => $readini(%command_file,n,%k,%kk)
  dec %x
}


... would change to build the list of commands into a single line, then displays the line afterwards:

Code:
var %text
while (%x) {
  %kk = $ini(%command_file,%k,%x)
  var %text %text ! $+ %kk => $readini(%command_file,n,%k,%kk) $(|)
  dec %x
}  
  .msg # .w $nick = %text


Joined: Sep 2013
Posts: 61
E
Babel fish
OP Offline
Babel fish
E
Joined: Sep 2013
Posts: 61
You're a star. Many Thanks <3 smile


Twitch Live-Streamer:
Synth Riders
Beat Saber
www.twitch.tv/eggfriedcheese
Joined: Sep 2013
Posts: 61
E
Babel fish
OP Offline
Babel fish
E
Joined: Sep 2013
Posts: 61
Okay, Sorry for bumping this, but now, I've come up with an issue.

So, The last piece of coding, allowed it to all be in one line, however, now twitch has implemented a maximum whisper message length, which is now posting the remainder of the text box as a standard message in the channel instead. This isn't great.

Is there a way, to set the code up, to post "x" number of characters, then start a new message, with the next "x" number of characters?

This is the way the code is in the bot right now for reading the text file:

Quote:

alias capital return $upper($left($1,1)) $+ $mid($1,2-)
alias capital2 return $upper($left($1,2)) $+ $mid($1,3-)

on *:TEXT:!cmd:#: {
if (%CADD.On. [ $+ [ $network ] ] [ $+ [ . ] ] [ $+ [ $chan ] ] != $null) {
var %command_file = rcdradio_commands.ini
var %k = $+($network,-,$chan)
var %x = $ini(%command_file,%k,0)
var %kk = ''

if (%x) {
.msg # .w $nick == Customized Command List for channel: $capital2($chan) $+ ...
var %text
while (%x) {
%kk = $ini(%command_file,%k,%x)
var %text %text ! $+ %kk => $readini(%command_file,n,%k,%kk) $(|)
dec %x
}
.msg # .w $nick = %text
}
}
.msg # .w $nick == End of Custom Command List
else {
msg $chan I'm sorry $capital($nick) $+ , there are no custom commands currently available.
}
}


Twitch Live-Streamer:
Synth Riders
Beat Saber
www.twitch.tv/eggfriedcheese
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Your code will be easier to read if you wrap it inside the "code" keyword instead of using "quote". On a side note, the line where you set the local var %k to a string of 2 apostrophes is not needed, as you are immediately redefining it. If you really did need to make it be blank, you would just use 2 double-quotes instead - or better yet just put nothing behind %kk or else use $null.

The part that needs to change is your while-loop where you slowly build your %text string and the immediate next line is displaying the entire contents of that string. Instead, it will need to check the length each time before it adds the next string. If it's too long, it displays the prior contents of %text then makes that variable blank. Then it does like before, adding the new contents to the %text which is going to safely be below the limit. I didn't test this, but it should work:

old:

Code:
while (%x) {
%kk = $ini(%command_file,%k,%x)
var %text %text ! $+ %kk => $readini(%command_file,n,%k,%kk) $(|)
dec %x
} 
.msg # .w $nick = %text


new:

Code:
      while (%x) {
        %kk = $ini(%command_file,%k,%x)
        var %temp $readini(%command_file,n,%k,%kk)
        if ( $len(%text ! $+ %kk => %temp $(|) ) ) > 99 {
          .msg # .w $nick = %text | var %text
        }
        var %text %text ! $+ %kk => %temp $(|)
        dec %x
      }
      .msg # .w $nick = %text



Additional work may be needed regarding the max message length. Above I arbitrarily used 99, and you can change it to whatever the unstated length will be. I don't use twitch, but I suspect the true limit is not just the visible part of the message, but includes other strings such as the server name or the nick sending or receiving the whisper or the #channelname. You might need to calculate the allowed length each time, based on the current values each time someone uses !cmd.

Joined: Sep 2013
Posts: 61
E
Babel fish
OP Offline
Babel fish
E
Joined: Sep 2013
Posts: 61
Okay, I think it's working in practice, however, I need to slow down the responses lol. It's throwing a bitch-fit every time I use the command:

Quote:
[19:32] -tmi.twitch.tv:#eggfriedcheese- You are sending whispers too fast. Try again in a second.


It doesn't help the bot still isn't verified, to avoid the whisper spam alerts yet.

I'll see what I can do, to input a delay, but if you have any suggestions, feel free smile

-Eggy


Twitch Live-Streamer:
Synth Riders
Beat Saber
www.twitch.tv/eggfriedcheese
Joined: Sep 2013
Posts: 61
E
Babel fish
OP Offline
Babel fish
E
Joined: Sep 2013
Posts: 61
Okay, forget that, it's not working as intended now.

The bot is just spamming the whispers now, and it tries to post the command as a mIRC program command now, rather than text:

Quote:
[19:50] EGGDISCORD Unknown command
-
[19:50] DEADMOUSE Unknown command


This is how it's appearing in whispers:

Quote:

= !knightbad => /me is embarrassed at how actually bad Knight is at video games. | !eggdiscord => You can also join Egg's discord at: https://discord.gg/jW5MXhB - Share the love! <3 | !deadmouse => /me is cringing along with Deadmouse46, at the skill shown by KnightISO |
= !knightbad => /me is embarrassed at how actually bad Knight is at video games. | !eggdiscord => You can also join Egg's discord at: https://discord.gg/jW5MXhB - Share the love! <3 | !deadmouse => /me is cringing along with Deadmouse46, at the skill shown by KnightISO | !knightsucks => Knight Sucks so hard... even the blowjobs are impressive |
== End of Custom Command List


I added the timer to delay the second part, but it seems to be not recognising it.


Twitch Live-Streamer:
Synth Riders
Beat Saber
www.twitch.tv/eggfriedcheese
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
I'm wondering if twitch also changed something so that the pipe-symbol is now being treated as the separator between 2 commands. Try changing the $(|) to use a different character to separate your commands. The closest I could see immediately would be ¦ from $chr(166) in place of $(|).

You need to be careful about using timers, as they will evaluate any word beginning with "$" as if it's an identifier. Probably a better solution would be to make a window named @Que then put your messages there instead of putting them into a timer command, then you can make an alias whose only job is to check the @Que window for any messages needing to be displayed to channel, then display them, then put themselves on a timer again if there are still remaining lines to be displayed. This way you can delay messages so they won't be flooded too quickly. My example uses a 5 second delay between Que messages. The Que window could be shared by other scripts, all they need to do is put "aline Que" in front of the message command, then call Que when they're done adding lines to the script, and Que will display the messages on a first-come/first-served basis.

Code:
alias capital return $upper($left($1,1)) $+ $mid($1,2-)
alias capital2 return $upper($left($1,2)) $+ $mid($1,3-)

on *:TEXT:!cmd:#: {
  if (%CADD.On. [ $+ [ $network ] ] [ $+ [ . ] ] [ $+ [ $chan ] ] != $null) {
    var %command_file = rcdradio_commands.ini
    var %k = $+($network,-,$chan)
    var %x = $ini(%command_file,%k,0) 
    if (!$window(@Que)) window -h @Que

    if (%x) { 
      aline @Que .msg # .w $nick == Customized Command List for channel: $capital2($chan) $+ ...
      var %text
      while (%x) {
        %kk = $ini(%command_file,%k,%x)
        var %temp $readini(%command_file,n,%k,%kk)
        if ( $len(%text ! $+ %kk => %temp $chr(166) ) >= 99) {
          aline @Que .msg # .w $nick = %text
          var %text
        }
        var %text %text ! $+ %kk => %temp $chr(166)
        dec %x
      }
      aline @Que .msg # .w $nick = %text
    }
  }
  aline @Que .msg # .w $nick == End of Custom Command List
  else {
    msg $chan I'm sorry $capital($nick) $+ , there are no custom commands currently available.
  }
  QUE
}
alias Que {
  var %que $line(@que,1)
  dline @que 1
  if (%que != $null) %que 
  if ($line(@que,1) == $null) return
  .timerQue 1 5 Que
}

Joined: Sep 2013
Posts: 61
E
Babel fish
OP Offline
Babel fish
E
Joined: Sep 2013
Posts: 61
That works really well, at 250 characters, with a delay of 2 seconds. That's amazing. Honestly, I'm not great with mIRC / C++ coding, and I'm actually doing an Unreal Games Dev course, that codes in C++ so maybe pick up some things I can use within mIRC for the bot.

I honestly appreciate all the help you've given. I know you've practically written it for me, and for that, Thank you.

I never knew you could even open a new "window" for that sort of thing, so even I've learnt something new today smile

Plus, it looks badass laugh


Twitch Live-Streamer:
Synth Riders
Beat Saber
www.twitch.tv/eggfriedcheese

Link Copied to Clipboard