mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: May 2015
Posts: 4
L
Self-satisified door
OP Offline
Self-satisified door
L
Joined: May 2015
Posts: 4
Hi guys, I've really gotten into mIRC scripting the last couple days. I've been writing a chat bot with fairly good success. There's just one issue that I haven't been able to figure out through google or basic programming knowledge. I'm trying to print a message to a channel. Sometimes when using msg $chan <TEXT> to print to the channel I am on, instead of printing to the channel, it prints to my Status window, and the first word is wrapped in asterisks. It's fairly annoying but I assume it only happens when certain conditions are met. The thing is, I don't know what those conditions are. Any help is appreciated.

Joined: Jan 2015
Posts: 168
P
Vogon poet
Offline
Vogon poet
P
Joined: Jan 2015
Posts: 168
Would it be possible for you to show me the code that is doing this? It is possible that you could have missed some things in the code and maybe need an extra set of eyes. I was having this issue as well, but it wasn't a bug, it was just an issue with the code.

Regards,
Powerade661

Joined: May 2015
Posts: 4
L
Self-satisified door
OP Offline
Self-satisified door
L
Joined: May 2015
Posts: 4
Yea sure, it's quite a long script, i'll give you the alias's that are at work here though.

Code:
readLine {
  ;/readLine <file.ini> <section> <topic>
  /allowMessage
  /message $readini($1,$2,$3)
}


Code:
message {
  ;/message <message for bot to type>
  if (( %allowedComments > 0 ) && ( %canMessage == $true ) && ( %storeOpen == $false ))  {
    msg $chan $1-
    dec %allowedComments

    var -g %canMessage $false
    timerAllowMessage 1 2 allowMessage
  }
  elseif ( %storeOpen == $true ) {
    timerAllowMessage off
    msg $chan $1-
  }
  elseif ( %allowedComments <= 0 ) {
    echo -a 4NO MORE COMMENTS ALLOWED
  }
}


and finally

Code:
allowMessage {
  var -g %canMessage $true
}


The issue is when I try to print from readLine.

Joined: May 2015
Posts: 249
Fjord artisan
Offline
Fjord artisan
Joined: May 2015
Posts: 249
Porbably there is no "$chan" identifier avaliable in those ON-event, so your "/msg $chan word1 word2 ..." looks like "/msg word1 word2 ..." and word1 becomes target for msg and is marked with *.
$chan - means channel, where event happens, for example ON-connect have NO $chan.


Dont give a fish - teach to fish!
Joined: May 2015
Posts: 249
Fjord artisan
Offline
Fjord artisan
Joined: May 2015
Posts: 249
As i told, you cant use $chan in aliases and some events (if it is not directly binded to those event). So you need to send $chan to your message-alias "/message $chan text", and inside of alias you can make "var %channel = $1" and use "/msg %channel $2-".


Dont give a fish - teach to fish!
Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
yea, seems like you're using aliases (functions) that don't know what $chan refers to. You need to pass the channel as a parameter like so

Code:
alias do_something { msg $1 Some kind of message }

on *:TEXT:!test:#: { do_something $chan }



Last edited by Sakana; 29/05/15 07:38 AM.
Joined: May 2015
Posts: 4
L
Self-satisified door
OP Offline
Self-satisified door
L
Joined: May 2015
Posts: 4
Okay I think I understand what you mean, so I defined a global variable %chan = #MYCHANNEL, and replaced $chan with it in my message alias. This works, but every the message alias is ran my client beeps twice, but I don't get an error message and everything works as intended. What does the beeping signify?

Joined: May 2015
Posts: 249
Fjord artisan
Offline
Fjord artisan
Joined: May 2015
Posts: 249
Check Alt+O -> Sounds.
And global var is good only if you send messages to one channel. You beter send $chan from events to alias (/message $chan ... ) and reassign this $chan (which will be $1 inside) to %chan.


Dont give a fish - teach to fish!
Joined: May 2015
Posts: 4
L
Self-satisified door
OP Offline
Self-satisified door
L
Joined: May 2015
Posts: 4
Yea I was just using the global var to try out some other options. I did switch it to your suggestion. Thanks for the help.


Link Copied to Clipboard