diff --git a/pyproject.toml b/pyproject.toml index 1cd12796b7..e8b34d2a88 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,6 +54,7 @@ dependencies = [ "importlib_metadata>=3.6", "packaging", "sopel-help>=0.4.0", + "sopel-py>=1.0.1", # TODO: drop for 8.1 ] [project.urls] diff --git a/sopel/modules/py.py b/sopel/modules/py.py deleted file mode 100644 index 4f134323ce..0000000000 --- a/sopel/modules/py.py +++ /dev/null @@ -1,65 +0,0 @@ -""" -py.py - Sopel Python Eval Plugin -Copyright 2008, Sean B. Palmer, inamidst.com -Licensed under the Eiffel Forum License 2. - -https://sopel.chat -""" -from __future__ import annotations - -from requests import get - -from sopel import plugin -from sopel.config import types -from sopel.tools.web import quote - - -class PySection(types.StaticSection): - oblique_instance = types.ValidatedAttribute( - 'oblique_instance', - default='https://oblique.sopel.chat/') - """The Oblique instance to use when evaluating Python expressions""" - - -def configure(config): - """ - | name | example | purpose | - | ---- | ------- | ------- | - | oblique_instance | https://oblique.sopel.chat/ | The Oblique instance to use when evaluating Python expressions (see ) | - """ - config.define_section('py', PySection) - config.py.configure_setting( - 'oblique_instance', - 'Enter the base URL of a custom Oblique instance (optional): ' - ) - - -def setup(bot): - bot.config.define_section('py', PySection) - - if not any( - bot.config.py.oblique_instance.startswith(prot) - for prot in ['http://', 'https://'] - ): - raise ValueError('Oblique instance URL must start with a protocol.') - - if not bot.config.py.oblique_instance.endswith('/'): - bot.config.py.oblique_instance += '/' - - -@plugin.command('py') -@plugin.output_prefix('[py] ') -@plugin.example('.py len([1,2,3])', '3', online=True, vcr=True) -def py(bot, trigger): - """Evaluate a Python expression.""" - query = trigger.group(2) - if not query: - bot.reply('What expression do you want me to evaluate?') - return - - uri = bot.config.py.oblique_instance + 'py/' - answer = get(uri + quote(query)).content.decode('utf-8') - if answer: - bot.say(answer) - else: - bot.reply('Sorry, no result.') diff --git a/test/vcr/modules/py/test_example_py_0.yaml b/test/vcr/modules/py/test_example_py_0.yaml deleted file mode 100644 index b41cf7a754..0000000000 --- a/test/vcr/modules/py/test_example_py_0.yaml +++ /dev/null @@ -1,23 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: ['*/*'] - Accept-Encoding: ['gzip, deflate'] - Connection: [keep-alive] - User-Agent: [python-requests/2.24.0] - method: GET - uri: https://oblique.sopel.chat/py/len%28%5B1%2C2%2C3%5D%29 - response: - body: {string: '3 - -'} - headers: - Cache-Control: [no-cache] - Content-Length: ['2'] - Content-Type: [text/plain] - Date: ['Fri, 09 Oct 2020 04:40:29 GMT'] - Server: [Google Frontend] - X-Cloud-Trace-Context: [ca53ebf0dbb861ffcceed76af746c923;o=1] - status: {code: 200, message: OK} -version: 1