208 reply ('Available functions for .calc: %s' % \ |
207 reply ('Available functions for .calc: %s' % \ |
209 ', '.join (sorted ([name for name, data in calc.Functions.items()]))) |
208 ', '.join (sorted ([name for name, data in calc.Functions.items()]))) |
210 |
209 |
211 def cmd_calc (bot, reply, args, **rest): |
210 def cmd_calc (bot, reply, args, **rest): |
212 reply (calc.Calculator().calc (args['expression'])) |
211 reply (calc.Calculator().calc (args['expression'])) |
213 # expr = args['expression'] |
|
214 # try: |
|
215 # Substitute some mathematical constants |
|
216 # expr = mathsubstitute (expr, 'pi' , 3.14159265358979323846264338327950288419716939937510) |
|
217 # expr = mathsubstitute (expr, 'e' , 2.71828182845904523536028747135266249775724709369995) |
|
218 # expr = mathsubstitute (expr, 'phi', 1.6180339887498948482) # golden ratio |
|
219 |
|
220 # result = subprocess.check_output (['calc', '--', expr], stderr=subprocess.STDOUT) \ |
|
221 # .replace ('\t', '') \ |
|
222 # .replace ('\n', '') |
|
223 |
|
224 # errmatch = re.compile (r'^.*\bError\b.*$').match (result) |
|
225 |
|
226 # if errmatch: |
|
227 # command_error ('math error') |
|
228 # return |
|
229 |
|
230 # reply ('Result: %s' % result) |
|
231 # except subprocess.CalledProcessError as e: |
|
232 # command_error (e.output.split('\n')[0]) |
|
233 # except OSError as e: |
|
234 # command_error ('failed to execute calc: ' + e.strerror) |
|
235 |
212 |
236 def cmd_more (commandObject, **rest): |
213 def cmd_more (commandObject, **rest): |
237 ModuleCore.print_responses (commandObject) |
214 ModuleCore.print_responses (commandObject) |
238 |
215 |
239 def cmd_yes (**k): |
216 def cmd_yes (**k): |