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
}
}
}
I wold never guess to use this script for http://twitter.com thank you, it's working.
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.
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?
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
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.
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
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)
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 $+ .)
}
}
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 $+ .)
}
}
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!!!
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.
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.
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.
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, 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) {
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)
I am typing mybotsname cadd on
followed by !cadd Twitter http://www.twitter.com/lokiramos
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?
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.
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 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.
Avec une robe de soirée bordeaux sur http://www.jmrouge.fr/, vous pouvez être sûr de se démarquer dans soirée.
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.