clragon / swan

bring elegance to your flutter discussions
https://discord.gg/rflutterdev
MIT License
3 stars 0 forks source link

SWAN

Swan helps bring elegance to your flutter discussions.

Plugins

Simple Widget Annotation

Quickly generate Flutter widget trees from a simple text-based syntax.

Syntax

Simple Widget Annotation (SWA) is a text-based syntax that allows you to describe Flutter widget trees in a concise manner.

Example

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.

Usage

To trigger a code generation from the bot,

A 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.

Skull emoji

Delete the bot's response with a skull emoji.

Usage

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.

StackOverflow Mirror

Print StackOverflow questions in a Discord channel.
This feature works better with an API key. See Setup.

Usage

To trigger a StackOverflow question mirror,

Pastebin Uploader

Upload files to Pastebin. This feature requires an API key. See Setup.

Usage

To upload a file to Pastebin,

Dependencies

Setup

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: .

Docker

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