mIRC Homepage
Posted By: medoit topic bot - 26/06/12 06:24 AM
So i've never really messed with a bot the does topics, so this is a pretty big challenge for me. basically I play a game online that uses mirc to communicate and one of the main things is organised crimes. so this is the setup I want

Topic: LE: (name) EE: (name) WE1: (name) etc for all 8 positions and the city they are located in

I would like the commands to be like !Leader (name) and it will insert the name into the LE: slot. I would like a command for each position and the city, but im not sure how to get the topic to keep the previous names :s

it would be great to get a command that clears it all out when im done too if at all possible.
Posted By: Loki12583 Re: topic bot - 26/06/12 05:33 PM
These are the only things in the topic? There are many caveats which could affect this implementation. The following will replace the text after the given tag, if the tag is not in the topic it will append it.

Code:
on *:text:!leader *:#:topic # $$game.topic(LE,$2-)
on *:text:!ee *:#:topic # $$game.topic(EE,$2-)
on *:text:!we1 *:#:topic # $$game.topic(WE1,$2-)
on *:text:!clear:#:.raw topic # :

alias game.topic {
  var %tag = $1, %value = $2-, %topic = $chan(#).topic
  var %regex = /(?<= $+ %tag $+ : )(?:.+?(?= \S+:)|.+$)/i
  if ($regex(%topic,%regex)) {
    return $regsubex(%topic,%regex,%value)
  }
  else return %topic %tag $+ : %value
}
Posted By: medoit Re: topic bot - 26/06/12 07:15 PM
what I was trying to do was have it set variables for the different positions. but I have come to find out that if i have it like this "on *:TEXT:!le *:#channelname { set %mocle $2
timer -m 1 10 topic #channelname City: %moccity | Le: %mocle | etc" then it will change the topic but it stops at the city because i have nothing listed there. is there a way to counteract that?
Posted By: Loki12583 Re: topic bot - 26/06/12 08:19 PM
That command is stopping at the city because you're using the | character, which is used to separate commands. You can use $chr(124) to provide the literal | in your topic.

If you'd like more help, please be specific, include existing code, and make sure the formatting you provide as an example actually is what you want/in use.

Timers can be used to run arbitrary commands, and so using a timer without first sanitizing the input can compromise your system. Since the timer you're using only has a 10ms delay, I would suggest not using the timer at all.
Posted By: medoit Re: topic bot - 26/06/12 08:43 PM
okay thank you very much, and I couldnt use existing code as i didnt have any xD but I appreciate your help smile
© mIRC Discussion Forums