mirror of
https://gitlab.com/octospacc/WinDog.git
synced 2025-06-05 22:09:20 +02:00
Legacy removals, code restructuring, add send_... functions and better help
This commit is contained in:
@ -1,23 +1,21 @@
|
||||
# ================================== #
|
||||
# WinDog multi-purpose chatbot #
|
||||
# Licensed under AGPLv3 by OctoSpacc #
|
||||
# ================================== #
|
||||
# ==================================== #
|
||||
# WinDog multi-purpose chatbot #
|
||||
# Licensed under AGPLv3 by OctoSpacc #
|
||||
# ==================================== #
|
||||
|
||||
import hashlib
|
||||
|
||||
def cHash(context:EventContext, data:InputMessageData):
|
||||
text_input = (data.command.body or (data.quoted and data.quoted.text_plain))
|
||||
algorithm = data.command.arguments.algorithm
|
||||
language = data.user.settings.language
|
||||
if not (text_input and (algorithm in hashlib.algorithms_available)):
|
||||
return SendMessage(context, {
|
||||
"text_html": f'{context.endpoint.help_text(language)}\n\n{context.endpoint.get_string("algorithms", language)}: {hashlib.algorithms_available}'})
|
||||
hashed = hashlib.new(algorithm, text_input.encode()).hexdigest()
|
||||
return SendMessage(context, {"text_html": f"<pre>{hashed}</pre>"})
|
||||
return send_status_400(context, data.user.settings.language)
|
||||
return send_message(context, {
|
||||
"text_html": f"<pre>{html_escape(hashlib.new(algorithm, text_input.encode()).hexdigest())}</pre>"})
|
||||
|
||||
RegisterModule(name="Hashing", group="Geek", endpoints=[
|
||||
SafeNamespace(names=["hash"], handler=cHash, body=False, quoted=False, arguments={
|
||||
"algorithm": True,
|
||||
}),
|
||||
}, help_extra=(lambda endpoint, lang: f'{endpoint.get_string("algorithms", lang)}: <code>{"</code>, <code>".join(hashlib.algorithms_available)}</code>.')),
|
||||
])
|
||||
|
||||
|
Reference in New Issue
Block a user