mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Nov 2014
Posts: 8
S
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Nov 2014
Posts: 8
So i have a !addcom,!editcom and !delcom but theres a problem..

It adds it to every channel and i want it so the channels its on have there own commands

Heres my code:
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 added to the database!
  }
}
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 deleted from the database!
  }
}
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 updated!
  }
}
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  | return }
    msg $chan $iif(-ul=mod == $gettok(%com,1,32),$gettok(%com,2-,32),$gettok(%com,1-,32))
  }
}


Hope someone can help me

Joined: Jun 2014
Posts: 248
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Jun 2014
Posts: 248
Just use a dynamic file name that includes the channel.

Joined: Nov 2014
Posts: 8
S
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Nov 2014
Posts: 8
Originally Posted By: Belhifet
Just use a dynamic file name that includes the channel.


I'm not the best at mIRC so just telling what to add dosent help me much, Sorry i'm still a noob at this stuff.

Joined: Nov 2014
Posts: 8
S
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Nov 2014
Posts: 8
Cause i'm making a semi-public type of bot, On twitch.

And that's a problem that all the commands are stored on the same file and i can't really find a way to make them have there own.

Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
If you're making a public type of bot, aren't you supposed to make it yourself then?
Here's your issue, you (read the script creator) are using a global textfile for your commands called commands.txt, this is used on your * text event in all channels. So how about you think for a second how to fix this and then return with your idea. I'm sure it won't be too hard to reach a solution.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Nov 2014
Posts: 8
S
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Nov 2014
Posts: 8
Like i said i really don't know much about mIRC so just telling me stuff won't really help..

But i guess i'll just have to look around for a way.


Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
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 added to the database!
  }
}
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 deleted from the database!
  }
}
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 updated!
  }
}
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  | return }
    msg $chan $iif(-ul=mod == $gettok(%com,1,32),$gettok(%com,2-,32),$gettok(%com,1-,32))
  }
}


This is very basic, all I did was rename the file from commands.txt to # $+ commands.txt which will create a new .txt file for each channel. (Which is exactly what Belhifet suggested)

To be able to make a script you need 2 things:
Knowledge in the language
An idea

You can get the first one from reading the help files: type "/help" in mIRC as well as on this website.
The idea part, well, that's entirely up to you. Can't really help you there.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Jan 2015
Posts: 40
J
Ameglian cow
Offline
Ameglian cow
J
Joined: Jan 2015
Posts: 40
I like this quite a bit.

Is there a way to make it so commands are not case sensitive?

Ex: if I make a command !test, but accidentally send !Test, it will not work.

Joined: Jan 2015
Posts: 40
J
Ameglian cow
Offline
Ameglian cow
J
Joined: Jan 2015
Posts: 40
Well ignore my previous post, as it appears I am an idiot. I was fooled by my own flood prevention.

Originally Posted By: jimieo
I like this quite a bit.

Is there a way to make it so commands are not case sensitive?

Ex: if I make a command !test, but accidentally send !Test, it will not work.

Joined: Jan 2015
Posts: 40
J
Ameglian cow
Offline
Ameglian cow
J
Joined: Jan 2015
Posts: 40
I've modified this script a bit more to include flood protection and the option for public, moderator, regular, and owner only commands.

The only issue I am having right now is for the public commands.

Right now I have to include a -ul=all for public. If that is not included, the command fails

ex: !addcom !test this is a test
When using !test it doesn't work (obviously because I left out the -ul=all)

I've been trying to make it so the -ul=all is not required. So if someone forgets to add it, the command will still work. Would someone mind pointing me in the right direction?


