mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2013
Posts: 22
A
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Aug 2013
Posts: 22
HI so I recently trying to figure out a command on my Twitch bot to !addcommand and !delete Command and The !addcom works just fine but the delete is not... I also want to figure out how to edit a Command as well if anyone can help me out that would be great

Code:
on*:text:!addcommand *:#: { 
write commands.txt $2-
}
on*:text:*:#: {
if ($read(commands.txt, ns, $1)) {
 msg $chan $v1
}
}
on *:text:!delcom *:#: {
if ($read(commands.txt, ns, $2)) {
 write -dl $+ $readn commands.txt
}
}

Joined: Oct 2012
Posts: 164
D
Vogon poet
Offline
Vogon poet
D
Joined: Oct 2012
Posts: 164
Move the !delcom code above the * code. Same goes for any other text events you add.
The event catching "*" matches "!delcom" also because * matches everything. Only one matching event from each file can trigger, so if something else matches it first it will never trigger.

Editing a line is as simple as replacing it, use $readn the same as your delcom except without the d switch. Again remember to place it above the "*" event.
Code:
on *:text:!editcom & *:#: {
  if ($read(commands.txt, ns, $2)) {
    write -l $+ $readn commands.txt $2-
  }
}


Joined: Aug 2013
Posts: 22
A
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Aug 2013
Posts: 22
omg you are awesome thanks so much works like a charm!

and Also one more thing I wonder if there a way when you type in !commands it shows all the commands you have on the list... like for a list for people know what commands you have

Last edited by Achievements; 04/12/13 11:32 PM.
Joined: Feb 2003
Posts: 3,432
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
you need to use a if statement if the commands should be listed.
Code:
on *:text:!addcommand *:#: { 
 if ($2 == show) { msg $chan Commands avalible are <enter commands here> | return }
  else {
  write commands.txt $2-
 }
}




if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Joined: Aug 2013
Posts: 22
A
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Aug 2013
Posts: 22
So I did the code. Do i have to enter the commands manually? I wonder if it would just read the list of Commands I already have ...

Joined: Oct 2012
Posts: 164
D
Vogon poet
Offline
Vogon poet
D
Joined: Oct 2012
Posts: 164
It might be easier to just /play the file smile
Code:
on *:text:!commands:#: {
  if ($file(commands.txt)) { .play # commands.txt 2000 }
}

.play # commands.txt 2000
play msgs the file contents one line at a time.
The 2000 refers to milliseconds delay between each line (2000 ms = 2 seconds), you can change that as you wish.

For more options, see "/help /play" (especially the second option that pops up when typing that).

Joined: Aug 2013
Posts: 22
A
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Aug 2013
Posts: 22
oh that helps a lot thanks! is there a way where you can only say the first word on that line then go to the next. for it won't Spam it the whole Commands. instead it would just say !example !Commands !ect

Last edited by Achievements; 06/12/13 02:20 AM.

Link Copied to Clipboard