Skip to content

Commit

Permalink
feat: add a discord bot interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
paquiteau committed Jun 18, 2023
1 parent 10bed03 commit 85d03fc
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/nbb/bot_discord.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env python3

import os

from nbb.models import get_message
from nbb.config import get_config
import discord
from discord.ext import commands

intents = discord.Intents.default()
intents.message_content = True

bot = commands.Bot(command_prefix="!", intents=intents)

CONF = get_config()

DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None) or CONF["discord"]["token"]


@bot.command(
help="Get next bus at some stops.",
brief="Get next bus at some stops.",
)
async def nbb(ctx, *args):
"""Get next bus from the command line."""
if len(args) == 0:
args = [None]
await ctx.channel.send(get_message(CONF, args[0]))


bot.run(DISCORD_TOKEN)

0 comments on commit 85d03fc

Please sign in to comment.