Premetto che questo è il primo plugin di emesene che (tento) di scrivere...
volevo fare un plugin che cambiasse il messaggio personale ogni 60 secondi...
ho preso un pò di codice dal plugin countdown, che fa all'incirca la stessa cosa...
Codice: Seleziona tutto
import Plugin
import gobject
msg_1 = "Hello World! 1"
msg_2 = "Hello World! 2"
num = 2
class MainClass( Plugin.Plugin ):
'''Main plugin class'''
def __init__( self, controller, msn ):
'''Contructor'''
Plugin.Plugin.__init__( self, controller, msn )
self.description = _( 'Cambia messaggio ogni 60 secondi.' )
self.authors = { '...' }
self.website = '...'
self.displayName = _( 'Mess' )
self.name = 'Mess'
self.config = controller.config
self.config.readPluginConfig(self.name)
self.enabled = False
def start( self ):
'''start the plugin'''
self.enabled = True
self.timeout = gobject.timeout_add(60000, self.refresh)
self.refresh()
def stop( self ):
'''stop the plugin'''
self.enabled = False
def check( self ):
'''
check if everything is OK to start the plugin
return a tuple whith a boolean and a message
if OK -> ( True , 'some message' )
else -> ( False , 'error message' )
'''
return ( True, 'Ok' )
def refresh( self ):
'''refresh the personal message with the new message'''
if num == 1:
self.controller.contacts.set_message(msg_2)
num == 2
elif num == 2:
self.controller.contacts.set_message(msg_1)
num == 1
return True
Allora questo plugin quando lo attivo mi cambia il messaggio in hello world! 1
ma dopo mi rimane sempre lo stesso...
come posso fare ??
grazie e spero di essere stato chiaro

