🫶 Community#

TT Community

🚧 Build Your Plugin#

here is a plugin example:

 1import os
 2
 3from tt.config import logger, settings
 4from tt.plugins.plugin_manager import BasePlugin
 5from tt.utils import send_notification
 6
 7
 8class ExamplePlugin(BasePlugin):
 9    """Example Plugin
10    Initialization of imported class MyClass
11    """
12
13    name = os.path.splitext(os.path.basename(__file__))[0]
14
15    def __init__(self):
16        """Plugin Initialization"""
17        super().__init__()
18        self.enabled = settings.example_plugin_enabled
19        if self.enabled:
20            logger.debug("example plugin enabled")
21
22    async def start(self):
23        """Starts the plugin"""
24        logger.debug("example plugin started")
25        if self.enabled:
26            logger.debug("example plugin enabled")
27
28    async def send_notification(self, message):
29        """Sends a notification"""
30        if self.enabled:
31            await send_notification(message)
32
33    async def handle_message(self, msg):
34        """
35        Handles incoming messages.
36
37        Args:
38            msg (str): The incoming message.
39        """
40        if not self.should_handle(msg):
41            return
42        if msg.startswith(settings.bot_prefix):
43            command, *args = msg.split(" ")
44            command = command[1:]
45
46            command_mapping = {
47                settings.bot_command_help: self.myadhocfunction,
48            }
49
50            if command in command_mapping:
51                function = command_mapping[command]
52                await self.send_notification(f"{await function()}")
53
54    async def myadhocfunction(self):
55        """
56        This is an example if you need an adhoc function.
57        Your class object should be in the initialization.
58        and the handle_message should be used to retrieve
59        your functions fro MyClass
60        """
61        return "this is an example"

🧑‍💻 Contributing#

We're really excited that you're interested in contributing! Before contributing, make sure you read through existing issues. Before working on a large PR, please open an issue to discuss first.
TalkyTrader, CI pipeline and linked libraries are built using the below framework: