-
-
Notifications
You must be signed in to change notification settings - Fork 265
Channel cloning and extending (2.x)
Eana Hufwe edited this page Apr 13, 2019
·
3 revisions
Written by Eana Hufwe for v2.0.0
By cloning an existing module, you can make changes to the existing code and override methods and behaviors of a module. This is done by extending the module class and overriding the module ID, you can also modify a module locally in this way.
Note: To have multiple accounts with the same channel, use "Instance ID".
It should work for most modules, depending on their implementations.
This example is simplified for just cloning a channel with minimum modifications. If you want to make further changes, please refer to the documentation for details.
- Look for the channel class you want to clone, and note down it's full qualified name, that is a name that you can import with. In this example,
efb_dummy_slave.DummyChannelwill be used. - Navigate to the modules path, or
EFB_DATA_PATH/modules, defaulted to~/.ehforwarderbot/modules. - Create a file
dummy_clone.py, and include the following code:from efb_dummy_slave import DummyChannel class DummyCloneChannel(DummyChannel): channel_id = "dummy_clone.DummyCloneChannel" # This is usually the file name and the class name of the clone channel_name = "Dummy clone channel" channel_emoji = "💭"
- Configure the channel as instructed by the channel author, but with the new channel ID (
dummy_clone.DummyCloneChannel). - Enable the channel in your
config.yamlwith the new ID.
EFB adds EFB_DATA_PATH/modules to its PYTHON_PATHS before it runs, and try to use the registered name as a fully qualifying path to import the class.