view plugins/xxchatnotify.py @ 178:ff19dd30064b alpha

Traipse Alpha 'OpenRPG' {100114-02} Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the productivity of the user. Update Summary (Keeping up with Beta) New Features: Added Bookmarks Added 'boot' command to remote admin Added confirmation window for sent nodes Minor changes to allow for portability to an OpenSUSE linux OS Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG Zoom Mouse plugin added Images added to Plugin UI Switching to Element Tree Map efficiency, from FlexiRPG Added Status Bar to Update Manager New TrueDebug Class in orpg_log (See documentation for usage) Portable Mercurial Tip of the Day added, from Core and community New Reference Syntax added for custom PC sheets New Child Reference for gametree New Parent Reference for gametree New Gametree Recursion method, mapping, context sensitivity, and effeciency.. New Features node with bonus nodes and Node Referencing help added Dieroller structure from Core New DieRoller portability for odd Dice Added 7th Sea die roller; ie [7k3] = [7d10.takeHighest(3).open(10)] New 'Mythos' System die roller added Added new vs. die roller method for WoD; ie [3v3] = [3d10.vs(3)]. Included for Mythos roller also New Warhammer FRPG Die Roller (Special thanks to Puu-san for the support) New EZ_Tree Reference system. Push a button, Traipse the tree, get a reference (Beta!) Fixes: Fix to Text based Server Fix to Remote Admin Commands Fix to Pretty Print, from Core Fix to Splitter Nodes not being created Fix to massive amounts of images loading, from Core Fix to Map from gametree not showing to all clients Fix to gametree about menus Fix to Password Manager check on startup Fix to PC Sheets from tool nodes. They now use the tabber_panel Fixed Whiteboard ID to prevent random line or text deleting. Modified ID's to prevent non updated clients from ruining the fix. default_manifest.xml renamed to default_upmana.xml Fix to Update Manager; cleaner clode for saved repositories Fixes made to Settings Panel and now reactive settings when Ok is pressed Fixes to Alternity roller's attack roll. Uses a simple Tuple instead of a Splice Fix to Use panel of Forms and Tabbers. Now longer enters design mode Fix made Image Fetching. New fetching image and new failed image
author sirebral
date Thu, 14 Jan 2010 12:45:14 -0600
parents 7b752c9d0c28
children 6debef714365
line wrap: on
line source

import os
import orpg.pluginhandler
import wx
from orpg.orpgCore import *

