[Winopenrpg-developer] openrpg1/plugins heya.wav,NONE,1.1 xxblank.py,NONE,1.1 xxcac.py,NONE,1.1 xxch
Status: Inactive
Brought to you by:
digitalxero
|
From: Digital X. <dig...@us...> - 2006-01-26 17:33:27
|
Update of /cvsroot/winopenrpg/openrpg1/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30930/plugins Added Files: heya.wav xxblank.py xxcac.py xxcherrypy.py xxnamesound.py xxooc.py xxsavewindow.py xxurl2link.py Log Message: Initial commit of OpenRPG++ python --- NEW FILE: xxblank.py --- import os import orpg.pluginhandler class Plugin(orpg.pluginhandler.PluginHandler): # Initialization subroutine. # # !self : instance of self # !openrpg : instance of the the base openrpg control def __init__(self, openrpg, plugindb, parent): orpg.pluginhandler.PluginHandler.__init__(self, openrpg, plugindb, parent) # The Following code should be edited to contain the proper information self.name = 'Example Plugin' self.author = 'Your Name' self.help = 'Info About your plugin' #You can set variables below here. Always set them to a blank value in this section. Use plugin_enabled #to set their proper values. self.sample_variable = {} def plugin_enabled(self): #You can add new /commands like # self.plugin_addcommand(cmd, function, helptext) self.plugin_addcommand('/test', self.on_test, '- This is an example plugin command') #If you want your plugin to have more then one way to call the same function you can #use self.plugin_commandalias(alias name, command name) #You can also make shortcut commands like the following self.plugin_commandalias('/example', '/me is giving you an example') #if you want your plugin to use custom messages to comunicate with other people using the same plugin #you can add a message handler in a simmilar way to adding a new slash command. The first variable #'tester' in this case is the tage name for your custom xml message. The second variable is the function #you want to handle proccessing your messages when one is recived. #Be sure to delete your handler in plugin_disabled self.plugin_add_msg_handler('xxblank', self.on_xml_recive) #This is where you set any variables that need to be initalized when your plugin starts self.sample_variable = {1:'one', 2:'two'} def plugin_disabled(self): #Here you need to remove any commands you added, and anything else you want to happen when you disable the plugin #such as closing windows created by the plugin self.plugin_removecmd('/test') self.plugin_removecmd('/example') #This is the command to delete a message handler self.plugin_delete_msg_handler('tester') #This is how you should destroy a frame when the plugin is disabled #This same method should be used in close_module as well try: self.frame.Destroy() except: pass def on_test(self, cmdargs): #this is just an example function for a command you create. # cmdargs contains everything you typed after the command # so if you typed /test this is a test, cmdargs = this is a test # args are the individual arguments split. For the above example # args[0] = this , args[1] = is , args[2] = a , args[3] = test self.plugin_send_msg('<xxblank>' + cmdargs + '</xxblank>') args = cmdargs.split(None,-1) msg = 'cmdargs = %s' % (cmdargs) self.chat.InfoPost(msg) if len(args) == 0: self.chat.InfoPost("You have no args") else: i = 0 for n in args: msg = 'args[' + str(i) + '] = ' + n self.chat.InfoPost(msg) i += 1 def on_xml_recive(self,id,data,xml_dom): self.chat.InfoPost(self.name + ":: Message recived<br>" + data.replace("<","<").replace(">",">")) def pre_parse(self, text): #This is called just before a message is parsed by openrpg return text def send_msg(self, text, send): #This is called when a message is about to be sent out. #It covers all messages sent by the user, before they have been formatted. #If send is set to 0, the message will not be sent out to other #users, but it will still be posted to the user's chat normally. #Otherwise, send defaults to 1. (The message is sent as normal) return text, send def plugin_incoming_msg(self, text, type, name, player): #This is called whenever a message from someone else is received, no matter #what type of message it is. #The text variable is the text of the message. If the type is a regular #message, it is already formatted. Otherwise, it's not. #The type variable is an integer which tells you the type: 1=chat, 2=whisper #3=emote, 4=info, and 5=system. #The name variable is the name of the player who sent you the message. #The player variable contains lots of info about the player sending the #message, including name, ID#, and currently-set role. #Uncomment the following line to see the format for the player variable. #print player return text, type, name def post_msg(self, text, myself): #This is called whenever a message from anyone is about to be posted #to chat; it doesn't affect the copy of the message that gets sent to others #Be careful; system and info messages trigger this too. return text def refresh_counter(self): #This is called once per second. That's all you need to know. pass --- NEW FILE: xxcac.py --- import os import orpg.pluginhandler class Plugin(orpg.pluginhandler.PluginHandler): # Initialization subroutine. # # !self : instance of self # !openrpg : instance of the the base openrpg control def __init__(self, openrpg, plugindb, parent): orpg.pluginhandler.PluginHandler.__init__(self, openrpg, plugindb, parent) # The Following code should be edited to contain the proper information self.name = 'Command Alias Creator' self.author = 'Dj Gilcrease' self.help = "This plugin lets you add Command Aliases.\neg /sits insted of /me sits down" self.newcmdaliases = {} def plugin_enabled(self): 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)') self.newcmdaliases = self.plugindb.GetDict("xxcac", "newcmdaliases", {}) for n in self.newcmdaliases: if not self.shortcmdlist.has_key(n) and not self.cmdlist.has_key(n): self.plugin_commandalias(n, self.newcmdaliases[n]) def plugin_disabled(self): self.plugin_removecmd('/cmdalias') for n in self.newcmdaliases: self.plugin_removecmd(n) def on_cmdalias(self, cmdargs): args = cmdargs.split(" ",-1) if len(args) == 0: self.chat.InfoPost("USAGE: /cmdalias [cmdalias_name fullcommand] [remove cmdalias_name] [clear] - (eg. /sits /me sits down)") elif args[0] == 'remove': if self.newcmdaliases.has_key(args[1]): del self.newcmdaliases[args[1]] self.plugindb.SetDict("xxcac", "newcmdaliases", self.newcmdaliases) self.plugin_removecmd(args[1]) elif args[0] == 'clear': for n in self.newcmdaliases: self.plugin_removecmd(n) self.newcmdaliases = {} self.plugindb.SetDict("xxcac", "newcmdaliases", self.newcmdaliases) else: oldcmd = cmdargs[len(args[0])+1:] self.newcmdaliases[args[0]] = oldcmd self.plugindb.SetDict("xxcac", "newcmdaliases", self.newcmdaliases) self.plugin_commandalias(args[0], oldcmd) --- NEW FILE: xxnamesound.py --- import os import orpg.pluginhandler from orpg.tools.orpg_sound import orpg_sound import orpg.dirpath class Plugin(orpg.pluginhandler.PluginHandler): # Initialization subroutine. # # !self : instance of self # !openrpg : instance of the the base openrpg control def __init__(self, openrpg, plugindb, parent): orpg.pluginhandler.PluginHandler.__init__(self, openrpg, plugindb, parent) # The Following code should be edited to contain the proper information self.name = 'Name Sound' self.author = 'mDuo13' self.help = "This plays a 'hey!' sound whenever your name is said in chat. It is\n" self.help += "not HTML- or case-sensitive. You can also create nicknames to which the plugin\n" self.help += "will also respond. To add a nickname, type '/xxnick add *name*', where *name*\n" self.help += "is the nickname you want to add. Then, whenever *name* is said in chat, you'll\n" self.help += "hear the sound also. You can remove your nicknames by typing\n" self.help += "'/xxnick del*name*' where *name* is the nickname you wish to delete. Neither is\n" self.help += "case sensitive. Additionally, you can see what nicknames you currently have\n" self.help += "with '/xxnick list'." self.antispam = 0 self.names = [] self.soundfile = '' self.soundplayer = '' def plugin_enabled(self): self.plugin_addcommand('/xxnick', self.on_xxnick, 'add name|del name|list - This is the command for the namesound plugin') self.names = self.plugindb.GetList("xxnamesound", "names", []) self.soundfile = orpg.dirpath.dir_struct['plugins'] + 'heya.wav' self.soundplayer = orpg_sound(self.settings.get_setting("UnixSoundPlayer")) if not self.chat.html_strip(self.session.name.lower()) in self.names: self.names.append(self.chat.html_strip(self.session.name.lower())) def plugin_disabled(self): self.plugin_removecmd('/xxnick') def on_xxnick(self, cmdargs): args = cmdargs.split(None,-1) if len(args): name = cmdargs[len(args[0])+1:].lower().strip() if len(args) == 0 or args[0] == 'list': name_list = '' i = 0 for name in self.names: name_list += name if i < len(self.names)-1: name_list += ', ' i += 1 self.chat.InfoPost('Currently chacking for ' + name_list) elif args[0] == 'add': if name not in self.names and name != '': self.names.append(name) self.plugindb.SetList('xxnamesound', 'names', self.names) self.chat.InfoPost('The name ' + name + ' has been added to your nickname list. You will now hear a sound when someone says it in chat.') else: self.chat.InfoPost('The name ' + name + ' is already in your nickname list.') elif args[0] == 'del': if name in self.names: self.names.remove(name) self.plugindb.SetList('xxnamesound', 'names', self.names) self.chat.InfoPost('The name ' + name + ' has been removed from your nickname list.') else: self.chat.InfoPost('The name ' + name + ' is not in your nickname list.') def plugin_incoming_msg(self, text, type, name, player): if self.antispam > 0: return text, type, name for name in self.names: #print self.chat.html_strip(text.lower()).find(name.lower()) if self.chat.html_strip(text.lower()).find(name.lower()) != -1: self.soundplayer.play(self.soundfile) self.antispam = 1 break return text, type, name def refresh_counter(self): #This is called once per second. That's all you need to know. if self.antispam: self.antispam -= 0.04 --- NEW FILE: xxurl2link.py --- import os import orpg.pluginhandler import re class Plugin(orpg.pluginhandler.PluginHandler): # Initialization subroutine. # # !self : instance of self # !chat : instance of the chat window to write to def __init__(self, openrpg, plugindb, parent): orpg.pluginhandler.PluginHandler.__init__(self, openrpg, plugindb, parent) # The Following code should be edited to contain the proper information self.name = 'URL to link conversion' self.author = 'tdb30 tb...@wr...' self.help = "This plugin automaticaly wraps urls in link tags\n" self.help += "making them clickable." self.url_regex = None self.mailto_regex = None def plugin_enabled(self): #This is where you set any variables that need to be initalized when your plugin starts self.url_regex = re.compile(r"""\w{3,}://[A-Za-z0-9.=,:/&;?_%~+!$#-]{2,63}\.[A-Za-z0-9.=,:/&;?_%~+!$#-]{2,63}|[\w-]{2,63}\.[\w-]{2,63}\.[A-Za-z]{2,6}(/[A-Za-z0-9.=,:/&;?_%~+!$#-]+)?|[0-9]{2,3}\.[0-9]{2,3}\.[0-9]{1,3}\.[0-9]{1,3}""", re.I) self.mailto_regex = re.compile(r"""(mailto:)?[\w._-]+@[A-Za-z0-9.-]+""", re.I) def plugin_disabled(self): #Here you need to remove any commands you added, and anything else you want to happen when you disable the plugin #such as closing windows created by the plugin pass def send_msg(self, text, send): text = self.link_emails(text) text = self.link_urls(text) return text, send def plugin_incoming_msg(self, text, type, name, player): text = self.link_emails(text) text = self.link_urls(text) return text, type, name def link_urls(self, text): #The modified text accumulates into text2 so that the indices of the regex matches #in the original text variable don't get screwed up by the replacement. text2 = "" url = self.url_regex.search(text) if not url:#so that it doesn't accidentally delete the message text2 = text textafterurl = "" while url: urltext = url.group() if urltext.find("://")<0:#it might not load the web browser but is usable. For example, "maps.google.com" urltext = "http://"+urltext textbeforeurl = text[:url.start()] textafterurl = text[url.end():] if not (len(re.findall("<",textbeforeurl)) > len(re.findall(">",textbeforeurl))) and text[url.start()-1]!="@": text2 += textbeforeurl + "<a href='" + urltext + "'>" + url.group() + "</a>" else: text2 += textbeforeurl + url.group()#not urltext, because we don't wanna screw with it text = textafterurl url = self.url_regex.search(text) else:#once it's done -- this happens whether or not it found a URL to begin with text2 += textafterurl return text2 def link_emails(self, text): #The modified text accumulates into text2 so that the indices of the regex matches #in the original text variable don't get screwed up by the replacement. #the main differences between this and the link_urls function are: # (a) this one uses the mailto_regex instead of url_regex # (b) this one doesn't append http:// but rather mailto: text2 = "" url = self.mailto_regex.search(text) if not url:#so that it doesn't accidentally delete the message text2 = text textafterurl = "" while url: urltext = url.group() if urltext.find("mailto:")<0:#it's just a plain e-mail like md...@ya... instead of a mailto URL urltext = "mailto:"+urltext textbeforeurl = text[:url.start()] textafterurl = text[url.end():] if not (len(re.findall("<",textbeforeurl)) > len(re.findall(">",textbeforeurl))): #here it doesn't use urltext, but rather the "prettier" version (without mailto:) in the displayed text #even though the href URL is actually a mailto. text2 += textbeforeurl + "<a href='" + urltext + "'>" + url.group() + "</a>" else: text2 += textbeforeurl + url.group()#not urltext, because we don't wanna screw with it text = textafterurl url = self.mailto_regex.search(text) else:#once it's done -- this happens whether or not it found a URL to begin with text2 += textafterurl return text2 --- NEW FILE: xxcherrypy.py --- import os import orpg.pluginhandler import thread from cherrypy import cpg import socket class Plugin(orpg.pluginhandler.PluginHandler): # Initialization subroutine. # # !self : instance of self # !openrpg : instance of the the base openrpg control def __init__(self, openrpg, plugindb, parent): orpg.pluginhandler.PluginHandler.__init__(self, openrpg, plugindb, parent) # The Following code should be edited to contain the proper information self.name = 'CherryPy Web Server' self.author = 'Dj Gilcrease' self.help = 'This plugin turns OpenRPG into a Web server\n' self.help += 'allowing you to host your map and mini files localy' #You can set variables below here. Always set them to a blank value in this section. Use plugin_enabled #to set their proper values. self.isServerRunning = 'off' self.host = 0 def plugin_enabled(self): self.plugin_addcommand('/cherrypy', self.on_cherrypy, '[on | off | status] - This controls the CherryPy Web Server') tmp = socket.gethostbyname_ex('') for ip in tmp[2]: if ip[:7] == '192.168' or ip[:3] == '10.' or ip == '127.0.0.1' or (ip[:3] == '172' and (int(ip[5:6]) >= 16 and int(ip[5:6]) <=32)) : continue else: self.host = ip def plugin_disabled(self): #Here you need to remove any commands you added, and anything else you want to happen when you disable the plugin #such as closing windows created by the plugin self.plugin_removecmd('/cherrypy') cpg.server.stop() self.isServerRunning = 'off' def on_cherrypy(self, cmdargs): args = cmdargs.split(None,-1) if len(args) == 0 or args[0] == 'status': self.chat.InfoPost("CherryPy Web Server is currently: " + self.isServerRunning) self.chat.InfoPost("CherryPy Web Server address is: http://" + self.host + '/webfiles/') elif args[0] == 'on' and self.isServerRunning == 'off': self.webserver = thread.start_new_thread(self.startServer, (80,)) self.isServerRunning = 'on' elif args[0] == 'off' and self.isServerRunning == 'on': cpg.server.stop() self.isServerRunning = 'off' self.chat.InfoPost("CherryPy Web Server is now disabled") def startServer(self, port): try: if self.host == 0: raise Exception("Invalid IP address.<br>This error means you are behind a router or some other form of network that is giving you a Privet IP only (ie. 192.168.x.x, 10.x.x.x, 172.16 - 32.x.x)") self.chat.InfoPost("CherryPy Web Server is now running on http://" + self.host + '/webfiles/') cpg.server.start(configMap = {'staticContentList': [['images', r''+orpg.dirpath.dir_struct["icon"]+''],['webfiles', r''+orpg.dirpath.dir_struct["user"]+'webfiles/']], 'socketPort': port, 'logToScreen': 0, 'logFile':orpg.dirpath.dir_struct["user"]+'webfiles/log.txt', 'sessionStorageType':'ram', 'threadPool':10, 'sessionTimeout':30, 'sessionCleanUpDelay':30}) except Exception, e: self.chat.InfoPost("FAILED to start server!") self.chat.InfoPost(str(e)) self.isServerRunning = 'off' --- NEW FILE: heya.wav --- (This appears to be a binary file; contents omitted.) --- NEW FILE: xxsavewindow.py --- import os import orpg.pluginhandler class Plugin(orpg.pluginhandler.PluginHandler): # Initialization subroutine. # # !self : instance of self # !openrpg : instance of the the base openrpg control def __init__(self, openrpg, plugindb, parent): orpg.pluginhandler.PluginHandler.__init__(self, openrpg, plugindb, parent) # The Following code should be edited to contain the proper information self.name = 'SaveWindow' self.author = 'mDuo13' self.help = "Saves the size and position of your OpenRPG window, as well as\n" self.help += "whether or not it is maximized. You must set the plugin to load on startup\n" self.help += "in order for this to work." #You can set variables below here. Always set them to a blank value in this section. Use plugin_enabled #to set their proper values. def plugin_enabled(self): if self.name in self.startplugs: win_xpos = self.plugindb.GetString(self.name,"win_xpos","-1") win_ypos = self.plugindb.GetString(self.name,"win_ypos","-1") maximized = self.plugindb.GetString(self.name,"maximized","0") win_xsize = self.plugindb.GetString(self.name,"win_xsize","-1") win_ysize = self.plugindb.GetString(self.name,"win_ysize","-1") x = int(win_xpos) y = int(win_ypos) is_maxed = int(maximized) width = int(win_xsize) height = int(win_ysize) if not is_maxed: self.parent.SetDimensions(x,y,width,height) self.parent.Maximize(is_maxed) def plugin_disabled(self): #This is called when OpenRPG shuts down (x_size,y_size) = self.parent.GetSizeTuple() (x_pos,y_pos) = self.parent.GetPositionTuple() is_maximized = self.bool2int(self.parent.IsMaximized()) self.plugindb.SetString(self.name,"win_xsize",str(x_size)) self.plugindb.SetString(self.name,"win_ysize",str(y_size)) self.plugindb.SetString(self.name,"win_xpos",str(x_pos)) self.plugindb.SetString(self.name,"win_ypos",str(y_pos)) self.plugindb.SetString(self.name,"maximized",str(is_maximized)) def bool2int(self, x): if x: return 1 else: return 0 --- NEW FILE: xxooc.py --- import os import orpg.pluginhandler class Plugin(orpg.pluginhandler.PluginHandler): # Initialization subroutine. # # !self : instance of self # !chat : instance of the chat window to write to def __init__(self, openrpg, plugindb, parent): orpg.pluginhandler.PluginHandler.__init__(self, openrpg, plugindb, parent) # The Following code should be edited to contain the proper information self.name = 'OOC Comments Tool' self.author = 'mDuo13' self.help = "Type '/ooc *message*' to send '(( *message* ))' -- it just preformats\n" self.help += "out of character comments for you." def plugin_enabled(self): #This is where you set any variables that need to be initalized when your plugin starts self.plugin_addcommand('/ooc', self.on_ooc, 'message - This puts (( message )) to let other players know you are talking out of character') def plugin_disabled(self): #Here you need to remove any commands you added, and anything else you want to happen when you disable the plugin #such as closing windows created by the plugin self.plugin_removecmd('/ooc') def on_ooc(self, cmdargs): #this is just an example function for a command you create create your own self.chat.ParsePost('(( ' + cmdargs + ' ))', 1, 1) |