Custom Command Adding and Deleting Script

By Lozo on Mar 10, 2014

The following script is used on the RCD Radio RoBo Bot, but has been edited down for a user version to be shared around and used.

Intended use for Ustream.tv users but can be used on any network.

A script to add to a bot to easily add and delete custom commands to a bot, like twitter and facebook links to share information within a channel, instead of adding commands manually to a script, this script helps you maintain, quickly and easily add/delete/change information commands.

Only channel ops can add and delete commands, anyone can use them in a channel, this script can be edited by anyone as they see fit.

How to use.

Turning on the script:
To add a command you must first turn on the script for the channel by typing BOTNAME cadd on - BOTNAME being the name of the bot with the loaded script.

Adding Commands:
To add a command, type: !cadd TRIGGER OUTPUT HERE

For example, if you want to add !twitter, you type !cadd twitter My Twitter Can be Found at http://twitter.com/lozocn

So then when you type !twitter - It will say My Twitter Can be Found at http://twitter.com/lozocn Triggers are automatically added with the ! and are not to be included when adding and deleting commands.

Deleting Commands:
To delete a command, type !cdel TRIGGER So for example, to delete !twitter, type !cdel twitter The command !twitter will then be deleted.

Viewing Commands:
To view all custom added commands, type !cmd in the channel and you will get a PM with all available commands.

Turning off the script:
To turn off the script for a channel, type BOTNAME cadd off When you turn it off for a channel, commands are kept on file and are not deleted, so when you turn it back on, you can continue to use them, the only way to remove commands is by using the !cdel command.

Finding Commands for the script in Bot Help:
To view the help commands within the bot, type BOTNAME cadd help and the bot will send you a PM with all the commands for this script.

If you have any problems or questions about this script, leave me a comment, I would also like some feedback on the script, if you find any bugs, leave them in the comments and if you find any bug fixes for the script, feel free to leave them in the comments as well, I never share my scripts, so this is the first time I am doing it really, I hope you find this useful.

;===================================================
; Custom Commands Add/Delete/Listings (CADD.ini) - Version 1.6
; Written by Lozo <Twitter: http://twitter.com/LozoCN >
;                       <Facebook: http://facebook.com/DJLozoCN >
;                       <Site: http://lozocn.com >
;                       <Email: http://lozocn.com/contact >
;===================================================
; Script Contribution from: Scootz
;===================================================
; The following script is used on the RCD Radio RoBo Bot, but has been
; edited down for a user version to be shared around and used.
; Intended use for Ustream.tv users but can be used on any network.
;===================================================
; A script to add to a bot to easily add and delete custom
; commands to a bot, like twitter and facebook links to share
; information within a channel, instead of adding commands
; manually to a script, this script helps you maintain, quickly and
; easily add/delete/change information commands.
;===================================================
; Only channel ops can add and delete commands, anyone can
; use them in a channel, this script can be edited by anyone as
; they see fit.
;
; To add a command you must first turn on the script for the
; channel by typing BOTNAME cadd on - BOTNAME being the
; name of the bot with the loaded script.
; To add a command, type !cadd TRIGGER OUTPUT HERE
;
; For example, if you want to add !twitter, you type
; !cadd twitter My Twitter Can be Found at http://twitter.com/lozocn
; So then when you type !twitter - It will say
; My Twitter Can be Found at http://twitter.com/lozocn
; Triggers are automatically added with the ! and are not to be included
; when adding and deleting commands.
;
; To delete a command, type !cdel TRIGGER
; So for example, to delete !twitter, type !cdel twitter
; The command !twitter will then be deleted.
;
; To view all custom added commands, type !cmd in the channel
; and you will get a PM with all available commands.
;
; To turn off the script for a channel, type BOTNAME cadd off
; When you turn it off for a channel, commands are kept on file and
; are not deleted, so when you turn it back on, you can continue to
; use them, the only way to remove commands is by using the !cdel
; command.
;
; To view the help commands within the bot, type BOTNAME cadd help
; and the bot will send you a PM with all the commands for this script.
;===================================================

