@@ -122,7 +122,7 @@ def load_module_from_file(file_path: str) -> ModuleType:
122
122
return lib_module
123
123
124
124
125
- def load_lib_modules (available_bots : List [str ]) -> Dict [str , Any ]:
125
+ def load_lib_modules (available_bots : List [str ]) -> Dict [str , ModuleType ]:
126
126
bots_lib_module = {}
127
127
for bot in available_bots :
128
128
try :
@@ -147,6 +147,7 @@ def load_lib_modules(available_bots: List[str]) -> Dict[str, Any]:
147
147
148
148
def load_bot_handlers (
149
149
available_bots : List [str ],
150
+ bot_lib_modules : Dict [str , ModuleType ],
150
151
bots_config : Dict [str , Dict [str , str ]],
151
152
third_party_bot_conf : Optional [configparser .ConfigParser ] = None ,
152
153
) -> Dict [str , lib .ExternalBotHandler ]:
@@ -157,7 +158,7 @@ def load_bot_handlers(
157
158
api_key = bots_config [bot ]["key" ],
158
159
site = bots_config [bot ]["site" ],
159
160
)
160
- bot_dir = os .path .join (os .path .dirname (os .path .abspath (__file__ )), "bots" , bot )
161
+ bot_dir = os .path .join (os .path .dirname (os .path .abspath (bot_lib_modules [ bot ]. __file__ )))
161
162
bot_handler = lib .ExternalBotHandler (
162
163
client , bot_dir , bot_details = {}, bot_config_parser = third_party_bot_conf
163
164
)
@@ -253,7 +254,9 @@ def main() -> None:
253
254
third_party_bot_conf = (
254
255
parse_config_file (options .bot_config_file ) if options .bot_config_file is not None else None
255
256
)
256
- bot_handlers = load_bot_handlers (available_bots , bots_config , third_party_bot_conf )
257
+ bot_handlers = load_bot_handlers (
258
+ available_bots , bots_lib_modules , bots_config , third_party_bot_conf
259
+ )
257
260
message_handlers = init_message_handlers (available_bots , bots_lib_modules , bot_handlers )
258
261
app .config ["BOTS_LIB_MODULES" ] = bots_lib_modules
259
262
app .config ["BOT_HANDLERS" ] = bot_handlers
0 commit comments