Shedding a new skin on Dis-Snek's commands.

Overview

PyPI Downloads Code style: black

Molter - WIP

Shedding a new skin on Dis-Snek's commands.

Currently, its goals are to make message commands more similar to discord.py's message commands.

Installing

pip install molter

Example

Load this as a normal scale in dis_snek

import dis_snek
import molter
from typing import Optional


class CommandTest(dis_snek.Scale):

    @molter.msg_command()
    async def test(
        self,
        ctx: dis_snek.MessageContext,
        a_num: int,
        a_user: Optional[dis_snek.Member],
        a_bool: bool,
    ):
        await ctx.message.reply(f"{a_num} {a_user} {a_bool}")


def setup(bot):
    CommandTest(bot)

Note

  • This project is a work in progress - it is very unstable and potentially very broken. Basic testing has been done, but more is still required.
  • Typing.Literal and discord.py's Greedy have not been added yet. Similar features to them are planned to be added in the future.
Comments
  • feat: basic help message

    feat: basic help message

    This is a basic implementation of a help command to tick off one of your points in #3.

    Pre-merge utilisation of this is fairly simple

    class bot(Snake):
        def __init__(sefl, ...):
            help = HelpCommand(self, show_params=True, ...)
            help.register()
    

    To modify it, pre-merge, i really think just overriding is the way to go. Post merge i would like to introduce some sort of client method to modify help.

    This pr is dependant on dev-latest of dis-snake. Specifically https://github.com/Discord-Snake-Pit/Dis-Snek/commit/af6402230b409be638f45e12f80710dc99e2efb2

    opened by LordOfPolls 5
  • feat: basic help message

    feat: basic help message

    Re-open of #5 due to unresolvable branch conflict issues.

    This is a basic implementation of a help command to tick off one of your points in #3.

    Pre-merge utilisation of this is fairly simple

    class bot(Snake):
        def __init__(sefl, ...):
            help = HelpCommand(self, show_params=True, ...)
            help.register()
    

    To modify it, pre-merge, i really think just overriding is the way to go. Post merge i would like to introduce some sort of client method to modify help.

    This pr is dependant on dev-latest of dis-snake. Specifically https://github.com/Discord-Snake-Pit/Dis-Snek/commit/af6402230b409be638f45e12f80710dc99e2efb2

    enhancement 
    opened by LordOfPolls 1
  • feat: annotation > converter specifiers

    feat: annotation > converter specifiers

    An idea discussed on the dis-snek server was the idea to allow normal annotations to be use in Molter commands by tying a converter to them. This is what is done for dis-snek objects, actually, but allowing user-defined "injections" would be nice as well.

    Take, for example:

    
    @molter.msg_command()
    @molter.register_converter(CustomClass, CustomClassConverter)
    async def test(ctx: Context, class_var: CustomClass):
        ...
    

    Molter would be able to take care of the conversion just with that decorator.

    This PR is not done and in fact is just a draft. Reviews and contributions are encouraged.

    enhancement 
    opened by AstreaTSS 1
  • [DISCUSSION] Parameter Analyzing and the Merge

    [DISCUSSION] Parameter Analyzing and the Merge

    This isn't quite about a bug or the like. Think of it like a subissue of #3, but it's just a design discussion that have to do with the merge:tm:.

    As of right now, molter (essentially) analyzes parameters (for its own use) upon function decoration. This may seem sane, but there is one issue: dealing with self parameters (or rather finding out when they're there and ignoring them if they are).

    self isn't exactly a special variable in Python - it can be named anything, and isn't typehinted or marked as anything special. We want to avoid it if it is there (it's always possible to declare a command in __main__, and is intended behavior), but... well, we can't. Not really.

    molter does the next best thing and checks if the function is "nested" - if it's in something, classes included. Based on that, we can theoretically ignore self if it is. However, this method uses a hack and is a hack, having many cases where this would fail. As such, another method is likely needed. Maybe.

    There aren't any better ways until molter is merged, but once it is...

    Solution 1

    Analyze the function as it is being added to the bot's dicts of prefix commands. As this is done with the context needed to determine if the command is in a scale (or in the bot class) or not, this is possible.

    The best way to do this is likely to add an extra argument to add_message_command that indicates if the underlying function has a self statement or not (defaulting to it not), and then running the parameter analyzing in the function itself. This also allows people adding their own commands manually to have some sort of control over that process, too.

    Basically:

    def add_message_command(command: MessageCommand, *, has_self: bool = False):
        command.parse_parameters(has_self=has_self)
        ... # rest of logic here
    
    # scales and in-bot commands can simply make has_self True when running that
    

    There is one drawback: if invalid parameters are passed (an invalid converter, etc.), then the user won't found out it's invalid until the bot is loaded. However, this method has the benefit of allowing all associate_converters to be associated before the command is parsed, meaning we don't have to dig into the parsed parameters to replace things as needed.

    Solution 2

    Analyze all parameters (minus whatever one's the first one) on function decoration. Then, if the command is being loaded in a place that indicates the function has self, edit the parameters list so that the first element is removed.

    This is very simple, in like with what dis-snek does, and allows for errors to happen pretty early on. However, this means that associated converters have to do what they currently do and dig into the current parameters to adjust them as needed, which is somewhat ugly. This also makes globally_associate_converter not be able to apply retroactively, and also makes it a pain to do if we do what Silasary mentioned here, as, well, we wouldn't get the bot's associated converters until after the parameters have been parsed and messed around (and so they would have to be messed around with *again).

    Conclusion

    I'm leaning towards solution 1 personally, but I'm curious to see what everyone else thinks. I also do wonder if it's even worth the pain when the hack works... fine in most cases. Again, I'm looking for ideas and feedback, so do say your thoughts!

    help wanted 
    opened by AstreaTSS 0
  • merge: dev > main

    merge: dev > main

    This will be accomplished via a force push due to their differing commit histories. This PR is more just a note that this will happen. A new version will be released soon after doing so to support dis-snek 8.0.0.

    Is waiting on #7 and #8.

    opened by AstreaTSS 0
  • merge: merge merge into dev

    merge: merge merge into dev

    Funny title, haha.

    With the merge to dis-snek basically being not very viable right now, I figured it would be a good idea just to merge everything from merge into dev. The branches don't really need to be separate, nor do I want to throw away the work done on merge.

    This will likely require force pushing and rebasing.

    opened by AstreaTSS 0
  • [FEAT] Merge with `dis-snek`

    [FEAT] Merge with `dis-snek`

    This was the end goal, after all. Fixes dis-snek's #392.

    Merging molter is not an easy task. Ideally, it would be done before the beta soft deadline, but if this is not complete, this should not hold dis-snek back from going into beta.

    In terms of molter itself, there's a few things that need to be finished up:

    • [x] Bug fixing, obviously. Not many people have used the advanced features, so that's something to consider.
    • [x] Making a help command. Technically, this isn't a strict requirement, but being honest, people who use message commands will want one - it's worth providing one under the ext namespace.
    • [x] Helper functions and properties, largely for:
      • [x] Allowing custom usage specifications instead of forcing people to use signature.
      • [x] Speaking of which, refactoring signature if possible.
      • [x] Probably more I can't think of quite yet. For Github's sake, this is going to be marked as done, but it might not be.
    • [x] At least finish the docstrings. Doing a whole page would be nice.
    • [ ] Subclassing BadArgument to have more specific errors. Is not strictly necessary to merge and may be ignored, but I'd prefer this being done.
    • [ ] Make invoked_name way better. It's, uh, a mess right now.
    • [x] Add command to Context in dis-snek itself.

    In terms of merging molter itself... yeah, that's going to be a doozy.

    • [x] A guide about how to use message commands would be a requirement at this point.
    • [x] Adjust Converter to either be not message command specific, or rename it to indicate it being so.
    • [x] File restructuring, separating message commands into its own file at the very least. I don't actually want to touch the BaseCommand too much.

    If anyone sees this and wants to help out, go ahead!

    help wanted 
    opened by AstreaTSS 11
Releases(v0.11.0)
  • v0.11.0(Apr 7, 2022)

    Oh lord is this update huge backend wise. Front-end wise, it's not horrible, but there's still a lot.

    And never mind on this being the last update... there's a lot that happened since then.

    What's Changed

    • FEAT💥: molter now uses dis-snek 8.0.0.
    • FEAT💥: Restructured and added channel converters. Some were removed/renamed in this process.
    • FEAT💥: MolterCommand.all_commands is now a frozenset instead of a tuple.
    • REFACTOR💥: MolterCommand.params has been renamed to MolterCommand.parameters.
    • FEAT: Added a basic help command for MolterCommands. (#8)
    • FEAT: Added register_converter to allow using normal annotations for commands while using Converters behind the scenes. (#7)
    • FEAT: MolterCommand.usage has been added, allowing you to specify how the command should be used if you don't like MolterCommand.signature.
    • FEAT: Make Converter's context Context instead of MessageContext so it has a chance of being used with other types of commands in the future.
    • FEAT: Make MolterCommand hashable.
    • FEAT/REFACTOR: Adjust parameter parsing to allow more control, allowing for MolterCommand.parse_parameters to be used by you if you need it.
    • REFACTOR: Much of the backend has changed to match up more closely with dis-snek's style.
    • REFACTOR: MolterCommand.signature has been redone. It may give slightly more accurate results.
    • DOCS: Added docstrings to many utility functions.
    • CI: pre-commit-related files were updated.

    New Contributors

    • @LordOfPolls made their first contribution in https://github.com/Discord-Snake-Pit/molter/pull/8

    Full Changelog: https://github.com/Discord-Snake-Pit/molter/compare/v0.9.1...v0.11.0

    Source code(tar.gz)
    Source code(zip)
  • v0.10.0(Mar 16, 2022)

    Minus bug fixes, this may be the second-to-final separated release of this version of molter. molter as an idea isn't exactly dead - I still want to go and see what I can do with slash commands and all - but it'll become more of a personal project that won't get merged with dis-snek ever rather than what it is now.

    What's Changed

    New Features

    • MolterSnake no longer rejects dis_snek.MessageCommand, and works with it and MolterCommands perfectly.
    • typing.Annotated support was added. molter assumes that it needs to use the second paramtere in the Annotation.
    • MessageConverter now uses a potentially faster method to get messages. At worst, it takes the same amount of time as the previous method.

    Bug Fixes

    • Arguments no longer get split at newlines.
    • MolterCommand.invoked_name now can have newlines if they were being used.
    • MolterCommand.get_command and MolterSnake.get_command work correctly with newlines now.
    • MolterCommand.remove_command no longer errors out with invalid names.
    • MolterCommand.qualified_name works correctly now.
    • MolterCommand.all_commands no longer errors out.

    Other

    • pre-commit's config was updated a bit.

    Full Changelog: https://github.com/Discord-Snake-Pit/molter/compare/v0.9.1...v0.10.0

    Source code(tar.gz)
    Source code(zip)
  • v0.9.1(Feb 27, 2022)

    Oops, haha.

    • Fix many converters erroring out due to incorrect getting/fetching.

    Full Changelog: https://github.com/Discord-Snake-Pit/molter/compare/v0.9.0...v0.9.1

    Source code(tar.gz)
    Source code(zip)
  • v0.9.0(Feb 27, 2022)

    This doesn't really feel like a major release, but semantic versioning is what it is because this update technically is breaking.

    • BREAKING: Upgrade to dis-snek 7.0.0, as it would have been annoying to support v6 and v7 at the same time.
      • No, this doesn't work with the latest dev version. A dev branch that closely follows dis-snek's dev branch is something I'm considering.
    • All converters that checked for an ID no longer check for an ID between 15-20 characters have been made so they only check for 15+ characters - who knows, maybe Discord will go over that limit.
    • Added a converter for dis_snek.Message, MessageConverter! This allows users to provide messages via a message link or a message ID, for example.

    Also, we're a part of the Snake-Pit organization now! Isn't that cool? Doesn't mean anything for this project beyond being officially recognized, though - merging with dis-snek isn't something that's going to be happening super soon.

    Full Changelog: https://github.com/Discord-Snake-Pit/molter/compare/v0.8.0...v0.9.0

    Source code(tar.gz)
    Source code(zip)
  • v0.8.0(Feb 22, 2022)

    An update after a while, woot!

    • BREAKING: Upgrade to dis-snek 6.0.0. There were some annoying bugs in 5.0.0.
      • This does not work with the latest dev version, or at least won't work correctly - sorry! It'll be fixed once the next version of dis-snek comes out.
    • BREAKING: VoiceChannelConverter has been changed to GuildVoiceConverter as you can't import dis_snek.VoiceChannel easily anyways, nor are you intended to.
    • BREAKING: Subcommands are now created with subcommand only rather than with command and its aliases. This is to be more consistent with dis-snek itself, especially with how it handles slash commands.
    • MolterCommand.signature is a thing! It's more or less exactly how discord.py did it - it's basically a way of getting a POSIX-like signature for a command's arguments.
    • MolterSnake.get_command(name) is a thing too! It allows you to get a command from its name, aliases or not, and even can go through subcommands.
    • Some fixes and adjustments here and there.

    Full Changelog: https://github.com/Astrea49/molter/compare/v0.7.0...v0.8.0

    Source code(tar.gz)
    Source code(zip)
  • v0.7.0(Feb 3, 2022)

    A small update, but hey, I'm back! Sorry, life got in the way. This update is really just about addressing dis_snek 0.5.0, which introduced a lot of breaking changes that needed to be accounted for.

    Updates

    • BREAKING: Upgraded to dis_snek 5.0.0. Older versions of dis_snek will no longer work.
      • EmojiConverter has been removed as Molter no longer supports versions below 5.0.0.
      • CustomEmojiConverter was changed to be faster if you have emoji caching on.
    • Molter now uses modern attr API names, attr.define and attr.field, over attr.s and attr.ib.

    New Contributors

    • @silasary made their first contribution in https://github.com/Astrea49/molter/pull/1! Thanks so much for this - it saved me quite a bit of time, even if it wasn't perfect.

    Full Changelog: https://github.com/Astrea49/molter/compare/v0.6.0...v0.7.0

    Source code(tar.gz)
    Source code(zip)
  • v0.6.0(Jan 14, 2022)

    Finally, subcommands!

    • Subcommands have been added! They do not require a different decorator - you can make any command a subcommand by doing base_cmd.command(), and it'll work!
      • These do not work like discord.py subcommands, as you expect, and you shouldn't treat them like one. The base command will always be run if no subcommand is found, and base command checks, by default, are run before subcommand checks (in case you want to run just subcommand checks, you can use hierarchical_checking on the base command).
    • MolterScale has been removed. Try to use MolterSnake if you can - it works great!
    • Fixed Molter with the the master/dev branches of Dis-Snek. This was caused by Emoji being renamed to PartialEmoji - Molter now automatically will detect which one to use!

    Full Changelog: https://github.com/Astrea49/molter/compare/v0.5.1...v0.6.0

    Source code(tar.gz)
    Source code(zip)
  • v0.5.1(Jan 9, 2022)

    A quick little bugfix.

    • Replaced a return with a continue in the two override classes, allowing for more than one alias and proper processing of Scales/commands in general.

    Full Changelog: https://github.com/Astrea49/molter/compare/v0.5.0...v0.5.1

    Source code(tar.gz)
    Source code(zip)
  • v0.5.0(Jan 9, 2022)

    We're slowly getting into phase 2 of Molter, where the features that require digging into Dis-Snek itself is being added.

    • Added aliases, working as they did in discord.py except that they must be a string. However, in order to use them, you must use:
    • Added MolterSnake and MolterScale, two classes that subclass Snake and Scale to add in alias support for each of the two classes. You must use one or the other - you cannot use both. You also MUST use them to use aliases.
    • Made name positional, while making everything else keyword-only for the decorator.
    • Fixed the message command decorator erroring out when neither a help or brief parameter were passed and the command lacked any docstrings of its own.

    Full Changelog: https://github.com/Astrea49/molter/compare/v0.4.0...v0.5.0

    Source code(tar.gz)
    Source code(zip)
  • v0.4.0(Dec 31, 2021)

    A very simple update, mainly to set out parts needed for the next part of molter and to show this project isn't dead.

    • Added some command parameters, like help text and a feature similar to discord.py's ignore_extra.
      • Note: these changes are simple, but they may break as I may have missed something. If so, sorry! I'll fix that ASAP.

    Full Changelog: https://github.com/Astrea49/molter/compare/v0.3.2...v0.4.0

    Source code(tar.gz)
    Source code(zip)
  • v0.3.2(Dec 22, 2021)

    • Bumped up minimum Dis-Snek version to 4.2.0. Technically, this is breaking, but I think anyone using this is already the latest version anyways.
    • Made MemberConverter be able to fetch users by user/nickname even if the guild is not chunked.

    Full Changelog: https://github.com/Astrea49/molter/compare/v0.3.1...v0.3.2

    Source code(tar.gz)
    Source code(zip)
  • v0.3.1(Dec 22, 2021)

    • Parse and check parameters on decoration assignment, not on first run of the command. This means errors with parameters are discovered as they are loaded in, not over and over again as the command is run.
    • Changed parameter-analyzing errors to ValueError rather than BadArgument.

    Full Changelog: https://github.com/Astrea49/molter/compare/v0.3.0...v0.3.1

    Source code(tar.gz)
    Source code(zip)
  • v0.3.0(Dec 22, 2021)

    • Added Greedy converters! They mostly function the same as discord.py's Greedy, though they do not work in variable or keyword-only arguments.
    • ...that's it.

    Full Changelog: https://github.com/Astrea49/molter/compare/v0.2.0...v0.3.0

    Source code(tar.gz)
    Source code(zip)
  • v0.2.0(Dec 21, 2021)

    • Added support for Literals! Only objects with types with a constructor that accepts one argument will work (the primitive data types like str and int work well with it, so something like Literal["e"] works right out of the box).
    • Fixed weirdness with how quoted arguments were handled.
    • Slightly clearer error message for Union-related errors.
    Source code(tar.gz)
    Source code(zip)
  • v0.1.0(Dec 20, 2021)

    • Added proper support for variable arguments, handling type hints correctly.
    • Added support for inline advanced converters.
    • Fixed issues with Optionals at an end of a command.
    • Slight adjustments to error handling.

    Full Changelog: https://github.com/Astrea49/molter/compare/v0.0.2...v0.1.0

    Source code(tar.gz)
    Source code(zip)
  • v0.0.2(Dec 20, 2021)

    • Added support for | union syntax.
    • Display clearer error messages for error messages involving unions.
    • Fixed consume rest behavior.
    • Added proper error handling for functions with more than 2 arguments.
    • Added support for 0 argument functions.
    Source code(tar.gz)
    Source code(zip)
  • v0.0.1b(Dec 19, 2021)

Owner
Astrea
Just a random girl developing random things for random uses. Mainly just a lot of Discord bots, though. She/her, please!
Astrea
This Code is Property of Rehyann Saini. Feel Free to use this Project.

Email-Spammer Rehyann Saini in Collabration With Fe13 Productions This is an easy to use Dev Friendly Email spammer... #Important Things to know..! St

Rehyann Saini 1 Jan 14, 2022
Discord raid tool!

GANG Multi Tool Menu: -- YOUTUBE TUTORIAL! Features: Most Advanced Multi Tool! Spammer DM Spammer Friend Spammer Reaction Spam WebhookSpammer Typing

1 Feb 13, 2022
A cool discord bot, called Fifi

Fifi A cool discord bot, called Fifi This bot is the official server bot of Meme Studios discord server. This github repo is the code we use for the b

Fifi Discord Bot 3 Jun 08, 2021
New developed moderation discord bot by archisha

Monitor42 New developed moderation discord bot by αrchιshα#5518. Details Prefix: 42! Commands: Moderation Use 42!help to get command list. Invite http

Kamilla Youver 0 Jun 29, 2022
HinamiRobot - Telegram Group Manager Bot Written In Python Using Pyrogram

✨ HINAMI CHAN ✨ Telegram Group Manager Bot Written In Python Using Pyrogram. Rea

DARK LEGEND088 2 Jan 27, 2022
Weee - Advanced project's versions bumper

Weee - Advanced project's versions bumper

Yan Kurbatov 2 Jun 06, 2022
An advanced Twitter scraping & OSINT tool written in Python that doesn't use Twitter's API, allowing you to scrape a user's followers, following, Tweets and more while evading most API limitations.

TWINT - Twitter Intelligence Tool No authentication. No API. No limits. Twint is an advanced Twitter scraping tool written in Python that allows for s

TWINT Project 14.2k Jan 03, 2023
ARKHAM X GOD MULTISPAM BOT

ARKHAM-X-GOD-MULTISPAM-BOT 𝗗𝗘𝗣𝗟𝗢𝗬 𝗨𝗣𝗧𝗢 30 𝗕𝗢𝗧𝗦 𝗜𝗡 𝗔 𝗦𝗜𝗡𝗚𝗟?

ArkhamXGod 2 Jan 08, 2022
Python functions to run WASS stereo wave processing executables, and load and post process WASS output files.

wass-pyfuns Python functions to run the WASS stereo wave processing executables, and load and post process the WASS output files. General WASS (Waves

Mika Malila 3 May 13, 2022
A multifunctional bot for Discord

Um bot multifuncional e divertido para Discord Estive desenvolvendo o BotDaora desde o começo de outubro de 2021 e agora ele é open-source! tomei essa

Ruan 4 Dec 28, 2021
The Easy-to-use Dialogue Response Selection Toolkit for Researchers

Easy-to-use toolkit for retrieval-based Chatbot Our released data can be found at this link. Make sure the following steps are adopted to use our code

GMFTBY 32 Nov 13, 2022
The open source version of Tentro - A multipurpose Discord bot.

Welcome to Tentro 👋 A multipurpose Discord bot. 🏠 Homepage Install pip install -r requirements.txt Usage py Tentro.py Contributors 👤 Tentro Dev Tea

6 Jul 14, 2022
Monitor robot of Apple Store's products, using DingTalk notification.

概述 本项目应用主要用来监测Apple Store线下直营店货源情况,主要使用Python实现。 首先感谢iPhone-Pickup-Monitor项目带来的灵感,同时有些实现也直接使用了该项目的一些代码。 本项目在iPhone-Pickup-Monitor原有功能的基础上去掉了声音通知,但添加了多

Lennon Chin 159 Dec 09, 2022
An Anime Theme Telegram group management bot. With lot of features.

Emilia Project Emilia-Prjkt is a modular bot running on python3 with anime theme and have a lot features. Easiest Way To Deploy On Heroku This Bot is

ZenitsuID #M•R•T™ 3 Feb 03, 2022
Python bot for send videos of a Youtube channel to a telegram group , channel or chat

py_youtube_to_telegram Usage: If you want to install ytt and use it, run this command: sudo sh -c "$(curl -fsSL https://raw.githubusercontent.com/nima

Nima Fanniasl 8 Nov 22, 2022
It's a discord.py simulator.

DiscordPySimulator It's a discord.py simulator. ⚠️ Things to fix Context As you may know, discord py commands provide the context as the first paramet

Juan Sebastián 11 Oct 24, 2022
Revolt account generator. Bypassing Hcaptcha using AI solver.

RevoltGenerator Revolt account generator. Bypassing Hcaptcha using AI solver. Config settings in config.json then put your usernames / proxies. If you

&! Ѵιchy.#0110 27 Nov 01, 2022
This repository is used to simplify the process of cloning the SSM documents across the AWS regions.

SSM Cloner Introduction This module is created in order to simplify the process of copying the SSM documents from one region to another regions. As an

6 Jun 04, 2022
Python wrapper for Stanford CoreNLP.

stanfordcorenlp stanfordcorenlp is a Python wrapper for Stanford CoreNLP. It provides a simple API for text processing tasks such as Tokenization, Par

884 Dec 25, 2022
NewpaperNews-API - Json data of the news with python

NewsAPI API Documentation BASE_URL = "https://saurav.tech/NewsAPI/" top_headline

Aryaman Prakash 2 Sep 23, 2022