emesene forum
November 22, 2008, 04:00:40 AM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
:
PROBLEMS WITH 1.0.x? TAKE A LOOK IN
HERE
- FATAL ERRORS? (1.0.x) REPORT THEM
HERE
Home
Forum
Help
Search
Login
Register
emesene forum
>
Forum
>
Development
>
Plugins
>
Notes Plugin
Pages: [
1
]
« previous
next »
Print
Author
Topic: Notes Plugin (Read 705 times)
Oceanos
Newbie
l33tness: 2
Offline
Posts: 1
Notes Plugin
«
on:
January 22, 2008, 07:47:12 PM »
Hi.
This afternoon, I was really bored and think a useless idea: "And if I make a plugin for Emesene to show some notes in the conversation window, according to contact?". Well, this keep me busy for some hours, and I made a little toy that can be usefull (or not... anyway, it was fun write it) for someone else:
Code:
# -*- 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'''
def __init__(self, controller, msn):
''' Constructor '''
Plugin.Plugin.__init__(self, controller, msn)
self.description = _('Show some notes (differentiated via contacts) in the conversation window.')
self.authors = {'Francisco de Souza Junior (Oceanos)': \
'fsjunior@gmail.com'}
self.website = ''
self.displayName = _('Notes')
self.name = 'Notes'
self.enabled = False
self.controller = controller
self.Slash = controller.Slash
self.config = controller.getConfig()
self.config.readPluginConfig(self.name)
def start(self):
self.Slash.register('note', self.noteCommand, \
_('Set a note for the contacts presents in the conversation window.'))
self.convmanagerId = self.controller.conversationManager.connect( \
'new-conversation-ui', self.openWindow)
self.enabled = True
def noteCommand(self, slashAction):
'''/note command'''
message = slashAction.getParams()
template = self.config.getPluginValue(self.name, 'new_note_template', \
_('New note for %s: %s'))
conversation = slashAction.conversation
members = conversation.getMembers()
for member in members:
self.config.setPluginValue(self.name, member, message)
conversation.appendOutputText(None, template % (member, message), \
'information')
def openWindow(self, conversationManager, conversation, window):
'''A new window (or tab) has been created...'''
members = conversation.getMembers()
template = self.config.getPluginValue(self.name, 'note_template', \
_('Note for %s: %s'))
for member in members:
message = self.config.getPluginValue(self.name, member, '')
conversation.appendOutputText(None, template % (member, message), \
'information')
def stop(self):
self.Slash.unregister('note')
self.controller.conversationManager.disconnect(self.convmanagerId)
self.enabled = False
def check(self):
return (True, 'Ok')
def configure(self):
note_template = self.config.getPluginValue(self.name, 'note_template', \
_('Note for %s: %s'))
new_note_template = self.config.getPluginValue(self.name, \
'new_note_template', _('New note for %s: %s'))
opts = [Plugin.Option('note_template', str, \
_('Notification message:'), '', note_template), \
Plugin.Option('new_note_template', str, \
_('Notification message for new notes:'), '', new_note_template)]
result = Plugin.ConfigWindow(self.displayName, opts).run()
if 'note_template' in result and result['note_template']:
self.config.setPluginValue(self.name, 'note_template', \
result['note_template'].value)
if 'new_note_template' in result and result['new_note_template']:
self.config.setPluginValue(self.name, 'new_note_template', \
result['new_note_template'].value)
This plugin shows a note when you open a conversation window, according to contact. To set a note for a contact, just use the command "/note Put Here Your Note".
Ps. Sorry for my english.
Logged
louizatakk
Hero Member
l33tness: 1
Offline
Posts: 428
Re: Notes Plugin
«
Reply #1 on:
January 23, 2008, 07:56:29 AM »
Works great, thank you
But, it's writton in bold, and I don't like it
But we don't care, it's great
Logged
dx
h4x0r
Administrator
Hero Member
l33tness: 16
Offline
Posts: 544
<insert stuff>
Re: Notes Plugin
«
Reply #2 on:
January 24, 2008, 04:11:37 AM »
Good one. We should have a separate plugin repository in this site. *opens a thread*
Quote from: louizatakk on January 23, 2008, 07:56:29 AM
But, it's writton in bold, and I don't like it
But we don't care, it's great
Because your conversation layout defines "information" as bold. (erhm, the default does too)
Logged
asd
Astu
Hero Member
l33tness: 1
Offline
Posts: 157
Re: Notes Plugin
«
Reply #3 on:
January 24, 2008, 09:10:46 AM »
This is a really nice idea! I made a very little modification so that the message "Note for:" shows only if there is a note to show, I hope you'l like it
I changed the openWindow function, here it is:
Code:
# -*- 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'''
def __init__(self, controller, msn):
''' Constructor '''
Plugin.Plugin.__init__(self, controller, msn)
self.description = _('Show some notes (differentiated via contacts) in the conversation window.')
self.authors = {'Francisco de Souza Junior (Oceanos)': \
'fsjunior@gmail.com'}
self.website = ''
self.displayName = _('Notes')
self.name = 'Notes'
self.enabled = False
self.controller = controller
self.Slash = controller.Slash
self.config = controller.getConfig()
self.config.readPluginConfig(self.name)
def start(self):
self.Slash.register('note', self.noteCommand, \
_('Set a note for the contacts presents in the conversation window.'))
self.convmanagerId = self.controller.conversationManager.connect( \
'new-conversation-ui', self.openWindow)
self.enabled = True
def noteCommand(self, slashAction):
'''/note command'''
message = slashAction.getParams()
template = self.config.getPluginValue(self.name, 'new_note_template', \
_('New note for %s: %s'))
conversation = slashAction.conversation
members = conversation.getMembers()
for member in members:
self.config.setPluginValue(self.name, member, message)
conversation.appendOutputText(None, template % (member, message), \
'information')
def openWindow(self, conversationManager, conversation, window):
'''A new window (or tab) has been created...'''
members = conversation.getMembers()
template = self.config.getPluginValue(self.name, 'note_template', \
_('Note for %s: %s'))
for member in members:
message = self.config.getPluginValue(self.name, member, '')
if message != '':
conversation.appendOutputText(None, template % (member, message), \
'information')
def stop(self):
self.Slash.unregister('note')
self.controller.conversationManager.disconnect(self.convmanagerId)
self.enabled = False
def check(self):
return (True, 'Ok')
def configure(self):
note_template = self.config.getPluginValue(self.name, 'note_template', \
_('Note for %s: %s'))
new_note_template = self.config.getPluginValue(self.name, \
'new_note_template', _('New note for %s: %s'))
opts = [Plugin.Option('note_template', str, \
_('Notification message:'), '', note_template), \
Plugin.Option('new_note_template', str, \
_('Notification message for new notes:'), '', new_note_template)]
result = Plugin.ConfigWindow(self.displayName, opts).run()
if 'note_template' in result and result['note_template']:
self.config.setPluginValue(self.name, 'note_template', \
result['note_template'].value)
if 'new_note_template' in result and result['new_note_template']:
self.config.setPluginValue(self.name, 'new_note_template', \
result['new_note_template'].value)
Logged
Pages: [
1
]
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Main
-----------------------------
=> Announcements
=> Feature Requests
=> Support (emesene 1.0.x)
===> Support for unsupported (emesene-trunk)
=> Themes
=> HOWTOs
=> Forum/site Requests
=> Offtopic
===> Nonsense
-----------------------------
Development
-----------------------------
=> Emesene
=> Plugins
=> Patches
=> Translations
-----------------------------
International Forum
-----------------------------
=> Deutsch
=> Español
=> Français
=> Italiano
=> Português
Loading...