; Feel free to edit below but do it at your own risk.

on *:TEXT:$($me cadd *):#: {
  if ($nick isop $chan) {
    if ($3 == on) {
      if (%CADD.On. [ $+ [ $network ] ] [ $+ [ . ] ] [ $+ [ $chan ] ] == $null) {
        set %CADD.On. [ $+ [ $network ] ] [ $+ [ . ] ] [ $+ [ $chan ] ] 1
        msg $chan Adding and Deleting Commands Script has been turned on for $chan on $network $+ .
      }
      else {
        msg $chan Adding and Deleting Commands Script is already turned on for $chan on $network $+ .
      }
    }
    if ($3 == off) {
      if (%CADD.On. [ $+ [ $network ] ] [ $+ [ . ] ] [ $+ [ $chan ] ] != $null) {
        unset %CADD.On. [ $+ [ $network ] ] [ $+ [ . ] ] [ $+ [ $chan ] ]
        msg $chan Adding and Deleting Commands Script has been turned off for $chan on $network $+ . - However, Custom added Commands for the channel have not been deleted.
      }
      else {
        msg $chan Adding and Deleting Commands Script is already turned off for $chan on $network $+ .
      }
    }
  }
  if ($3 == help) {
    msg $chan Help Commands for the Custom Command Adding/Deleting Script have been sent to $nick in a query.
    msg $nick === Commands for Adding and Removing Custom Commands
    msg $nick == $me cadd on = Turns the Script On for the channel on the network. (Ops Only)
    msg $nick == $me cadd off = Turns the Script Off for the channel on the network. (Ops Only)
    msg $nick == !cadd <COMMAND> <OUTPUT HERE> = Adds a Custom Command for the channel. (Ops Only)
    msg $nick == Note: Don't include the ! when you are typing in a command.
    msg $nick == !cdel <COMMAND> = Deletes a Custom Command for the channel. (Ops Only)
    msg $nick == Note: Don't include the ! when you are typing in a command.
    msg $nick == !cmd = Lists all available custom commands for the channel.
    msg $nick == End Help List
  }
}

on *:TEXT:!cmd:#: {
  if (%CADD.On. [ $+ [ $network ] ] [ $+ [ . ] ] [ $+ [ $chan ] ] != $null) {
    var %command_file = rcdradio_commands.ini
    var %k = $+($network,-,$chan)
    var %x = $ini(%command_file,%k,0)     
    var %kk = ''

    if (%x) { 
      msg $chan Sending a query of all available Customized Commands to $nick for $chan on $network $+ .
      msg $nick == Customized Command List for $chan on $network
      while (%x) {
        %kk = $ini(%command_file,%k,%x)
        msg $nick = ! $+ %kk => $readini(%command_file,n,%k,%kk)
        dec %x
      }
      msg $nick == End of Custom Command List
    } 
    else { 
      msg $chan Sorry $nick $+ , No custom commands available.
    }
  }
}

on *:TEXT:!cadd *:#:{
  if (%CADD.On. [ $+ [ $network ] ] [ $+ [ . ] ] [ $+ [ $chan ] ] != $null) {
    if ($nick isop $chan) {
      var %command_file = rcdradio_commands.ini
      var %k = $+($network,-,$chan)

      writeini %command_file %k $2 $3-
      msg $chan The Command ! $+ $2 has been added to $chan on $network  
    }
  }
}

on *:TEXT:!cdel *:#:{
  if (%CADD.On. [ $+ [ $network ] ] [ $+ [ . ] ] [ $+ [ $chan ] ] != $null) {
    if ($nick isop $chan) {
      var %command_file = rcdradio_commands.ini
      var %k = $+($network,-,$chan)

      if ($ini(%command_file,%k,$2) >= 1) {
        remini %command_file %k $2
        msg $chan The command ! $+ $2 has been found in $chan on $network and has been deleted.
      } 
      else { 
        msg $chan Sorry, command ! $+ $2 could not be found.
      }
    }
  }
}

