Variabili
-
ivan4president
- Prode Principiante
- Messaggi: 105
- Iscrizione: martedì 23 settembre 2008, 16:13
- Località: Bari
Variabili
Nei plugin ritrovo spesso delle variabili. Ora per esempio, in una, sfrutta l'indirixxo email per dire che "pippo ti sta scrivendo un messaggio".. usa: "%s ti sta scrivendo un messaggio".. dove %s è la variabile dell'email. Come faccio a scoprire le variabili di quel programma? Dove son state decise? Come modificarle? Come scoprire le altre?
-
ivan4president
- Prode Principiante
- Messaggi: 105
- Iscrizione: martedì 23 settembre 2008, 16:13
- Località: Bari
Re: Variabili
# -*- coding: utf-8 -*-
# This file is part of emesene.
#
# Emesene is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# emesene is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with emesene; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import Plugin
class MainClass( Plugin.Plugin ):
'''Main plugin class'''
description = _('Open conversation window when user starts typing.')
authors = { 'Jan de Mooij' : 'jandemooij@gmail.com' }
displayName = _('Psycho Mode')
name = 'PsychoMode'
def __init__( self, controller, msn ):
'''Contructor'''
Plugin.Plugin.__init__( self, controller, msn )
self.description = _('Open conversation window when user starts typing.')
self.authors = { 'Jan de Mooij' : 'jandemooij@gmail.com' }
self.displayName = _('Psycho Mode')
self.name = 'PsychoMode'
self.controller = controller
self.config = controller.config
self.config.readPluginConfig(self.name)
self.handlerId = None
self.enabled = False
def receiveTyping(self, msn, switchboard, signal, args):
controller = self.controller
mail = args[0]
result = controller.conversationManager.getOpenConversation(mail, \
switchboard)
if result == None:
window, conversation = controller.newConversation(self.msn, \
mail, switchboard)
template = self.config.getPluginValue(self.name, 'message', \
_('%s starts typing...'))
try:
message = template % mail
except TypeError:
message = template
conversation.appendOutputText(None, message, 'information')
conversation.receiveTyping(switchboard, mail)
def start( self ):
'''start the plugin'''
self.handlerId = self.connect('switchboard::typing',
self.receiveTyping)
self.enabled = True
def stop( self ):
'''stop the plugin'''
self.controller.msn.disconnect(self.handlerId)
self.enabled = False
def check(self):
return (True, 'Ok')
def configure(self):
opts = [Plugin.Option('message', str, 'Notification message:', '', \
self.config.getPluginValue(self.name, 'message', \
_('%s starts typing...')))]
result = Plugin.ConfigWindow(_('Psycho mode'), opts).run()
if result and 'message' in result and result['message'].value:
self.config.setPluginValue(self.name, 'message', \
result['message'].value)
# This file is part of emesene.
#
# Emesene is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# emesene is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with emesene; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import Plugin
class MainClass( Plugin.Plugin ):
'''Main plugin class'''
description = _('Open conversation window when user starts typing.')
authors = { 'Jan de Mooij' : 'jandemooij@gmail.com' }
displayName = _('Psycho Mode')
name = 'PsychoMode'
def __init__( self, controller, msn ):
'''Contructor'''
Plugin.Plugin.__init__( self, controller, msn )
self.description = _('Open conversation window when user starts typing.')
self.authors = { 'Jan de Mooij' : 'jandemooij@gmail.com' }
self.displayName = _('Psycho Mode')
self.name = 'PsychoMode'
self.controller = controller
self.config = controller.config
self.config.readPluginConfig(self.name)
self.handlerId = None
self.enabled = False
def receiveTyping(self, msn, switchboard, signal, args):
controller = self.controller
mail = args[0]
result = controller.conversationManager.getOpenConversation(mail, \
switchboard)
if result == None:
window, conversation = controller.newConversation(self.msn, \
mail, switchboard)
template = self.config.getPluginValue(self.name, 'message', \
_('%s starts typing...'))
try:
message = template % mail
except TypeError:
message = template
conversation.appendOutputText(None, message, 'information')
conversation.receiveTyping(switchboard, mail)
def start( self ):
'''start the plugin'''
self.handlerId = self.connect('switchboard::typing',
self.receiveTyping)
self.enabled = True
def stop( self ):
'''stop the plugin'''
self.controller.msn.disconnect(self.handlerId)
self.enabled = False
def check(self):
return (True, 'Ok')
def configure(self):
opts = [Plugin.Option('message', str, 'Notification message:', '', \
self.config.getPluginValue(self.name, 'message', \
_('%s starts typing...')))]
result = Plugin.ConfigWindow(_('Psycho mode'), opts).run()
if result and 'message' in result and result['message'].value:
self.config.setPluginValue(self.name, 'message', \
result['message'].value)
Re: Variabili
E cosa vorresti fare con questo plugin?
"E alla fine sei da solo, dove vai, con chi brindi?"
-
ivan4president
- Prode Principiante
- Messaggi: 105
- Iscrizione: martedì 23 settembre 2008, 16:13
- Località: Bari
Re: Variabili
fare in modo che %s nn sia l'email, ma il nick dell utente.
Chi c’è in linea
Visualizzano questa sezione: 0 utenti iscritti e 2 ospiti
