mod_admin.py

Sun, 02 Aug 2015 17:15:00 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Sun, 02 Aug 2015 17:15:00 +0300
changeset 144
b3d1b356e544
parent 121
ac07779f788d
child 146
c17b82b1f573
permissions
-rw-r--r--

- Remove hgapi dependence
- Limit the amount of commits being pulled in so that if there's a lot of them the bot won't time out
- If a changeset in e.g. sandbox gets pulled to main, it needs to be processed again or it won't get announced.
- Use hg cat instead of hg revert to get the contents of version.h to find out the Zandronum version without changing any files

from modulecore import command_error
import sys

ModuleData = {
	'commands':
	[
		{
			'name': 'raw',
			'description': 'Sends a raw message to the server',
			'args': '<message...>',
			'level': 'admin',
		},

		{
			'name': 'msg',
			'description': 'Sends a message to someone',
			'args': '<recipient> <message...>',
			'level': 'admin',
		},

		{
			'name': 'restart',
			'description': 'Restarts the bot',
			'args': None,
			'level': 'admin',
		},

		{
			'name': 'die',
			'description': 'Shuts the bot down',
			'args': None,
			'level': 'admin',
		},

		{
			'name': 'modreload',
			'description': 'Reloads a module',
			'args': '<module>',
			'level': 'admin',
		},
	]
}

def cmd_raw (bot, args, **rest):
	bot.write (args['message'])

def cmd_msg (bot, args, **rest):
	bot.privmsg (args['recipient'], args['message'])

def cmd_restart (bot, **rest):
	bot.restart()

def cmd_die (bot, **rest):
	quit()

def cmd_modreload (bot, args, **rest):
	reload (sys.modules[args['module']])

mercurial