mIRC Homepage
Posted By: OrionsBelt Message host - 08/10/06 09:16 AM
I have the following problem.

I want my bot to message me, when it receives a private message.

Code:
on *:TEXT:*:?:{
  .msg mynick 05PRIVATE MESSAGE from $nick $+ : $1-
}


That works fine, but not when I change my nick.
To mynick|afk or whatever....

Is this also possible to do on hostmask or something?
Or does anyone have a solution for this?
Posted By: NineTails Re: Message host - 08/10/06 09:47 AM
Make it simple: message your bot your new nickname when you change it and let him store it in some variable and then use it. That will work in all cases.
Posted By: OrionsBelt Re: Message host - 08/10/06 10:03 AM
Hmm, yeah that will work.
Neat idea. Thx a lot!
Posted By: Riamus2 Re: Message host - 08/10/06 04:04 PM
You can also use an on nick event on your bot to watch for when you change your nick and then change the variable based on that. Of course, when you join the channel, it will still have your last-used nick, which could be different from the one you're currently using, and that can make it not work until you change your nick to the last-used nick or reset the variable in the bot.

Perhaps the best method would be to give the bot all possible nicks you'll use and then have it check if (nick ison #) with each nick. If it's on the channel, it will message you. This also makes it so the bot doesn't get an error if you aren't connected.
Posted By: OrionsBelt Re: Message host - 08/10/06 04:29 PM
Thx for that Riamus.
I indead used the on Nick event for it.
I've been testing it a little, and it seems to be working fine.

Regarding the joining of a channel. I already have my main nick always returning to default using a scripted on start and on exit. So I just added a line, to also reset the variable back to my default nick. This way it should always match.

And, I will always be online if my bot is online. It's just a copy of mIRC, it will never run without my main client being connected as well.

Thx for the advices though.
Posted By: Lpfix5 Re: Message host - 08/10/06 08:55 PM
Actually, if your nick is always static like your showing me like the mynick and mynick|AFK this is easily fixable if you never change part of the nick

on *:TEXT:*:?:if mynick isin $nick msg $nick msghere

the isin will check that if mynick isin the nick that messages you then it will message because because it found a match

:P
Posted By: OrionsBelt Re: Message host - 08/10/06 09:06 PM
Hmm yeah you're right.
But it's almost always like that, not always, always... smile

I'm gonna settle for the current solution. It seems waterproof to me. But also thx for thinking along laugh
Posted By: RusselB Re: Message host - 08/10/06 09:53 PM
You could use your original code, just replacing mynick with $me
Posted By: OrionsBelt Re: Message host - 08/10/06 09:55 PM
Then it would message itself (the bot) instead of me laugh
Posted By: RusselB Re: Message host - 08/10/06 10:09 PM
right..sorry..wasn't thinking straight.
Posted By: MikeChat Re: Message host - 09/10/06 03:59 AM
you could at some point set a var in the bot with your nick
you could then have an on:nick event that checks if $nick == %thevar set %thevar $newnick
Posted By: deegee Re: Message host - 09/10/06 04:05 AM
If both clients are on the same PC he could use DDE and never have to worry about nicks wink
No need for levels, nicks, hosts, vars, servers. All it requires is for DDEserver to be turned on on the main client only. The bot doesnt even need it's DDE server on

for ex.
Code:
; For the bot
on ^*:open:?:{
  dde [color:green]mIRC[/color] command "" /botmsg 05PRIVATE MESSAGE from $nick $+ : $1-
  halt
}
;Swap "[color:green]mIRC[/color]" for your actual DDEserver name, on the main client

Code:
; For the Main client
alias botmsg {
  var %a = [color:blue]botnick[/color]
  if !$query(%a) { query -n %a }
   echo -itlbfmr %a  $+(<,%a,>) $1-
}
Swap "[color:blue]botnick[/color]" for the bots nick. :)
Posted By: Lpfix5 Re: Message host - 09/10/06 04:39 AM
even a specific user leve that if your host = user level 30 and you set the

ON 30:TEXT:*:?:{ stuff }
Posted By: sdamon Re: Message host - 10/10/06 08:06 AM
this seams to work a little better, and with some modification, this can be used to run multiple bots, should you have more than 1. (simply add $me to message someware)

Bot side
Code:
on *:text:*:?:{
  dde mIRC command "" /botmsg  $+ $color(normal) $+  $network $+ $chr(58) $+ $nick $+ $chr(58) $1-
  halt
}
on *:action:*:?:{
  dde mIRC command "" /botmsg  $+ $color(action) $+ $network $+ $chr(58) $+ $nick $+ $chr(58) $1-
  halt
} 

Main client side
Code:
alias botmsg {
  if !$window(@bot) { window -azk0 @Bot }
  echo -itlbfmr @Bot $1-
}
© mIRC Discussion Forums