mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Apr 2015
Posts: 8
F
FRAG_B Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
F
Joined: Apr 2015
Posts: 8
Hi, I have a few scripts that I'd like to have running as much as possible in my IRC channel. The problem is currently that they're only running when my computer and mIRC is on. I'd like to increase the time they're running by letting other regular users have them too, although then they might interfere. When the script reacts to a certain type of message and there are x users with that script online, there would be x reactions to that message when there should only be one.

To get to the point, I want to make sure only one of the users' script is actually running at each moment. I don't know if it's possible to create some sort of 'public' variable in a channel that every user (eventually from a certain level) can consult and change, so when someone starts running the script it changes to '1' and when nobody's running the script it changes to '0'. The condition for a user who logs on to start running the script would be that the variable equals 0.

Simply checking if any of the other users who have the script is online isn't a solution, cause some of them have a 'ghost' on our channel which makes them appear online 24/7, even though they're not really there (and thus their script wouldn't be activated).

I also thought of letting the script send a PM to those other users when it's activated, and based on whether there's a response (an automatic response would be in the other users' scripts) or not, the script would start running. This would also allow one user to know if anyone else's script is already running or not. However, this doesn't seem like a very elegant solution cause all the names of the users with the script would need to be in everyone's script and there would be a lot of PM spam which isn't very nice if the actual human users want to PM eachother.

Thanks for reading, I'd greatly appreciate it if anyone knows any solutions for this problem.

Joined: Sep 2011
Posts: 32
F
Ameglian cow
Offline
Ameglian cow
F
Joined: Sep 2011
Posts: 32
I'm assuming that this is in the nature of a chatbot/servicebot, rather than just some scripts that run "behind" your own nick that you're using for general chatting.

The way I would do this is to check specifically if the script is running. My first inclination in that direction would be to have something like

Code:
ctcp *:ISMYBOT:*:/ctcpreply $nick BOTHERE Running as $me
ctcp *:BOTHERE:*:/dontrun


in the remotes section, and when the bot starts up, have it send

Code:
/ctcp #botchannel ISMYBOT


to see if there are any other copies running - if there are, they'll reply with a BOTHERE, and the current copy will put itself into a "don't-run" status (based on the code that you put into the alias "dontrun").

This isn't perfect; it doesn't handle such cases as the currently active bot leaving (all other copies remain in the don't-run state) or selecting which other idle copy (if there are multiple ones) should take over operation in such a case. It does, however, adjust for ghosts (a ghost won't reply to the CTCP).

(Note: You can change the "ISMYBOT" and "BOTHERE" ctcp messages to whatever you want; the more likely it is to be unique to your bot, the better.)

Joined: Apr 2015
Posts: 8
F
FRAG_B Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
F
Joined: Apr 2015
Posts: 8
Thanks for your help, I'm gonna try it some time soon. I'm curious if there's anyone else with possible solutions though, anyone?


Link Copied to Clipboard