diff -r 9880bb697149 -r ac07779f788d mod_util.py --- a/mod_util.py Mon Jan 19 16:42:36 2015 -0500 +++ b/mod_util.py Sat Apr 11 21:02:09 2015 +0300 @@ -5,6 +5,7 @@ import re from modulecore import command_error import modulecore as ModuleCore +import utility ModuleData = { 'commands': @@ -64,6 +65,13 @@ 'args': None, 'level': 'normal', }, + + { + 'name': 'bitly', + 'description': 'Shortens a link using bit.ly', + 'args': '', + 'level': 'normal' + }, ] } @@ -161,7 +169,7 @@ expr = mathsubstitute (expr, 'e' , 2.71828182845904523536028747135266249775724709369995) expr = mathsubstitute (expr, 'phi', 1.6180339887498948482) # golden ratio - result = subprocess.check_output (['calc', expr], stderr=subprocess.STDOUT) \ + result = subprocess.check_output (['calc', '--', expr], stderr=subprocess.STDOUT) \ .replace ('\t', '') \ .replace ('\n', '') @@ -177,11 +185,14 @@ except OSError as e: command_error ('failed to execute calc: ' + e.strerror) -def cmd_more (bot, replyto, **rest): - ModuleCore.print_responses (bot, replyto) +def cmd_more (commandObject, **rest): + ModuleCore.print_responses (commandObject) def cmd_yes (**k): ModuleCore.confirm (k, True) def cmd_no (**k): ModuleCore.confirm (k, False) + +def cmd_bitly (reply, args, **k): + reply ('Result: %s' % utility.shorten_link (args['link']))