Mercurial > traipse_dev
comparison plugins/xxcac.py @ 0:4385a7d0efd1 grumpy-goblin
Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
author | sirebral |
---|---|
date | Tue, 14 Jul 2009 16:41:58 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4385a7d0efd1 |
---|---|
1 import os | |
2 import orpg.pluginhandler | |
3 | |
4 class Plugin(orpg.pluginhandler.PluginHandler): | |
5 # Initialization subroutine. | |
6 # | |
7 # !self : instance of self | |
8 # !openrpg : instance of the the base openrpg control | |
9 def __init__(self, plugindb, parent): | |
10 orpg.pluginhandler.PluginHandler.__init__(self, plugindb, parent) | |
11 | |
12 # The Following code should be edited to contain the proper information | |
13 self.name = 'Command Alias Creator' | |
14 self.author = 'Dj Gilcrease' | |
15 self.help = "This plugin lets you add Command Aliases.\neg /sits insted of /me sits down" | |
16 self.newcmdaliases = {} | |
17 | |
18 | |
19 def plugin_enabled(self): | |
20 self.plugin_addcommand('/cmdalias', self.on_cmdalias, '[cmdalias_name fullcommand] [remove cmdalias_name] [clear] - (eg. <font color="#000000">/cmdalias /sits /me sits down</font> to add a command. OR <font color="#000000">/cmdalias remove /sits</font> to remove a single command. OR <font color="#000000">/cmdalias clear</font to clear the entire list)') | |
21 self.newcmdaliases = self.plugindb.GetDict("xxcac", "newcmdaliases", {}) | |
22 | |
23 for n in self.newcmdaliases: | |
24 if not self.shortcmdlist.has_key(n) and not self.cmdlist.has_key(n): | |
25 self.plugin_commandalias(n, self.newcmdaliases[n]) | |
26 | |
27 | |
28 def plugin_disabled(self): | |
29 self.plugin_removecmd('/cmdalias') | |
30 for n in self.newcmdaliases: | |
31 self.plugin_removecmd(n) | |
32 | |
33 def on_cmdalias(self, cmdargs): | |
34 args = cmdargs.split(" ",-1) | |
35 if len(args) == 0: | |
36 self.chat.InfoPost("USAGE: /cmdalias [cmdalias_name fullcommand] [remove cmdalias_name] [clear] - (eg. /sits /me sits down)") | |
37 | |
38 elif args[0] == 'remove': | |
39 if self.newcmdaliases.has_key(args[1]): | |
40 del self.newcmdaliases[args[1]] | |
41 self.plugindb.SetDict("xxcac", "newcmdaliases", self.newcmdaliases) | |
42 self.plugin_removecmd(args[1]) | |
43 elif args[0] == 'clear': | |
44 for n in self.newcmdaliases: | |
45 self.plugin_removecmd(n) | |
46 self.newcmdaliases = {} | |
47 self.plugindb.SetDict("xxcac", "newcmdaliases", self.newcmdaliases) | |
48 else: | |
49 oldcmd = cmdargs[len(args[0])+1:] | |
50 self.newcmdaliases[args[0]] = oldcmd | |
51 self.plugindb.SetDict("xxcac", "newcmdaliases", self.newcmdaliases) | |
52 self.plugin_commandalias(args[0], oldcmd) |