progdisc / awesome_bot

Discord bot powered by awesomeness!
Apache License 2.0
0 stars 1 forks source link

Bot core proposal #4

Open saethlin opened 6 years ago

saethlin commented 6 years ago

We want to serve a large programming community with varying competency. For this reason I would like to have a core bot built in Python using discord.py, and very quickly dispatch in a generic way into modules that can be written in any language. The onus is on the contributor to integrate whatever language they're using.

I think the core bot should look something like this:

from modules import *

commands = {
    'weather': weather.weather,
    'eval': runner.evaluate,
}

async def on_message_or_whatever():
    if command in commands:
        post_message(commands[payload]())

Where we pull in everything with a modules directory, which will contain the entry point for every command, regardless of what language it is written in. We define a dictionary or config file that maps bot string commands such as !bot weather onto a Python function that takes the contents of the message, and returns the contents of a reply message. The primary job of the core bot is to dispatch to handlers, and to avoid making this overcomplicated so that people unfamiliar with Python have little difficulty integrating their work.

LaVieEstDure commented 6 years ago

Sounds good to me. I can see the flow going something like

run bot->
on_message event handler called->
redirects to command handler in bot core->
bot core either connects to something that links languages in core, 
  or a module that links to other language on its own -> 
function called and returned, and answer posted by bot

The on_message event handler definitely works with discord.py. I think Mathbot does it, so someone can take some inspiration from there if needed.

seekheart commented 6 years ago

I like it, can we finalize on what the directory should look like?

saethlin commented 6 years ago

All the basic stuff at the top level, and put all the commands in a directory. Now add something already.

seekheart commented 6 years ago

How do we wanna call the bot in the server? !bot <cmd> is what it was and I was thinking -ab <cmd> for new version?

saethlin commented 6 years ago

Sounds good to me. I would prefer something more specific that just calling it bot

Samoxive commented 6 years ago

Prefix can be dynamic, we can pick a placeholder for now and make awesomebot fetch prefix from the config.