Get Help

Custom Command Adding and Deleting Script

Share and find mIRC Scripts that are useful on Ustream Chat.
Forum rules
Please take a moment to read the rules before sharing any scripts or replying to any posts in this forum.

Custom Command Adding and Deleting Script

Postby Lozo » Sun Mar 09, 2014 10:10 am

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.

Code:

Code: Select all
;===================================================
; Custom Commands Add/Delete/Listings (CADD.ini) - Version 1.5
; 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,%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
    }
  }
}
Lawrence Newberry (Lozo & LozoCN)
Ustream Volunteer Senior HelpOp

http://twitter.com/lozocn
http://lozocn.com

Other Links
facebook.com/djlozocn
rcdradio.com

Ustream Broadcast Channel
ustream.tv/channel/rcdradio
Ustream IRC Channel: #Dotcomboy17
User avatar
Lozo
Senior HelpOp
Senior HelpOp
 
Posts: 65
Joined: Fri May 14, 2010 4:13 am
Location: United Kingdom

Sponsored Links

Postby Sponsored Links » Fri Aug 27, 2004 12:01 am


Sponsored Links
VP of Marketing
 
Posts: 10100
Joined: Fri Aug 27, 2004 12:01 am
Location: Mountain View, CA

Return to mIRC Scripts

Who is online

Users browsing this forum: No registered users and 1 guest