You can choose to continue using the @slash decorator while splitting your code into multiple classes / files if you like, just that you will still need to instantiate each class in __main__.py
and pass the required BDK services along with ActivityRegistry
.
# __main__.py
from .my_file import MyClass
async def run():
config = BdkConfigLoader.load_from_file(Path.joinpath(current_dir, 'resources', 'config.yaml'))
async with SymphonyBdk(config) as bdk:
datafeed_loop = bdk.datafeed()
datafeed_loop.subscribe(MessageListener())
MyClass(bdk.activities(), bdk.messages())
await datafeed_loop.start()
# my_file.py
class MyClass():
def __init__(self, activities: ActivityRegistry, messages: MessageService):
@activities.slash("/mycommand")
async def do_something(context: CommandContext):
await messages.send_message(context.stream_id, "Hello!")