]>
jfr.im git - erebus.git/blob - modules/misc.py
1 # Erebus IRC bot - Author: Erebus Team
2 # vim: fileencoding=utf-8
3 # simple module example
4 # This file is released into the public domain; see http://unlicense.org/
8 'author' : 'Erebus Team' ,
9 'license' : 'public domain' ,
10 'compatible' : [ 0 ], # compatible module API versions
11 'depends' : [], # other modules required to work properly?
12 'softdeps' : [ 'help' ], # modules which are preferred but not required
17 lib
= modlib
. modlib ( __name__
)
18 modstart
= lib
. modstart
22 from fractions
import Fraction
25 @lib.hook ( needchan
= False , wantchan
= True )
26 @lib.help ( '<numerator>/<denominator>|<decimal>' , 'reduces a fraction' , 'you may supply a fraction in the form "1/2" or a decimal in the form ".5", "0.5", "5e-1", etc.' )
27 def reduce ( bot
, user
, chan
, realtarget
, * args
):
28 supplied_value
= '' . join ( args
)
30 frac
= Fraction ( supplied_value
)
32 return 'Invalid fraction supplied. You must supply a fraction in the form "1/2" or a decimal in the form ".5", "0.5", "5e-1", etc.'
33 return " %s = %s " % ( supplied_value
, frac
)