"""Tiny Firebird echo bot.

This is the fastest useful bot to deploy. It listens for both classic
message commands and a slash command.

Before running:
  pip install .
  set FIREBIRD_BASE_URL=https://firebird.gg
  set FIREBIRD_BOT_TOKEN=fb_bot_...

Try in chat:
  !ping
  !echo hello from Firebird
  /echo hello from slash commands
"""

from firebird_bot import BotClient


bot = BotClient()


@bot.command("ping")
def ping(ctx):
    ctx.reply("Pong.")


@bot.command("echo")
def echo_message(ctx):
    ctx.reply(ctx.args or "Give me a little text to echo.")


@bot.slash_command(
    "echo",
    description="Repeat a short message.",
    options=[
        {
            "name": "text",
            "type": "string",
            "description": "Text to send back",
            "required": False,
        }
    ],
)
def echo_slash(ctx):
    ctx.reply(ctx.args or "Give me a little text to echo.")


@bot.event("member_join")
def welcome(event):
    identity = event.payload.get("identity")
    if identity:
        print(f"{identity} joined server {event.server_id}")


if __name__ == "__main__":
    bot.run_forever()
