mIRC Home    About    Download    Register    News    Help

Print Thread
Commands for separate channels (TWITCH) #259404 16/11/16 09:06 AM
Joined: Sep 2014
Posts: 46
S
Spike Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Sep 2014
Posts: 46
I use to run a bot on Twitch that already had this type of script working but I lost that script now but still have the main code but it doesn't work for more then one channel.

(what I mean by this say I was to add a command while in user1's channel I would want it not to work in user2's channel and he would have his own commands and what not)
Code:
ON *:TEXT:!addcom *:#: {
  if ($nick isop #) {
    var %r = $read(commands.txt,ns,$2)
    if (%r) { .msg $chan [ $+ $nick $+ ]: Error, This command $qt($2) is already exist into the database! | return }
    write commands.txt $2-
    msg $chan /me + Command $2 has been created!
  }
}
ON *:TEXT:!delcom *:#: {
  if ($nick isop #) {
    var %r = $read(commands.txt,ns,$2)
    if (!%r) { .msg $chan [ $+ $nick $+ ]: Error, This command $qt($2) does NOT exist into the database! | return }
    write -dl $+ $readn commands.txt
    msg $chan /me - Command $2- has been removed!
  }
}
ON *:TEXT:!editcom & *:#: {
  if ($nick isop #) {
    var %r = $read(commands.txt,ns,$2)
    if (!%r) { .msg $chan [ $+ $nick $+ ]: Error, This command $qt($2) does NOT exist into the database! | return }
    write -l $+ $readn commands.txt $2-
    msg $chan /me -> Command $2 has been edited!
  }
}
ON *:TEXT:*:#: {
  tokenize 32 $strip($1-,burci)
  if ($read(commands.txt, nts, $1)) {
    var %com = $v1
    var %com = $replace(%com,@user@,$iif($2,$2,?),@nick@,$nick,@target@,$target)
    if (-ul=mod == $gettok(%com,1,32)) && ($nick !isop $chan) { msg $chan [ $+ $nick $+ ]: Error, You are NOT an channel operator! | return }
    msg $chan $iif(-ul=mod == $gettok(%com,1,32),$gettok(%com,2-,32),$gettok(%com,1-,32))
  }
}

Re: Commands for separate channels (TWITCH) [Re: Spike] #259405 16/11/16 05:39 PM
Joined: Oct 2016
Posts: 14
F
FoxInABox Offline
Pikka bird
Offline
Pikka bird
F
Joined: Oct 2016
Posts: 14
Use the channel name as a part of the name of the command file, so each channel uses its own command list?

Re: Commands for separate channels (TWITCH) [Re: FoxInABox] #259408 16/11/16 10:32 PM
Joined: Sep 2014
Posts: 46
S
Spike Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Sep 2014
Posts: 46
Originally Posted By: FoxInABox
Use the channel name as a part of the name of the command file, so each channel uses its own command list?


think I got it never remembered how to make spaces in mirc code this is what I was able to do and it seems to do what I need
Code:
ON *:TEXT:!addcom *:#: {
  if ($nick isop #) {
    var %r = $read($chan $+ commands.txt,ns,$2)
    if (%r) { .msg $chan [ $+ $nick $+ ]: Error, This command $qt($2) is already exist into the database! | return }
    write $chan $+ commands.txt $2-
    msg $chan /me + Command $2 has been created!
  }
}
ON *:TEXT:!delcom *:#: {
  if ($nick isop #) {
    var %r = $read($chan $+ commands.txt,ns,$2)
    if (!%r) { .msg $chan [ $+ $nick $+ ]: Error, This command $qt($2) does NOT exist into the database! | return }
    write -dl $+ $readn $chan $+ commands.txt
    msg $chan /me - Command $2- has been removed!
  }
}
ON *:TEXT:!editcom & *:#: {
  if ($nick isop #) {
    var %r = $read($chan $+ commands.txt,ns,$2)
    if (!%r) { .msg $chan [ $+ $nick $+ ]: Error, This command $qt($2) does NOT exist into the database! | return }
    write -l $+ $readn $chan $+ commands.txt $2-
    msg $chan /me -> Command $2 has been edited!
  }
}
ON *:TEXT:*:#: {
  tokenize 32 $strip($1-,burci)
  if ($read($chan $+ commands.txt, nts, $1)) {
    var %com = $v1
    var %com = $replace(%com,@user@,$iif($2,$2,?),@nick@,$nick,@target@,$target)
    if (-ul=mod == $gettok(%com,1,32)) && ($nick !isop $chan) { msg $chan [ $+ $nick $+ ]: Error, You are NOT an channel operator! | return }
    msg $chan $iif(-ul=mod == $gettok(%com,1,32),$gettok(%com,2-,32),$gettok(%com,1-,32))
  }
}