Add/remove names to a list

By AnneChoV on Sep 28, 2013

So basically, I wanted to make a command so that moderators can add names to a list of subscribers so that I can make them immune to bans/kicks on twitch chat. However, this code only works with 2 words or more. For example, "!subs add asdf 1" works but "!subs add asdf" does not. I'm not sure what I could do. Any suggestions or fixes would be greatly appreciated! I'm pretty noob at coding ;w; Needed a LOT of help to get this done.

on $*:text:/^!subs\b/Si:*:{
  if ($2 == add) && ($nick isop $chan) {
    if ($3) {
      writeini sub.ini $chan $3-
      msg $chan " $+ $3- $+ " has been added to the list
    }
  }
  if ($2 == remove) && ($nick isop $chan) {
    if ($3) {
      if ($readini(sub.ini,$chan,$3)) {
        remini sub.ini $chan $3-
        msg $chan Removed " $+ $3- $+ " from the list
      }
    }
    else {
      msg $chan That command is not available
    }
  }
  if (!$2) && ($ini(sub.ini,$chan,0)) {
    var %a 1, %z $ini(sub.ini,$chan,0)
    .msg $chan $chan has %z sub(s)
  }
  elseif ($2 == list) && (!$ini(sub.ini,$chan,0)) {
    .msg $chan No subs for $chan $+ 
  }
}

Comments

Sign in to comment.
Ireliavent   -  Oct 02, 2015

You could also automate this process. If you would be interested I'd try to code something for you. :)

 Respond  
KilllerX   -  Oct 01, 2013

on $:text:/^!subs\b/Si::{
if ($nick isop #) {
if ($2 == list) || (!$2) {
if ($ini(sub.ini,$chan,0)) {
var %a 1, %z $ini(sub.ini,$chan,0)
msg # # has %z sub(s)
}
else { msg # No subs for $chan $+ .
}
}
if ($2 == add) {
if (!$3) {
msg # please specify whom to add.
}
else { writeini sub.ini $chan $3 subbed
msg # " $+ $3- $+ " has been added to the list
}
}
if ($2 == remove) {
if (!$3) {
msg # please specify whom to remove.
}
else {
if ($readini(sub.ini,$chan,$3)) {
remini sub.ini $chan $3
msg # Removed " $+ $3 $+ " from the list
}
}
}
}
}

I think this should do what you want. I hope.

KilllerX  -  Oct 01, 2013

What your problem what, is you weren't adding a identifier to the names. Which the ini files calls for one. So when you did the ADSGF 1 the 1, I assume would go as an Identifier.

as ini files appear somewhat as

Subs.ini <- file

Channel
NICK=Identifier

So without that identifier it didn't know how to write it.

AnneChoV  -  Oct 01, 2013

Thank you!! I'll keep this in mind :)

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.