mIRC Home    About    Download    Register    News    Help

Print Thread
#238050 26/06/12 06:24 AM
Joined: Apr 2012
Posts: 16
M
medoit Offline OP
Pikka bird
OP Offline
Pikka bird
M
Joined: Apr 2012
Posts: 16
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.

medoit #238052 26/06/12 05:33 PM
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
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
}

medoit #238053 26/06/12 07:15 PM
Joined: Apr 2012
Posts: 16
M
medoit Offline OP
Pikka bird
OP Offline
Pikka bird
M
Joined: Apr 2012
Posts: 16
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?

medoit #238054 26/06/12 08:19 PM
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
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.

Last edited by Loki12583; 26/06/12 08:34 PM.
Loki12583 #238055 26/06/12 08:43 PM
Joined: Apr 2012
Posts: 16
M
medoit Offline OP
Pikka bird
OP Offline
Pikka bird
M
Joined: Apr 2012
Posts: 16
okay thank you very much, and I couldnt use existing code as i didnt have any xD but I appreciate your help smile


Link Copied to Clipboard