Code:
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)) && ($mod($nick)) {
      if ($($+(%,flood,$1),2)) || ($($+(%,flood,$1,.,$nick),2)) { return }
      set -u5 $+(%,flood,$1) On
      set -u5 $+(%,flood,$1,.,$nick)
      if ($2 ison #) {
        msg $chan $2 $+ : $iif(-ul=mod == $gettok(%com,1,32),$gettok(%com,2-,32),$gettok(%com,1-,32))
      }
      else {
        msg $chan $iif(-ul=mod == $gettok(%com,1,32),$gettok(%com,2-,32),$gettok(%com,1-,32))
      }
    }
    elseif (-ul=reg == $gettok(%com,1,32)) && (($mod($nick)) || ($regular($nick))) {
      if ($($+(%,flood,$1),2)) || ($($+(%,flood,$1,.,$nick),2)) { return }
      set -u5 $+(%,flood,$1) On
      set -u5 $+(%,flood,$1,.,$nick)
      if ($2 ison #) {
        msg $chan $2 $+ : $iif(-ul=reg == $gettok(%com,1,32),$gettok(%com,2-,32),$gettok(%com,1-,32))
      }
      else {
        msg $chan $iif(-ul=reg == $gettok(%com,1,32),$gettok(%com,2-,32),$gettok(%com,1-,32))
      }
    }
    elseif (-ul=own == $gettok(%com,1,32)) && ($nick == jimieo) {
      if ($($+(%,flood,$1),2)) || ($($+(%,flood,$1,.,$nick),2)) { return }
      set -u5 $+(%,flood,$1) On
      set -u5 $+(%,flood,$1,.,$nick)
      msg $chan $iif(-ul=own == $gettok(%com,1,32),$gettok(%com,2-,32),$gettok(%com,1-,32))
    }
    elseif (-ul=all == $gettok(%com,1,32)) {
      if ($($+(%,flood,$1),2)) || ($($+(%,flood,$1,.,$nick),2)) { return }
      set -u5 $+(%,flood,$1) On
      set -u5 $+(%,flood,$1,.,$nick)
      if ($2 ison ) {
        msg $chan $2 $+ : $iif(-ul=all == $gettok(%com,1,32),$gettok(%com,2-,32),$gettok(%com,1-,32))
      }
      else {
        msg $chan $iif(-ul=all == $gettok(%com,1,32),$gettok(%com,2-,32),$gettok(%com,1-,32))
      }
    }        

  }
}


Joined: Sep 2014
Posts: 52
Babel fish
Offline
Babel fish
Joined: Sep 2014
Posts: 52
This should do what you are looking for. Flood protection still needs to be added though.
Code:
ON *:TEXT:*:#: {
  var %owner $right(#,-1)
  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)) && (!$mod($nick)) { msg $chan Sorry $nick $+ , you cannot use this command. | return }
    if (-ul=reg == $gettok(%com,1,32)) && (!$mod($nick)) && (!$regular($nick)) { msg $chan Sorry $nick $+ , you cannot use this command. | return }
    if (-ul=own == $gettok(%com,1,32)) && ($nick != %owner) { msg $chan Sorry $nick $+ , you cannot use this command. | return }
    msg $chan $iif(-ul=mod == $gettok(%com,1,32) || -ul=reg == $gettok(%com,1,32) || -ul=own == $gettok(%com,1,32),$gettok(%com,2-,32),$gettok(%com,1-,32))
  }
}

Joined: Jan 2015
Posts: 40
J
Ameglian cow
Offline
Ameglian cow
J
Joined: Jan 2015
Posts: 40
That should do nicely! Thank you very much.

Joined: Jan 2014
Posts: 107
M
Vogon poet
Offline
Vogon poet
M
Joined: Jan 2014
Posts: 107
Jimieo --

Would you mind posting your final script for this?

(I would like to compare with what I have)

Last edited by Majeye; 13/01/15 04:45 AM.
Joined: Jan 2015
Posts: 40
J
Ameglian cow
Offline
Ameglian cow
J
Joined: Jan 2015
Posts: 40
Here is the final:
Flood protection is included and I've added the ability (thanks to Nillens for showing me an easier way) to tag a user in the command.

ex: A user is asking for the ip of the game server/ts server. You simply do !ip jimieo and your bot will check if I am in your channel and reply "jimieo: iphere."

The addcom, delcom, and editcom are all the same.

As seen above, the cleanup to this script goes to: paper0rplastic. I only removed the messages for unauthorized users.
Code:
ON *:TEXT:*:#jimieotest: {
  var %owner $right(#,-1)
  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)) && (!$mod($nick)) { halt }
    if (-ul=reg == $gettok(%com,1,32)) && (!$mod($nick)) && (!$regular($nick)) { halt }
    if (-ul=own == $gettok(%com,1,32)) && ($nick != %owner) { halt }
    if ($($+(%,flood,$1),2)) || ($($+(%,flood,$1,.,$nick),2)) { return }
    set -u5 $+(%,flood,$1) On
    set -u5 $+(%,flood,$1,.,$nick)
    if ($2 ison #) {
      msg $chan $2 $+ : $iif(-ul=mod == $gettok(%com,1,32) || -ul=reg == $gettok(%com,1,32) || -ul=own == $gettok(%com,1,32),$gettok(%com,2-,32),$gettok(%com,1-,32))
    }
    else {
      msg $chan $iif(-ul=mod == $gettok(%com,1,32) || -ul=reg == $gettok(%com,1,32) || -ul=own == $gettok(%com,1,32),$gettok(%com,2-,32),$gettok(%com,1-,32))
    }  
  }
}

Last edited by jimieo; 13/01/15 09:51 PM.

Link Copied to Clipboard