Swan helps bring elegance to your flutter discussions.
Quickly generate Flutter widget trees from a simple text-based syntax.
Simple Widget Annotation (SWA) is a text-based syntax that allows you to describe Flutter widget trees in a concise manner.
Column > [ Center > Icon(Icons.help), Text('Hello, world!') ]
The above SWA code will generate the following Dart code:
Column(
children: [
Center(
child: Icon(Icons.help),
),
Text('Hello, world!'),
],
);
SWA syntax is flexible.
You may omit or add as many spaces or newlines as you like.
You may also omit the >
character before a list of children.
To trigger a code generation from the bot,
.swa
followed by the SWA code..swa Column [ Text('Hello, world!') ]
swa
as the language identifier.swa
extensionA maximum of 5 sources of SWA code will be processed per message.
To see the help message, send a message with just .swa
in it.
The SWA parser is based on an EBNF grammar.
The full grammar is available here.
You can test it on this website.
Delete the bot's response with a skull emoji.
React to a bot response with the 💀 emoji to delete it. This only works if you are the author of the message that triggered the bot.
Print StackOverflow questions in a Discord channel.
This feature works better with an API key. See Setup.
To trigger a StackOverflow question mirror,
.flow
followed by a StackOverflow link..flow
.Upload files to Pastebin. This feature requires an API key. See Setup.
To upload a file to Pastebin,
.paste
, and attach a file (or multiple) to it..paste
.To run the bot, you need to provide it with a Discord bot token.
You can get one by creating a new application on the Discord Developer Portal.
Once you have a token, create a file named .env
in the root directory of the project and add the following line to it:
DISCORD_BOT_TOKEN=your_token_here
For additional plugins, you may need to provide extra API keys:
STACKEXCHANGE_API_KEY=your_key_here # optional, but recommended
PASTEBIN_API_KEY=your_key_here # required for the pastebin plugin
You can also specify a custom prefix for the bot:
BOT_PREFIX=your_prefix_here # default: .
You can run the bot in a Docker container. A pre-built image is available in the releases section.
To run your image, load the image:
docker load -i app_image_*.tar
then create a docker compose file with the following content:
version: "3.8"
services:
swan:
image: swan:latest
volumes:
- ./.env:/.env
- config:/config
volumes:
config:
Then, run:
docker compose up -d