1212
1313
1414@plugin .command ('c' , 'calc' )
15+ @plugin .example ('.c' , 'Nothing to calculate.' )
16+ @plugin .example ('.c foo * bar' , "Can't process expression: Node type 'Name' is not supported." )
17+ @plugin .example ('.c 10 / 0' , 'Division by zero is not supported in this universe.' )
18+ @plugin .example ('.c 10\\ 2' , 'Invalid syntax' )
19+ @plugin .example ('.c (10**1000000)**2' ,
20+ "Error running calculation: "
21+ "ValueError('Pow expression too complex to calculate.')" )
22+ @plugin .example ('.c (10**100000)**2 * (10**100000)**2' ,
23+ "Error running calculation: "
24+ "ValueError('Value is too large to be handled in limited time and memory.')" )
1525@plugin .example ('.c 5 + 3' , '8' )
1626@plugin .example ('.c 0.9*10' , '9' )
1727@plugin .example ('.c 10*0.9' , '9' )
18- @plugin .example ('.c 2*(1+2)*3' , '18' )
19- @plugin .example ('.c 2**10' , '1024' )
20- @plugin .example ('.c 5 // 2' , '2' )
21- @plugin .example ('.c 5 / 2' , '2.5' )
28+ @plugin .example ('.c 0.5**2' , '0.25' )
29+ @plugin .example ('.c 3**0' , '1' )
30+ @plugin .example ('.c 0 * 5' , '0' )
31+ @plugin .example ('.c 5**5' , '3125' )
32+ @plugin .example ('.c 2*(1+2)*3' , '18' , user_help = True )
33+ @plugin .example ('.c 2**10' , '1024' , user_help = True )
34+ @plugin .example ('.c 5 // 2' , '2' , user_help = True )
35+ @plugin .example ('.c 5 / 2' , '2.5' , user_help = True )
2236@plugin .output_prefix ('[calc] ' )
2337def c (bot , trigger ):
2438 """Evaluate some calculation."""
@@ -39,5 +53,8 @@ def c(bot, trigger):
3953 except SyntaxError :
4054 bot .reply ('Invalid syntax' )
4155 return
56+ except ValueError as err :
57+ bot .reply ("Error running calculation: %r" % err )
58+ return
4259
4360 bot .say (result )
0 commit comments