1
0
mirror of https://github.com/gsi-upm/senpy synced 2024-11-14 12:42:27 +00:00
senpy/example-plugin/example_plugin.py
J. Fernando Sánchez c52a894017 Merged into monorepo
2018-06-14 19:38:08 +02:00

38 lines
1005 B
Python

from senpy.plugins import Analysis
from senpy.models import Response, Entry
import logging
logger = logging.getLogger(__name__)
class ExamplePlugin(Analysis):
'''A *VERY* simple plugin that exemplifies the development of Senpy Plugins'''
name = "example-plugin"
author = "@balkian"
version = "0.1"
extra_params = {
"parameter": {
"@id": "parameter",
"aliases": ["parameter", "param"],
"required": True,
"default": 42
}
}
custom_attribute = "42"
def analyse_entry(self, entry, params):
logger.debug('Analysing with the example.')
logger.debug('The answer to this response is: %s.' % params['parameter'])
resp = Response()
entry['example:reversed'] = entry.text[::-1]
entry['example:the_answer'] = params['parameter']
yield entry
test_cases = [{
'input': 'hello',
'expected': {
'example:reversed': 'olleh'
}
}]