comparison plugins/xxblank.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 15488fe94f52
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 = 'Example Plugin'
14 self.author = 'Your Name'
15 self.help = 'Info About your plugin'
16
17 #You can set variables below here. Always set them to a blank value in this section. Use plugin_enabled
18 #to set their proper values.
19 self.sample_variable = {}
20
21
22 def plugin_enabled(self):
23 #You can add new /commands like
24 # self.plugin_addcommand(cmd, function, helptext)
25 self.plugin_addcommand('/test', self.on_test, '- This is an example plugin command')
26
27 #If you want your plugin to have more then one way to call the same function you can
28 #use self.plugin_commandalias(alias name, command name)
29 #You can also make shortcut commands like the following
30 self.plugin_commandalias('/example', '/me is giving you an example')
31
32 #if you want your plugin to use custom messages to comunicate with other people using the same plugin
33 #you can add a message handler in a simmilar way to adding a new slash command. The first variable
34 #'xxblank' in this case is the tage name for your custom xml message. The second variable is the function
35 #you want to handle proccessing your messages when one is recived.
36 #Be sure to delete your handler in plugin_disabled
37 self.plugin_add_msg_handler('xxblank', self.on_xml_recive)
38
39 #if you want your plugin to store some settings in the settings window
40 #you can add them here, the system checks to make sure it does not already exist so you dont
41 #have to worry about it adding copies every time the plugin loads or it overwriting the users changes to it.
42 #This should be used for simple short settings that you would like the user to be able to change in the settings window
43 #variables:
44 #setting - The setting name, cannot contain spaces
45 #value - The default value
46 #options - The type of value that is expected
47 #help - a help message to explain what this variable does.
48 self.plugin_add_setting('Setting', 'Value', 'Options', 'Help message')
49
50 #This is where you set any variables that need to be initalized when your plugin starts
51 self.sample_variable = {1:'one', 2:'two'}
52
53 def plugin_disabled(self):
54 #Here you need to remove any commands you added, and anything else you want to happen when you disable the plugin
55 #such as closing windows created by the plugin
56 self.plugin_removecmd('/test')
57 self.plugin_removecmd('/example')
58
59 #This is the command to delete a message handler
60 self.plugin_delete_msg_handler('xxblank')
61
62 #This is how you should destroy a frame when the plugin is disabled
63 #This same method should be used in close_module as well
64 try:
65 self.frame.Destroy()
66 except:
67 pass
68
69 def on_test(self, cmdargs):
70 #this is just an example function for a command you create.
71 # cmdargs contains everything you typed after the command
72 # so if you typed /test this is a test, cmdargs = this is a test
73 # args are the individual arguments split. For the above example
74 # args[0] = this , args[1] = is , args[2] = a , args[3] = test
75 self.plugin_send_msg(cmdargs, '<xxblank>' + cmdargs + '</xxblank>')
76 args = cmdargs.split(None,-1)
77 msg = 'cmdargs = %s' % (cmdargs)
78 self.chat.InfoPost(msg)
79
80 if len(args) == 0:
81 self.chat.InfoPost("You have no args")
82 else:
83 i = 0
84 for n in args:
85 msg = 'args[' + str(i) + '] = ' + n
86 self.chat.InfoPost(msg)
87 i += 1
88
89 def on_xml_recive(self,id, data,xml_dom):
90 self.chat.InfoPost(self.name + ":: Message recived<br />" + data.replace("<","&lt;").replace(">","&gt;") +'<br />From id:' + str(id))
91
92 def pre_parse(self, text):
93 #This is called just before a message is parsed by openrpg
94 return text
95
96 def send_msg(self, text, send):
97 #This is called when a message is about to be sent out.
98 #It covers all messages sent by the user, before they have been formatted.
99 #If send is set to 0, the message will not be sent out to other
100 #users, but it will still be posted to the user's chat normally.
101 #Otherwise, send defaults to 1. (The message is sent as normal)
102 return text, send
103
104 def plugin_incoming_msg(self, text, type, name, player):
105 #This is called whenever a message from someone else is received, no matter
106 #what type of message it is.
107 #The text variable is the text of the message. If the type is a regular
108 #message, it is already formatted. Otherwise, it's not.
109 #The type variable is an integer which tells you the type: 1=chat, 2=whisper
110 #3=emote, 4=info, and 5=system.
111 #The name variable is the name of the player who sent you the message.
112 #The player variable contains lots of info about the player sending the
113 #message, including name, ID#, and currently-set role.
114 #Uncomment the following line to see the format for the player variable.
115 #print player
116 return text, type, name
117
118 def post_msg(self, text, myself):
119 #This is called whenever a message from anyone is about to be posted
120 #to chat; it doesn't affect the copy of the message that gets sent to others
121 #Be careful; system and info messages trigger this too.
122 return text
123
124 def refresh_counter(self):
125 #This is called once per second. That's all you need to know.
126 pass