mIRC Homepage
Posted By: Mattie88 Message Short Cuts - 01/10/11 03:08 PM
I have been using Mirc for a couple of months. My friends seem to have a different version of Mirc so they were not able to help me with this question....

If I do not want to type out a complete message everytime I use it how do I go about setting it up so that I can just type a few letters ?

ie.... If I don't want to type 'Be Right Back' each time I want to use it, can I have it so that I can only type 'brb' and the entire message that I want will be displayed ? Thanks
Posted By: Riamus2 Re: Message Short Cuts - 01/10/11 04:20 PM
/help on input

To allow replacing the text anywhere in a message:
Code:
on *:input:#: {
  var %message = $replacex($1-,brb,Be right back,ty,Thank you,wb,Welcome back)
  msg $chan %message
  halt
}


An alternative if you only want to replace the text if it's the only thing typed:
Code:
on *:input:#: {
  if ($1 == brb) { msg $chan Be right back }
  elseif ($1 == ty) { msg $chan Thank you }
  elseif ($1 == wb) { msg $chan Welcome back }
  halt
}


Yet one more option similar to the first that limits it to only when you type the one thing:
Code:
on *:input:#: {
  if (!$2) {
    var %message = $replacex($1,brb,Be right back,ty,Thank you,wb,Welcome back)
    msg $chan %message
    halt
  }
}


There are a variety of other methods as well, depending on how many "words" you want to add. If you wanted to have hundreds of these, you could set it up in a hash table or INI file to greatly improve the script, for example. But if you're only using 10 or even 20, then these should work fine for what you're doing.

* Be aware that the $replacex() examples will replace any occurrence of the "word" even if it's not by itself. For example, "ty" is common in other words, such as "Capacity". These $replacex() examples would end up changing that to "CapaciThank you", which is obviously not what you'd want. I would recommend not using these examples with "ty" or any other combination of letters that are likely to be in your text. Things like brb and wb are fine. If you want to include the other items, you'll be better off with regex or using example 2.
Posted By: Mattie88 Re: Message Short Cuts - 01/10/11 07:56 PM
Where do I put these commands...or change them ? I'm not sure where to go to. And if I want to create an ini file where do i put it ? Which folder, etc.
Posted By: Riamus2 Re: Message Short Cuts - 01/10/11 08:51 PM
Scripts go in Alt-R under Remotes. Use File > New before pasting.

INI files or any other files can go wherever you want. You will put the path in your script. Most people will put the file in the same place the script is stored.
Posted By: Wims Re: Message Short Cuts - 01/10/11 08:55 PM
The first and third on input event you gave have a serious problem: you are not checking if a command is entered, making a /ns identify command sent as plaintext for example.
Also halting everytime might be not something wanted, usually you halt only when it's needed.

Posted By: Riamus2 Re: Message Short Cuts - 01/10/11 11:11 PM
You're right that I forgot to include the command check in those. I was trying to quickly display some examples and did not fully cover everything that you should do when halting text.

Here's a better example which limits to only using it when the only thing typed is the shortened version (such as brb) without any other text. I can no longer edit my previous post, and those aren't really the easiest ways of doing this anyhow, so just ignore that post.

Code:
on *:input:#: {
  if ($readini(words.ini,Words,$1) && !$2) {
    msg $chan $v1
    halt
  }
}


You can then create an INI file in the the mIRC folder named words.ini and format it like this:

Quote:

[Words]
wb=Welcome back
ty=Thank you
brb=Be right back
:)=(。◕‿◕。)

© mIRC Discussion Forums