-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
202 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
# this is example of plugin creating, maded by vanezus <3 | ||
|
||
# Use quart - this async flask | ||
from quart import Quart, jsonify | ||
# need for types | ||
from src.MZscript import MZClient, BasePlugin | ||
|
||
|
||
class WebsitePlugin(BasePlugin): # name of plugin | ||
def __init__(self): | ||
self.app = Quart(__name__) | ||
|
||
#route / | ||
@self.app.route("/") | ||
async def route_page(): | ||
return jsonify({"bot": self.bot_name}) # -> return bot display name | ||
|
||
# simple add function | ||
async def func_myfunction(self, ctx, args): | ||
print("Hello!") | ||
|
||
# self.client declaration | ||
def setup(self, client): | ||
self.client: MZClient = client | ||
self.client.funcs.add_function("$myfunction", self.func_myfunction) | ||
|
||
# there is async starting of server | ||
# on bot ready | ||
async def on_ready(self): | ||
self.bot_name: str = self.client.bot.user.display_name | ||
await self.app.run_task(host='127.0.0.1', port=5000, debug=False) | ||
|
||
# # example of add: | ||
# from .website import WebsitePlugin | ||
# | ||
# bot.add_plugin(WebsitePlugin()) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
disnake>=2.9.2 | ||
MZscript @ git+https://github.com/MZshnik/MZscript@main | ||
twine>=5.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ | |
|
||
from .database import Database | ||
from .main import MZClient | ||
from .base_plugin import BasePlugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import disnake | ||
|
||
|
||
class BasePlugin: | ||
""" | ||
## Base class for creating MZscript plugins | ||
### This class discribes events what MZClient can call | ||
### Only 1 method is required - `setup`. If it ignored, raises NotImplementedError | ||
""" | ||
|
||
def setup(self, client): | ||
""" | ||
## Setup plugin | ||
### Required to implement. If it ignored, raises NotImplementedError | ||
### Args: | ||
client (`MZClient`): Instance of MZClient class. Contains all user and bot settings/information | ||
""" | ||
raise NotImplementedError("Method \"setup\" of BasePlugin not implemented") | ||
|
||
async def on_ready(self): | ||
pass | ||
|
||
async def on_message(self, message: disnake.Message): | ||
pass | ||
|
||
async def on_button_click(self, inter: disnake.MessageInteraction): | ||
pass | ||
|
||
async def on_interaction(self, inter: disnake.MessageInteraction): | ||
pass | ||
|
||
async def on_slash(self, inter: disnake.MessageInteraction): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.