mirror of
https://gitlab.com/chicken-riders/RcGcDw.git
synced 2025-02-23 00:24:09 +00:00
47 lines
1.8 KiB
Python
47 lines
1.8 KiB
Python
# This file is part of Recent changes Goat compatible Discord webhook (RcGcDw).
|
|
#
|
|
# RcGcDw is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# RcGcDw is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with RcGcDw. If not, see <http://www.gnu.org/licenses/>.
|
|
from src.api.context import Context
|
|
from src.discord.message import DiscordMessage, DiscordMessageMetadata
|
|
from src.api.hook import pre_hook, post_hook
|
|
|
|
|
|
@pre_hook
|
|
def example_pre_hook(context: Context, change: dict):
|
|
if context.event == "edit":
|
|
print("I'm an edit with {} bytes changed!".format(change.get("newlen", 0) - change.get("oldlen", 0)))
|
|
|
|
|
|
@post_hook
|
|
def example_post_hook(message: DiscordMessage, metadata: DiscordMessageMetadata, context: Context, change: dict):
|
|
print("Our Discord message looks as follows: ")
|
|
print(message)
|
|
|
|
|
|
def verify_upload(context: Context, change: dict) -> bool:
|
|
return hasattr(context, "event") and context.event.startswith("upload")
|
|
|
|
|
|
@pre_hook(priority=105, condition=verify_upload)
|
|
def example_pre_hook_with_args(context: Context, change: dict):
|
|
print("I'm an upload! Also I'm using a fancy decorator!")
|
|
|
|
|
|
def never_register_this_one(settings):
|
|
return False
|
|
|
|
|
|
@pre_hook(priority=2, register=never_register_this_one)
|
|
def example_pre_hook_that_will_never_register(context: Context, change: dict):
|
|
print("EVIL THINGS HAPPENING IN HERE MUHAHHAHAHHA") |