Giter VIP home page Giter VIP logo

merely-framework's Introduction

Merely logo

Merelybot

Python build status Merelybot is an extended feature-set framework for Disnake bots. Adding features like configuration-defined bots, hot-reloading of code, a feature rich help command, translation support, authorization, security, error handling, and paywalled commands.

Featured implementations

You can test these implementations on my official Discord server.

  • Merely is an example implementation of the framework. Merely uses the default config included with this code so you can run it yourself.
  • ConfessionBot is an anonymous messaging system for Discord. ConfessionBot uses the help command, translation support, and module reloading features to speed up development and shares improvements to the framework back here.

News

Seven languages are now supported! English, German, French, Polish, Brazilian Portugese, Tagalog, and Chinese are all available to choose with /language set today, but most are incomplete. MerelyBot now also follows your user and server language preferences by default.

See live translation stats and contribute >

MerelyBot v1.2.0 has launched! This update marks the completed migration to slash commands, which comes with countless performance and usability improvements. Some highlights are the newly-polished /poll and ReactRoles now catch up after any interruptions.

See the roadmap for future updates >

Usage

  • Clone the project to a folder
  • Install python >= 3.10
  • Install required python packages with python3 -m pip install -r requirements.txt
  • Create a discord bot in the Discord Developer Portal, you will need the token to continue
  • Give MerelyBot the token by setting it in the [main] section of the config
  • Run MerelyBot with python3 merelybot.py
  • Add your instance of merely to your server
  • optional: create a log channel on your server and copy the id to merely_data/config.ini > logchannel. - you can also do the same with a channel for feedback and a channel for moderators.

The first run generates a config.ini file, you can modify it from there to enable features.

Contributing

The best way to contribute is to create your own discord bot using this framework, and send any improvements to the framework my way in the form of a pull request!

Translation

I have built a website which makes it easier to translate my projects, including Merely-Framework. Babel Translator.

Code contribution

Merely-Framework is written in Python with the help of the disnake API wrapper (like discord.py). Refer to the Project roadmap for future features we'd like to implement. All contributions are welcome and support can be given in the Discord server.

Design

Merely is a highly customizable and extensible framework for discord bots. through the config file, people can enable and disable extensions, change the bot name, and configure extensions. Developers can even write their own extensions to further extend the Merely Framework.

Code structure

Extensions should operate entirely independant of each other and should rarely need to communicate with each other. Extensions must inherit from the disnake.ext.commands.Cog class and bind themselves on import. Effort should be made to avoid clashes with existing commands. extensions/example.py should demonstrate all of this.

Writing a different bot using the framework

If you would like to make a bot that changes functionality of existing commands or strings, you may want to use an overlay. Create a folder named 'overlay' in this directory, refer to the source code for ConfessionBot to see an example of how an overlay is structured. Note that babel is given a language file prefix so Merely Language files can still be inherited from.

This overlay system allows for improvements to the framework to be easily shared upstream and downstream.

Strings

As the Babel language framework is being used, there's no need to provide strings for your code. Myself and the volunteer translators can add strings later. In place of strings, simply invent a meaningful key, for example;

self.bot.babel('example', 'echo', content=userinput)
# Appears like the following until a string is written:
"<ECHO: content={content}>"
# An example of a written string:
"You said: \"{content}\"."

If you wish to provide strings, add them to babel/en.ini.

File structure

  • Core plugins are stored in the top directory, these elements cannot be reloaded or disabled. Reloading babel or config refreshes the data, but not the code.
  • Extensions are placed in the extensions folder, from there, they will be added to the config and can be enabled.
  • Config and config history will be found in the config folder.
  • Translation data is stored in the babel folder.
  • Error and usage logs are stored in the logs folder.

Extensions

Extension Description Ver. Added
main* imports extensions, creates some global variables, establishes a log, and runs the main loop N/A
config* reads configuration data and ensures that the config file is valid 1.0
babel* provides translated and formatted strings that contributors can easily translate to more languages 1.0
auth* provides security checks for other commands which need authorization 1.0
utilities provides useful functions and other shared code between extensions 1.2.2
error provides error handling for all other extensions so they don't have to 1.0
log allows for logging to file, or to a text channel in a rich format 1.0
help** help, about - lists featured commands and fetches translated usage instructions 1.0
language language - allows bot users to change the language or request a translation 1.0
admin die, janitor, clean, purge - power tools for server administrators 1.0
dice dice - a simple dice rolling command with some advanced features 1.0
emoji emoji, thonk - allows non-nitro users to use a selection of custom emojis 1.0
eventmsg eventmsg - automated messages in response to user actions 1.0
poll poll - adds polls to discord with an interactive poll builder and countdown timers 1.0
reactroles reactrole - adds reaction roles to discord with an interactive setup 1.0
system module, die - modify behaviour of the bot while it's running 1.2
premium premium - locks select features behind a paywall, using a premium role to check 1.0
------ ----------- -----
example ping - example commands for getting started on writing your own extension 1.0
  • * = must be imported for minimal functionality
  • ** = must be imported, or replaced with a compatible replacement

merely-framework's People

Contributors

duncy avatar ooxxe04 avatar yiays avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

ooxxe04 gebow4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.