!kill command for Twitch bot

By Jc_el_unico on Apr 21, 2014

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? }
}

Comments

Sign in to comment.
Scy   -  Apr 21, 2014

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

Scy  -  Apr 21, 2014

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. }
}

Nos  -  Apr 23, 2014
on *:TEXT:*:#:{
  if ($regex($1,/^!buzzkill\b/iS)) {
    if ($nick isop $chan) {
      part $chan
    }
    else {
      msg $chan you must be an op to use this command.
    }
  }
} 

or

on *:TEXT:*:#:{
  if ($strip($1) == !buzzkill) {
    if ($nick isop $chan) {
      part $chan
    }
    else {
      msg $chan you must be an op to use this command.
    }
  }
} 
Yawhatnever  -  Apr 24, 2014

@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.

Nos  -  Apr 24, 2014
if ($strip($regex(...))) { 

or

if ($regex($strip(...))) { 

@Yawhatnever results remain the same

Yawhatnever  -  Apr 24, 2014

@Nos that's my point, $strip() does nothing there.

Nos  -  Apr 24, 2014

Image

Sign in to comment

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.