mIRC Home    About    Download    Register    News    Help

Print Thread
C
cooliosis
cooliosis
C
I'm pretty new to mIRC and coding in general. I want the bot to greet a person when they say "hi" (not when they join the channel). Here's a snippet of the script:

on *:text:*hi*:#:{
else { msg # Hello, $nick ! }
}

First of all, how can I add punctuation onto $nick? If I do something like "Hello, $nick !", it kinda bothers me that there's a space between the username and the exclamation point. Is it possible to conjugate the two?
Second, is it possible for the bot to not trigger when the message includes someone else's name? For example, with this, I could say "Hi Bob" but it would still reply "Hello, cooliosis !" Sorry for the really stupid questions.

B
Belhifet
Belhifet
B
String concatenation is performed with the $+ identifier. (Example: $nick $+ !).

You could perform a loop and check if each $nick in the channel is in the text. But this will still get awkward responses.

Here is a cleaned up version of your code.
Code:
on *:text:*hi*:#: { 
  var %i 1
  while (%i <= $0) {
    if ($($+($,%i),2) ison $chan) { halt }    
    inc %i
  }
 msg # Hello, $nick $+ ! 
 }


This replies if *hi* is anywhere in the text.

Last edited by Belhifet; 31/12/14 09:08 AM.

Link Copied to Clipboard