on $*:TEXT:m/\!.*/iS:#:{
  if (%CADD.On. [ $+ [ $network ] ] [ $+ [ . ] ] [ $+ [ $chan ] ] != $null) {
    var %command_file = rcdradio_commands.ini
    var %cmd = $mid($1,2)

    if ($me == $nick) {
      halt 
    }

    var %k = $+($network,-,$chan)
    var %t = $readini(%command_file,n,%k,%cmd)

    if ($len(%t)) { 
      msg # %t
    }
  }
}

Comments

Sign in to comment.
alishakihn   -  Jun 01, 2023

Please contact the support team, they will be able to help you with the problem

 Respond  
Ironshaper   -  Dec 22, 2016

I wold never guess to use this script for http://twitter.com thank you, it's working.

 Respond  
perrymasterson   -  Oct 06, 2016

I'd like to express gratitude on the behalf of the whole http://writemyessaytoday.net/ team! We managed to help one of our customers only thanks to your code after our professionals gain insight into it.

George78  -  Jun 08, 2022

I recently found a fairly easy way to turn in essays and get an "A" on them without any effort. You see, I, like many students, find such assignments quite difficult. That's why I found from which I order various assignments. This greatly simplifies the situation, because I do not have to give up walking and going to the movies with friends to write an assignment, because I can just order it in such places.

Sign in to comment

Nathanael   -  Nov 01, 2015

How do you automatically add a cooldown for each command that is created and where would I put the script?

 Respond  
swimsphinx   -  Apr 23, 2015

Hi Lozo, first off thank you so much for posting this, not only does it work amazingly but it also helped me learn alot about how to structure things in mIRC. I don't know if you check this page but if you do a response would be great :). I see in the description that the program auto prepends a "!" to any added command is there anyway to turn this off/ make it not work for specific commands? ex: i want to add a command that will respond whenever a person types a word "hi" for instance but not "!hi" im pretty new to coding so i can't really figure out where the prepending occurs. Any pointers?

Lozo  -  Apr 24, 2015

Hey

I'm really behind on responding to questions on this code, but you did ask a excellent question which I am able to help you with.

First off, this bit of code

on $*:TEXT:m/\!.*/iS:#:{

Needs to be replaced with

on $*:TEXT:*:#:{

Then, where you see this bit of code on the event I told you to edit above

        var %cmd = $mid($1,2)

Replace that with

        var %cmd = $mid($1,1)

This will make all commands work simply by typing the command name without a ! or anything before it.

Let me know if this worked
Lozo

Lozo  -  Apr 24, 2015

I should add, changing this won't change any of the help messages that say things like 'the command !help has been added' - The command will still work as 'help' and not '!help' when you make the changes I have suggested.

swimsphinx  -  Apr 24, 2015

Thanks a ton! for the response works like a charm. i figured out the first bit on my own while tinkering around but couldn't get the second part, this cleared it up quite well. thank you :)

Sign in to comment

westpanda   -  Dec 06, 2014

Anyone have a idea how to add flood Protection to this ?

I tried this code :

{
on $*:text:/^!(\S+)/:#:{
if ((%floodcom) || ($($+(%,floodcom.,$2),2))) { return }
set -u10 %floodcom On
set -u30 %floodcom. $+ $nick On
if ($readini(rcdradio_commands.ini,n,#,$regml(1))) msg # $v1
}

Paper0rPlastic  -  Dec 09, 2014
    if ($len(%t)) { 
      if ((%floodcom. [ $+ [ $chan ] ]) || ($($+(%,floodcom. [ $+ [ $chan ] ] $+ .,$nick),2))) { return }
      set -u10 %floodcom. [ $+ [ $chan ] ] On
      set -u30 %floodcom. [ $+ [ $chan ] ] $+ . $+ $nick On
      msg # %t
    }
  }
}
westpanda  -  Dec 12, 2014

Thank you <3

Sign in to comment

donpot   -  Sep 05, 2014

well the script work for me and awesome! THANKS! anyway when you do the !cmd command, you get all the commands, but is there away so instead it write evry single command + their value in each msg, then it just show all the commands in one msg?

Lozo  -  Sep 08, 2014

You could try making it so it sets a varible with all the commands then posts that varible to the user...

Example:
Instead of msg $nick - Replace it with var %p = ! $+ %kk => $readini(%command_file,n,%k,%kk) ==

Then, instead of msg $nick == End of Custom Command List - Replace that with, msg $nick %p

I think this may be the best way of doing it, let me know how you get on and if you need any help, reply to this comment.

Thank you and I am glad you like it.

donpot  -  Sep 09, 2014

well its sorta works xD i have 2 picturs. First one is before the changes: http://imgur.com/bRyHOQ4,2RSIz8O#1 and this one after the changes: http://imgur.com/bRyHOQ4,2RSIz8O#0 as you can se after the changes it does what i want it to do. but its only telling me about 1 command and not all of them now this is a pictur from my code, how i think you want me to change it to: http://imgur.com/N5zLV5Y

Paper0rPlastic  -  Sep 19, 2014

Just strip out the !cmd section above and replace it with this. Works like you wanted.

on *:TEXT:!cmd:#: {
if (%CADD.On. [ $+ [ $chan ] ] != $null) {
var %i 1 | while $ini(rcdradio_commands.ini,#,%i) {
var %commands %commands ! $+ $v1
inc %i
}
msg # $iif(%commands,Custom commands: %commands,There are no custom commands for $chan $+ .)
}
}

(Sorry, I don't know how to post code here)

donpot  -  Sep 22, 2014

well it works like i wanted? for me it don't work at all :( i removed the old !cmd section and put yours in, but sadly it does not work now

Paper0rPlastic  -  Sep 22, 2014

Sorry, I forgot I took out part of the if %CADD.On. statement on my script. My apologies. This should work:

on *:TEXT:!cmd:#: {
if (%CADD.On. [ $+ [ $network ] ] [ $+ [ . ] ] [ $+ [ $chan ] ] != $null) {
var %i 1 | while $ini(rcdradio_commands.ini,#,%i) {
var %commands %commands ! $+ $v1
inc %i
}
msg # $iif(%commands,Custom commands: %commands,There are no custom commands for $chan $+ .)
}
}

donpot  -  Sep 23, 2014

well know it works better, it answers me! :D but it tells me no custom commands are there, but there is some custom commands for the stream. any idea? or do you want some screen shots?

Paper0rPlastic  -  Sep 23, 2014

Wow, I need to quit doing this stuff so late at night. Forgot a part. I tested this one and double-checked it. Working. Here ya go.

on *:TEXT:!cmd:#: {
  if (%CADD.On. [ $+ [ $network ] ] [ $+ [ . ] ] [ $+ [ $chan ] ] != $null) {
    var %k = $+($network,-,$chan)
    var %i 1 | while $ini(rcdradio_commands.ini,%k,%i) {
      var %commands %commands ! $+ $v1
      inc %i
    }
    msg # $iif(%commands,Custom commands: %commands,There are no custom commands for $chan $+ .)
  }
}
donpot  -  Sep 23, 2014

well it works! THANK YOU SO MUCH! and why stop :O its allways funnyer to do it late night instead of in the day xD againt thank you alot for your help :D

Sign in to comment

Paper0rPlastic   -  Sep 02, 2014

This is great. Thank you. I tried adding a command with a $nick in the output, but it just spits out $nick, not the actual nickname. Is this a possibility?
NVM - I found the answer. Working now.

donpot  -  Sep 09, 2014

how did you make it to work?

Paper0rPlastic  -  Sep 12, 2014

At the end where is has: var %t = $readini(%command_file,n,%k,%cmd)
replace that line with: var %t = $readini(%command_file,%k,%cmd)
I just removed n,

twoclipz  -  Sep 13, 2014

Awesome!! Thanks!

Sign in to comment

twoclipz   -  Aug 29, 2014

Has anyone been able to get this working for twitch.tv?
Add/removing commands seem to work well, but listing the commands doesn't work. I know msg users don't work on twitch, but even if I change those to msg chan it still doesn't return anything.