class Plugin(orpg.pluginhandler.PluginHandler): #Attempting to pass the orpgFrame so that we can Bind events, not working.
    def __init__(self, plugindb, parent):
        orpg.pluginhandler.PluginHandler.__init__(self, plugindb, parent)

        # The Following code should be edited to contain the proper information
        self.name = 'Chat Notification'
        self.author = 'Dj Gilcrease'
        self.help = 'This plugin with either play a sound when a new chat message comes in, flash the taskbar or both'

    def plugin_menu(self):
	#Plugin Menu
        self.menu = wx.Menu()
        self.notifyToggle = self.menu.AppendCheckItem(wx.ID_ANY, 'On')
        self.topframe.Bind(wx.EVT_MENU, self.on_settings, self.notifyToggle)

        notify = wx.Menu()
        self.notifyBeep = notify.AppendRadioItem(wx.ID_ANY, 'Beep')
        self.notifyFlash = notify.AppendRadioItem(wx.ID_ANY, 'Flash')
        self.notifyBoth = notify.AppendRadioItem(wx.ID_ANY, 'Both')
        self.menu.AppendMenu(wx.ID_ANY, 'Notify', notify)
        self.topframe.Bind(wx.EVT_MENU, self.on_settings, self.notifyBeep)
        self.topframe.Bind(wx.EVT_MENU, self.on_settings, self.notifyFlash)
        self.topframe.Bind(wx.EVT_MENU, self.on_settings, self.notifyBoth)

        notifyType = wx.Menu()
        self.notifyAll = notifyType.AppendRadioItem(wx.ID_ANY, 'All')
        self.notifyWhisper = notifyType.AppendRadioItem(wx.ID_ANY, 'Whisper')
        self.menu.AppendMenu(wx.ID_ANY, 'Type', notifyType)
        self.topframe.Bind(wx.EVT_MENU, self.on_settings, self.notifyAll)
        self.topframe.Bind(wx.EVT_MENU, self.on_settings, self.notifyWhisper)

    def on_settings(self, evt):
        if self.notifyToggle.IsChecked() == False:
            self.notify = 'Off'
            self.plugindb.SetString('xxchatnotify', 'notify', self.notify)
            return
        if self.notifyBeep.IsChecked() == True:
            self.notify ='beep'
        elif self.notifyFlash.IsChecked() == True:
            self.notify = 'flash'
        elif self.notifyBoth.IsChecked() == True:
            self.notify = 'both'
        if self.notifyAll.IsChecked() == True:
            self.type = 'all'
        elif self.notifyWhisper.IsChecked() == True:
            self.type = 'whisper'
        self.plugindb.SetString('xxchatnotify', 'notify', self.notify)
        self.plugindb.SetString('xxchatnotify', 'type', self.type)


    def plugin_enabled(self):
        self.plugin_addcommand('/notify', self.on_notify, 'beep | flash | both | off | type all|whisper | clearsound | lsound soundfile [Local Sound Files only] | rsound http://to.sound.file [Remote Sound Files only] - This command turns on the chat notification. You can use sound files and flash by issuing /notify both')
        self.notify = self.plugindb.GetString('xxchatnotify', 'notify', string) or 'off'
        self.type = self.plugindb.GetString('xxchatnotify', 'type', string) or 'beep'
        self.mainframe = component.get('frame')
        self.sound_player = component.get('sound')
        self.soundloc = self.plugindb.GetString('xxchatnotify', 'soundloc', 'local')
        self.soundfile = self.plugindb.GetString('xxchatnotify', 'soundfile', 'None')
        self.chat_settings()

    def chat_settings(self):
        self.notifyToggle.Check(True)
        if self.notify == 'beep':
            self.notifyBeep.Check(True)
        elif self.notify == 'flash':
            self.notifyFlash.Check(True)
        elif self.notify == 'both':
            self.notifyBoth.Check(True)
        else:
            self.notifyToggle.Check(False)
        if self.type == 'all':
            self.notifyAll.Check(True)
        elif self.type == 'whisper':
            self.notifyWhisper.Check(True)

    def plugin_disabled(self):
        self.plugin_removecmd('/notify')

    def on_notify(self, cmdargs):
        args = cmdargs.split(None, 2)

        if len(args) == 0:
            self.chat.InfoPost('You must specify if you want it to beep, flash, both or be turned off or specify if you want to be notified for all messages or just whispers')

        if args[0] == 'type':
            self.type = args[1]
            self.plugindb.SetString('xxchatnotify', 'type', self.type)
            self.chat.InfoPost('Setting Notification on Message type to ' + args[1])
            self.chat_settings()
            return
        elif args[0] == 'lsound':
            self.soundloc = 'local'
            self.soundfile = orpg.dirpath.dir_struct['plugins'] + args[1]
            self.plugindb.SetString('xxchatnotify', 'soundfile', self.soundfile)
            self.plugindb.GetString('xxchatnotify', 'soundloc', self.soundloc)
            self.chat.InfoPost('Setting Sound file to ' + self.soundfile)
            self.notify = 'beep'
            return
        elif args[0] == 'rsound':
            self.soundloc = 'remote'
            self.soundfile = args[1]
            self.plugindb.SetString('xxchatnotify', 'soundfile', self.soundfile)
            self.plugindb.GetString('xxchatnotify', 'soundloc', self.soundloc)
            self.chat.InfoPost('Setting Sound file to ' + self.soundfile)
            self.notify = 'beep'
            return
        elif args[0] == 'clearsound':
            self.soundloc = 'local'
            self.soundfile = 'None'
            self.plugindb.SetString('xxchatnotify', 'soundfile', self.soundfile)
            self.plugindb.GetString('xxchatnotify', 'soundloc', self.soundloc)
            self.chat.InfoPost('Clearing Sound file')
            self.notify = 'off'
            return


        self.notify = args[0]
        self.plugindb.SetString('xxchatnotify', 'notify', self.notify)
        self.chat.InfoPost('Setting Notification type to ' + args[0])
        self.chat_settings()


    def plugin_incoming_msg(self, text, type, name, player):
        if (self.notify == 'beep' or self.notify == 'both') and (self.type == 'all' or type == 2):
            if self.soundfile == 'None':
                wx.CallAfter(wx.Bell)
                wx.CallAfter(wx.Bell)
            else:
                wx.CallAfter(self.sound_player.play, self.soundfile, self.soundloc)
        if (self.notify == 'flash' or self.notify == 'both') and (self.type == 'all' or type == 2):
            wx.CallAfter(self.mainframe.RequestUserAttention)
        return text, type, name