| Conditions | 3 |
| Total Lines | 15 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | # coding=utf-8 |
||
| 29 | @module.commands('py') |
||
| 30 | @module.output_prefix('[py] ') |
||
| 31 | @module.example('.py len([1,2,3])', '3', online=True) |
||
| 32 | def py(bot, trigger): |
||
| 33 | """Evaluate a Python expression.""" |
||
| 34 | if not trigger.group(2): |
||
| 35 | return bot.reply('I need an expression to evaluate.') |
||
| 36 | |||
| 37 | query = trigger.group(2) |
||
| 38 | uri = BASE_TUMBOLIA_URI + 'py/' |
||
| 39 | answer = get(uri + quote(query)).content.decode('utf-8') |
||
| 40 | if answer: |
||
| 41 | bot.say(answer) |
||
| 42 | else: |
||
| 43 | bot.reply('Sorry, no result.') |
||
| 44 | |||
| 49 |