Initial commit

Based on
https://github.com/zrgn/ZargBot/blob/master/zargbot/plugins/figlet.py
and https://github.com/maubot/echo

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2023-11-07 01:44:52 +00:00
commit 1eac11cda4
Signed by: vbatts
GPG Key ID: E30EFAA812C6E5ED
4 changed files with 46 additions and 0 deletions

9
LICENSE Normal file
View File

@ -0,0 +1,9 @@
MIT License
Copyright (c) 2023 vbatts
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

2
README.md Normal file
View File

@ -0,0 +1,2 @@
# maubot_figlet

26
figlet.py Normal file
View File

@ -0,0 +1,26 @@
import random
import pyfiglet
from maubot import Plugin, MessageEvent
from maubot.handlers import command
class FigletBot(Plugin):
@command.new("figlet", help="display text in large ascii fonts")
@command.argument("message", pass_raw=True)
async def figlet_handler(self, evt: MessageEvent, message: str) -> None:
message = message.strip()
fonts = pyfiglet.FigletFont.getFonts()
if message.lower() == 'star wars' and 'starwars' in fonts:
fontname = 'starwars'
elif message.lower() == 'star trek' and 'trek' in fonts:
fontname = 'trek'
else:
fontname = fonts[random.randint(0, len(fonts) - 1)]
fig = pyfiglet.Figlet(font=fontname)
msg = f'Rendering with: {fontname}\n\n```'
msg += fig.renderText(message)
msg += '\n```'
await evt.respond(msg)

9
maubot.yaml Normal file
View File

@ -0,0 +1,9 @@
maubot: 0.1.0
id: cloud.batts.figlet
version: 0.5.0
license: MIT
modules:
- figlet
dependencies:
- pyfiglet
main_class: FigletBot