EDIT: a little bit of changes and some timers and it works great!! THANK YOU!!!

 Respond  
lurkerintheshadows   -  Aug 14, 2014

I cannot seem to get this to work - I really want to, because it looks amazing :(

I tried both putting it inside the remote.ini - and by making it a seperate .ini.

Lozo  -  Aug 15, 2014

It looks like you are doing this correctly, you must put this in a blank remote file, nothing else must be in the remote file you paste this in, to avoid it breaking.

Are you getting any errors in the status window? Did you turn on the script first using BOTNAMEHERE cadd on? Make sure you have @ status or greater in the channel for it to work.

lurkerintheshadows  -  Aug 16, 2014

Tried both as a mod and as broadcaster
Yes, the bot is in a blank remote.ini file, No errors visible in the status window :S

  • also, no response to the "botname cadd on"
Lozo  -  Aug 16, 2014

When you type the botname, replace that with the name of the bot with the script on it, so if your bot is called SarahTheBot type SarahTheBot CADD on

Let me know if that works.

lurkerintheshadows  -  Aug 16, 2014

That is exactly what I have been doing, nybotsname cadd on
No response, not even an error to work from.

Sign in to comment

ltpliers   -  Aug 13, 2014

Is there a way to add user levels to specify who can/can't use a specific new generated command? For example, if I wanted to generate a new command to post a picture but only moderators can activate that command rather than anyone in chat? I've started using this script and it works well, but was wondering if there was a way to do that to improve on it.

Lozo  -  Aug 15, 2014

You could, but you would need to manually program this in the script on the event on line 142, with a if ($1 == !command) && ($nick isop $chan)

That could work, but I have not tested it, I shall look in to adding to make it so that users can decide which commands can be performed by who.

ltpliers  -  Aug 16, 2014

Would be greatly appreciated :) I would love to see something like that definitely implemented.

Atomicfirepit  -  Jun 18, 2015

I hate to reactivate such an old post but has this been implemented? This would be one of the best things for bigger channels. love the script have been using it for ages.

Lozo  -  Jun 18, 2015

Sorry, my work load outside of scripting has increased, but this scripting project has not gone forgotten, it is unknown when this will be done, I will post a update here as soon as its available, there are some new features coming to the next release of this script which I have worked on but not yet perfected.

Thank you for bringing this up.

Sign in to comment

EE128   -  Jul 10, 2014

Love this script, the only problem I've run into is deleting one command. I created the command "+128"
"+" is my prefix. But ever time I try to delete it I'm told it doesn't exist. Is it because the command is a number?

Lozo  -  Jul 10, 2014

Thank you for bringing this bug to my attention, I will try create and debug the problem later or tonight or over the weekend.

Glad you love the script! XD

EE128  -  Jul 10, 2014

Thanks! Out of curiosity, what causes this problem? Just in case I run into something like it in the future.

Lozo  -  Jul 10, 2014

I'm not entirely sure, I have not had a look yet, not had the chance to look in to it yet, I will let you know of my findings once I have them.

Lozo  -  Jul 10, 2014

I have found the bug and I am not quite sure what is causing it, I will try and patch a fix over the next few days and make a update, it seems to be a problem when deleting commands containing only numbers or a prefix like + and numbers.

I have a older version of the script on my RoBo bot which this script was taken and re configured from and has no problem deleting numbers, so its a bit odd.

Thanks for bringing this bug to my attention EE128.

EE128  -  Jul 11, 2014

Oh and while I'm thinking of it, (This is more of a request) would a "!cadd test Test the " be possible? Like "!test userinput" >> "Test the userinput"

Meta  -  Aug 15, 2014

EE128, yes - it is indeed because your command is a number; Specifically, in the context of $ini(%command_file,%k,$2), where $2 is +128, mIRC sees +128 as equivalent to 128, and thus tries to find the 128th item in the section rather than an item called "+128"

Try changing this line: (line 131)

