Misc updates, improve global API, start work on db and module strings

This commit is contained in:
2024-06-25 02:08:49 +02:00
parent 7d426e9497
commit 8f1b80ab14
26 changed files with 389 additions and 210 deletions

24
ModWinDog/Hashing/Hashing.py Executable file
View File

@ -0,0 +1,24 @@
# ================================== #
# WinDog multi-purpose chatbot #
# Licensed under AGPLv3 by OctoSpacc #
# ================================== #
import hashlib
def cHash(context:EventContext, data:InputMessageData):
text_input = ObjGet(data, "command.body")
algorithm = ObjGet(data, "command.arguments.algorithm")
if not (text_input and (algorithm in hashlib.algorithms_available)):
return SendMessage(context, {"Text": choice(Locale.__('hash.usage')).format(data.command.tokens[0], hashlib.algorithms_available)})
hashed = hashlib.new(algorithm, text_input.encode()).hexdigest()
return SendMessage(context, {
"TextPlain": hashed,
"TextMarkdown": MarkdownCode(hashed, True),
})
RegisterModule(name="Hashing", group="Geek", summary="Functions for hashing of textual content.", endpoints=[
SafeNamespace(names=["hash"], summary="Responds with the hash-sum of a message received.", handler=cHash, arguments={
"algorithm": True,
}),
])