Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/YousefEZ/discord-qalib
👾 Discord library built on discord.py to simplify source code by rendering markup (xml) templates of embeds and menus (Pagination).
https://github.com/YousefEZ/discord-qalib
deserializer discord discord-jinja discord-menu discord-paginator discord-py discord-qalib discord-templating engine flask jinja jinja2 pagination paginator python template template-engine templates templating templating-engine
Last synced: about 2 months ago
JSON representation
👾 Discord library built on discord.py to simplify source code by rendering markup (xml) templates of embeds and menus (Pagination).
- Host: GitHub
- URL: https://github.com/YousefEZ/discord-qalib
- Owner: YousefEZ
- License: mit
- Created: 2022-11-08T21:13:28.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-25T11:57:43.000Z (3 months ago)
- Last Synced: 2024-09-25T22:20:15.485Z (3 months ago)
- Topics: deserializer, discord, discord-jinja, discord-menu, discord-paginator, discord-py, discord-qalib, discord-templating, engine, flask, jinja, jinja2, pagination, paginator, python, template, template-engine, templates, templating, templating-engine
- Language: Python
- Homepage: https://yousefez.github.io/discord-qalib/
- Size: 1.01 MB
- Stars: 14
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-discordpy - YousefEZ/discord-qalib - Discord library built on discord.py to simplify source code by rendering markup (xml) templates of embeds and menus (Pagination). (Libraries and Extensions / Miscellaneous)
README
[![Discord-Qalib Tests](https://github.com/YousefEZ/discord-qalib/actions/workflows/discord-qalib.yml/badge.svg)](https://github.com/YousefEZ/discord-qalib/actions/workflows/discord-qalib.yml)
[![codecov](https://codecov.io/gh/YousefEZ/discord-qalib/branch/main/graph/badge.svg?token=3EG4ZF8K3R)](https://codecov.io/gh/YousefEZ/discord-qalib)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/b6a528f00dc7418c9cd15b0d120d8297)](https://www.codacy.com/gh/YousefEZ/discord-qalib/dashboard?utm_source=github.com&utm_medium=referral&utm_content=YousefEZ/discord-qalib&utm_campaign=Badge_Grade)
![Python Version](https://img.shields.io/badge/python-3.8%20%7C%203.9%20%7C%203.10-informational)
Discord templating engine built on discord.py, to help separate text of embeds from the source code. Inspired by Flask.
-----
Key Features:* use of xml files to hold the various template responses
* allows for pagination, in an abstract form simplifying the interface in the source code-----
## :gear: Installing:
Python3.8 or higher is required
## :test_tube: Tests
To run the tests, run the following command in the root directory:
Windows:
```bash
python -m unittest tests -v
```Linux:
```bash
python3 -m unittest tests -v
```## :zap: Usage
_This is explained in more detail in the [wiki](https://github.com/YousefEZ/discord-qalib/wiki)_
Wrap expressions that need to evaluated with ``{}``, such as ``{player.name}`` or ``{todays_date}``
Sample XML file:
```xml
Test
Test Description
magenta
{todays_date}
https://www.discord.com
Test Field
Test Text
Test Footer
https://cdn.discordapp.com/embed/avatars/0.png
https://cdn.discordapp.com/embed/avatars/0.png
https://cdn.discordapp.com/embed/avatars/0.png
Test Author
https://cdn.discordapp.com/embed/avatars/0.png
https://discordapp.com
Understood
success
```
using the above xml file, for example, you can create an embed with the following code:
```python
import datetime
from typing import Literalimport discord
from discord.ext import commandsimport qalib
from qalib.template_engines import formatterbot = commands.AutoShardedBot(command_prefix="!", intents=discord.Intents.all())
Messages = Literal["test_key"]
async def acknowledged(interaction: discord.Interaction):
await interaction.response.send_message("Acknowledged", ephemeral=True)@bot.command()
@qalib.qalib_context(formatter.Formatter(), "templates/test.xml")
async def test(ctx: qalib.QalibContext[Messages]):
callables = {"understood_button": acknowledged}await ctx.rendered_send("test_key", callables, keywords={
"todays_date": datetime.datetime.now()
})
```