if ($ini(%command_file,%k,$2) >= 1) {

To this:

if ($readini(%command_file,n,%k,$2) != $null) {
Lozo  -  Aug 15, 2014

Thank you Meta, I shall see if I can include this in the next version if it works well for the script, I have still not found a good solution for the numbers add, but I am still looking in to it, its a bit of a funny one, at the moment, I am having to remove them manually through the .ini output file. (rcdradio_commands.ini)

Sign in to comment

Lozo   -  Mar 21, 2014

New Update
Version 1.6
Minor Bug Fixes.

 Respond  
gamewar   -  Mar 20, 2014

@Lozo

I meant something like this:

!allow -> username -> Allows a user to post a link.

i.e: Gamewar: !allow Lozo

Bot: Gamewar -> Lozo has been granted permission to post a link.

Lozo  -  Mar 20, 2014

I had to look at your account to see what the hell you were on about, I don't take script requests and I don't share my scripts unless I have one to share, sorry I am of no help with this.

Sign in to comment

Lokiramos   -  Mar 20, 2014

This code looks really well put together, but I cant seem to get it to initialize?
Do I need to create a separate ini file for the commands to be stored in?

Lozo  -  Mar 20, 2014

The ini file creates itself if it does not exist in the first place, what are you typing when you add a command?

Lokiramos  -  Mar 20, 2014

I am typing mybotsname cadd on
followed by !cadd Twitter http://www.twitter.com/lokiramos

Lozo  -  Mar 20, 2014

Is the bot confirming that the script is then turned on? it should say its been turned on for that specific channel on that specific network.

Then when you type !twitter, you get the output of http://www.twitter.com/lokiramos right?

Lokiramos  -  Mar 20, 2014

that's the thing, the bot doesn't confirm the script is turned on at all, that's where Im stuck

Lozo  -  Mar 20, 2014

Firstly, you are typing where it says BOTNAME in my instructions, the actual name of the bot right? so if your bot with the loaded script is called Blonk, you type 'Blonk cadd on' without the ''

Second, you have full op (@) privileges in the channel?

Third, you did load this script in to a new remote file away from all other scripts? don't load it with any other script on your bot, this can cause a break.

Lokiramos  -  Mar 20, 2014

Putting it into its own blank file appears to have made the difference
thank you very much :) I look forward to making use of this!

Lozo  -  Mar 20, 2014

No Problem at all! Do enjoy!

Sign in to comment

gamewar   -  Mar 19, 2014

Thank you very much @Lozo for this script had been looking something like this gives us more things.

PS: Do have the Script "!allow"? That allows users to post a link for a certain time.

Lozo  -  Mar 20, 2014

No Problem! I am glad you like it!

What do you mean by a !allow command? can you please elaborate with as much detail as you can so that I understand what you mean.

Sign in to comment

hommy   -  Mar 16, 2014

I made an account just for this Script. This is Amazing and extremely helpful! Now i don't have to add all of the commands, and since several of my friends share my bot, they don't have to worry about common commands such as !Facebook or !twitter being used already, this saves me alot of time and it's just all around useful. Thank you, very much!

Lozo  -  Mar 16, 2014

No problem! I am very glad you found this helpful, I looked on Hawkee before posting this script and it was lacking in this sort of area, so I posted it! Enjoy!

Sign in to comment

Truk   -  Mar 12, 2014

This is a great script! I was manually doing this for mods on one of my chats and this will do it for you in a matter of seconds. Sweet script Lozo!

Lozo  -  Mar 12, 2014

YAY! First comment on my public shared script! Thank you very much, glad you like it and find it useful! Let me know if you have any bug findings or anything you want me to work on or add.

Truk  -  Jul 16, 2015

Lozo I have a glitch for you. I have a command ep and when someone in chat says "yep ! " w/o quotes or "yep i understand!" it will fire the !ep command. not sure what or why - i have not had time to look at this closely but wanted to let you know. I THINK this has happened with other commands but cant say for sure.

amour  -  Jun 14, 2017

Avec une robe de soirée bordeaux sur http://www.jmrouge.fr/, vous pouvez être sûr de se démarquer dans soirée.

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.