I'm veeery new to scripting in general but I'm trying to write in some code to make my twtich bot "/part" from any channel it is in when certain users with privilege type "!buzzkill". Please help me finish the code. Thanks!
// Command executes /part from current channel.
On *:TEXT:*!buzzkill*:#: {
if ($nick == somenick) { whatdoiputhere? }
}
very simple... i have something like that on my bot actually. I put * instead of # because you can also do it via
/msg yourbotsnick !buzzkill CHAN
on :text:!buzzkill :*: {
if ($nick isop $chan) { part $2 }
elseif ($nick ison $chan) { msg $chan You must be an Op to use this command. }
}
I tested that on my bot and it works:::
(18:07) <~Scy> !deowner
(18:07) Kyrie sets mode: -y Scy
(18:07) !buzzkill #abyss
(18:07) <@Legato> You must be an Op to use this command.
(18:07) !up
(18:07) -Kyrie- Upped successfully on #Abyss.
(18:07) Kyrie sets mode: +yohv Scy Scy Scy Scy
(18:07) <~Scy> !buzzkill #abyss
(18:07) * @Legato (Legato@bots.are.sexy) has left #abyss
@Nos
$regex() returns the number of matches, so using $strip() here:
if ($strip($regex(...)) { }
does nothing because you're essentially using $strip(0) or $strip(1). Perhaps you meant to use $regex($strip(...), ...), but I should point out that it would be redundant since you've specified the regex /S modifier which strips colors/underlines/bold/reverse.
@Scy
While it's true using * instead of # allows the command to be used by querying the bot, you also still use /msg $chan which will be $null if the text event was not used in a channel. You can use
if (#) { }
to check if the command was used a channel, and then from there you can determine if the response should be sent to a channel or back to $nick.
If you wanted it to just part from the channel the command is used on then use this code instead of the first one:::
on *:text:!buzzkill:#: {
if ($nick isop $chan) { part $chan }
elseif ($nick ison $chan) { msg $chan You must be an Op to use this command. }
}