As part of my ongoing
server hacking, I've come across the need to be able to do things that can't be done with just aliases and scripts. So I am going to try and create an RCON Bot.
The idea is that the bot would sit and listen to the server's output, issuing commands as a response to certain events. A short example might look like:
-z- has turned mkzelda into slag
<Server> mkzelda will make good bullets *pour*
Has anyone tried something like this before? Or is rcon2irc the only example of something close to this?
rcon2irc is most likely all you'll find but you probably want to describe that further b/c I dont think its obvious that you're making the server do something (like turn my corpse into an ammo box) other than spit out text (in which case you could edit the output directly of course).
rcon2irc is most likely all you'll find but you probably want to describe that further b/c I dont think its obvious that you're making the server do something (like turn my corpse into an ammo box) other than spit out text (in which case you could edit the output directly of course).
That sounds like an interesting idea. I'll have to look into that.
(The turning-corpses-into-ammo.)
But yeah. The idea is to make the server do things that would otherwise require source edits/recompilation (which I despise because of the maintenance headaches it creates).
The idea is:
- Bot reads server's console output (using log_dest_udp)
- Bot does processing
- Bot sends commands server (using rcon)
So when things like kill sprees, bonus pickups, flag grabs, etc happen, the server (triggered by the bot) can do things like change fullbright, change game modes, kill players, give/take points, whatever there's commands to do. Things like "Player has nex - enable player fullbright" or "Team is ahead by 500%, end match early" or "Player found the secret key, go to the next level now".
I'll be sure to post the eventual bot.
This sounds like a really interesting project. You should hang out with us on IRC :).
Ok, I've put what I've got (only a stub, really) into my
subversion.
At this point, it's only an rcon implementation in python on top of twisted.
Wow, I impress myself sometimes.
The rcon implementation is entirely usable, with NexRcon having the higher-level functionality.
I've stubbed-out the high-level bot framework, which will be implemented soon.
ZOMG! It works!
[/over excitement]
The bot module is now implemented. Callbacks and simple commands work.
Because of the way commands are implemented, there's lots of caveats. The docstrings should describe them all. Short list:
- No more than 9 arguments
- Quoted strings don't work (eg `mycommand "foo bar"` fails) [edit]FIXED![/edit]
- The literals "$0", "$1", etc can not be passed alone (eg, `mycommand $$1` will be parsed as `mycommand`)
As more/better commands to handle this are added to Nexuiz, hopefully this list will get shorter.
PS- My apologies for my site running so slow
I've attached the current version of the rconbot code. (It's revision 86 in subversion.) Hopefully, someone else knows python well enough to be able to know what to do with it. (It's a package based on twisted.internet which makes use of python 2.5.)
The actual bot in use on my server is now in my
downloads. Specifically, the code is
modebot.py.
What it currently does:
- The "make good bullets" line
- Greets players when they connect
- Changes game types (automatically as well as on command)
- Has a command "spam" which just prints the arguments passed to the bot's console
eh, so how does one implement this? o_O