Hello, I've made a little plugin, for those who sometimes play role playing game (like Dungeon and Dragons), it's for my personal use at first, but I think it could be useful to some others (ie : I really don't except it to be in emesene, but use it if you want it)
The command is /dice xdy, and it sends x dices with y faces.
Please report any bug or comment, or feedback, or WHAT YOU WANT

For those you want to read it :
# -*- 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
VERSION = '0.1'
import random
from Plugin import Plugin
class MainClass(Plugin):
def __init__(self, controller, msn):
Plugin.__init__(self, controller, msn)
self.description = _('Show random numbers in the conversation. "/help dice" for usage.')
self.authors = {'Le Coz Florent (aka louiz)': 'louizatakk AT gmail DOT com'}
self.website = 'None'
self.displayName = _('Dices')
self.name = 'Dices'
self.Slash = controller.Slash
self.enabled = False
def start(self):
self.Slash.register('dice', self.rolls_dice, _('Dice:\nformat : xdy\nRolls x dices, each dice has y faces'))
self.enabled = True
def rolls_dice(self, slash_action):
'''rolls dices : it sends random numbers, defined by the xdy format'''
data = slash_action.getParams()
params = data.split('d')
if len(params) != 2:
return
try:
x = int(params[0])
nb = int(params[1])
except ValueError:
return
data += " :\n"
if (nb <= 0):
return
for i in range(x):
data += str(random.randint(1, nb)) + ' '
slash_action.outputText(data, True)
def stop(self):
self.Slash.unregister('dice')
self.enabled = False
def check(self):
return (True, 'Ok')
and those who want to download it and use it, it's attached too.
