mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Apr 2008
Posts: 5
C
Coheed Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Apr 2008
Posts: 5
can someone please help me out with a script like that? I just need it so when i do like !add something somethinghere then when i do !something my bot will respond with somethinghere. I hope this makes sense.

Thanks in advance
coheed

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Use this code at your own risk. There are many ways in which it could be abused, but in order to counter all of the possibilities, would require an AI level code, which, as has been said before, is beyond the current abilities of mIRC
Code:
on *:text:!add*:?:{
  if !$3 { halt }
  else {    .hadd -m Commands $2 $3-  }
}
on *:text:!*:#:{
  if $hget(Commands,$right($1,-1)) {  $v1  }
}
on *:start:{
  if !$hget(Commands) { .hmake Commands 100 }
  if $exists(Commands.hsh) { .hload Commands Commands.hsh }
}
on *:exit:{
  .hsave Commands Commands.hsh
}

Joined: Apr 2008
Posts: 5
C
Coheed Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Apr 2008
Posts: 5
So i should be able to do !add hi hi!! and then when i type !hi my bot will type !hi!! right?

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Untested, but this should do what you need. As mentioned by RussellB, this has the potential for abuse. This is why I put a level 500 requirement on it. You can really just use whatever level you want and/or have it check to make sure the nick's host is "allowed". You *really* don't want to let just anyone add commands or people can make your bot do just about anything... including format your hard drive. To add someone as level 500 user, you'll want to use: /auser 500 nick!ident@host.com . Keep in mind that you can use wildcards in the address mask if you want to make it more general (such as /auser 500 *!ident@host.com or whatever).

Code:
on *:start: { HashCommands }

on 500:text:!add *:*: {
  if ($3) {
    if (!$hget(Commands)) { HashCommands }
    hadd Commands $2 $3-
    hsave Commands Commands.hsh
  }
}

on *:text:*:#: {
  if ($hget(Commands,$1)) { msg $chan $v1 }
}

alias HashCommands {
  hmake Commands 100
  if ($exists(Commands.hsh)) { hload Commands Commands.hsh }
}


To RussellB, you should avoid saving the hash table on exit. It's better to save it every time a change is made (except if you're changing it constantly and then you should use a timer). If you save only on exit, it won't be saved if you crash. There's also no reason to silence a command that only has output if there's an error (which you usually *want* to see in those cases). Also, just having the bot do "$v1" won't work unless you add actual commands when using !add... it won't send any text by just doing $v1.


Invision Support
#Invision on irc.irchighway.net
Joined: Apr 2008
Posts: 5
C
Coheed Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Apr 2008
Posts: 5
awesome thanks, now what about a delete? Sorry...

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
I have noted that even when my system crashes (or as close to a crash as I can think of, system froze and I had to power down the CPU) the hsh file (which I use by default for hash tables) were saved. Now, I admit I don't know if they were saved due to the ON EXIT event, or if it was the ON DISCONNECT event, as I had /hsave's in both events and those were the only /hsave commands in the script(s).

Regarding having the bot return $v1 rather than having it msg the channel with $v1, which you did, I realized that it wouldn't work directly when I wrote it like that, but it does allow a command to be sent using the action format or using colors, which, I believe, yours would not allow.

As I said, there's just too many possibilities to do this 100% accurately and avoid the abuse potential using mIRC.

To the OP regarding delete
Code:
on 500:text:!add *:*: {
    hdel Commands $2
    hsave Commands Commands.hsh
}

Joined: Apr 2008
Posts: 5
C
Coheed Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Apr 2008
Posts: 5
Thanks so much! Now, if i wanted to add a "what is" command, how would I do that? Sorry, I am a noob at this :P. Thanks for you're guys' help!!

~Coheed

Last edited by Coheed; 28/04/08 05:38 AM.
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
we've already shown you the basics of what you're wanting.

You should open the help file and read the help sections on some of the things we've already mentioned, eg: /help $hget

This forum is supposed to be for helping you write your own script, not having one of us write it for you, especially in bits and pieces.

If you want one written for you, make a list of all of the things that you want in it, then ask for the full thing.

Some of the people here will write full codes, plus there are sites like Hawkee where you can request full scripts/snippets to be written.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Originally Posted By: RusselB
I have noted that even when my system crashes (or as close to a crash as I can think of, system froze and I had to power down the CPU) the hsh file (which I use by default for hash tables) were saved. Now, I admit I don't know if they were saved due to the ON EXIT event, or if it was the ON DISCONNECT event, as I had /hsave's in both events and those were the only /hsave commands in the script(s).

Regarding having the bot return $v1 rather than having it msg the channel with $v1, which you did, I realized that it wouldn't work directly when I wrote it like that, but it does allow a command to be sent using the action format or using colors, which, I believe, yours would not allow.

As I said, there's just too many possibilities to do this 100% accurately and avoid the abuse potential using mIRC.

To the OP regarding delete
Code:
on 500:text:!add *:*: {
    hdel Commands $2
    hsave Commands Commands.hsh
}


If you have the on DISCONNECT, then it will be saved from the last time your disconnected if you crash, but anything between then and the crash will be lost. That's why it's good to save when a change is made.

What I gave can use colors just fine. Why wouldn't it? Colors would be added after the /msg $chan anyhow. As far as performing other kinds of commands, yes, what I gave will just do normal messages. It can be adjusted, but this is what was originally asked for.

Btw, for your delete command, you should change the matchtext. !add isn't a good choice for deleting. wink


Invision Support
#Invision on irc.irchighway.net
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Quote:
Btw, for your delete command, you should change the matchtext. !add isn't a good choice for deleting.
Ooops.. thought I had changed that to !del

Joined: Apr 2008
Posts: 5
C
Coheed Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Apr 2008
Posts: 5
Originally Posted By: RusselB
we've already shown you the basics of what you're wanting.

You should open the help file and read the help sections on some of the things we've already mentioned, eg: /help $hget

This forum is supposed to be for helping you write your own script, not having one of us write it for you, especially in bits and pieces.

If you want one written for you, make a list of all of the things that you want in it, then ask for the full thing.

Some of the people here will write full codes, plus there are sites like Hawkee where you can request full scripts/snippets to be written.


Ok, so I've gotten thus far: I have noticed that I cannot make the "what is" command because if I change the 5th line to be anything with a more than 1 character suffix, it does not work. Can someone help please?

~Coheed


Link Copied to Clipboard