mIRC Home    About    Download    Register    News    Help

Print Thread
#234025 01/10/11 03:08 PM
Joined: Oct 2011
Posts: 2
M
Bowl of petunias
OP Offline
Bowl of petunias
M
Joined: Oct 2011
Posts: 2
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

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
/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.


Invision Support
#Invision on irc.irchighway.net
Joined: Oct 2011
Posts: 2
M
Bowl of petunias
OP Offline
Bowl of petunias
M
Joined: Oct 2011
Posts: 2
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.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.


Invision Support
#Invision on irc.irchighway.net
Joined: Jul 2006
Posts: 4,150
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,150
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.



#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Wims #234035 01/10/11 11:11 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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
:)=(。◕‿◕。)



Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard