Open rhetr opened 2 years ago
Thanks for bringing this to my attention! Honestly it looks like I might have just forgotten to update the plugin template generator. Looks like an oversight on my part while updating the bot the last couple versions since I haven't had anyone create their own plugins yet.
I'll look into this and update it as necessary.
Note: I'm also currently away from my computer so I can't investigate this right away, so I'll answer your questions when I get a look at the code and documentation.
I'll try to address all your questions here and update this comment as I investigate these issues:
the command given on the wiki python3 JJMumbleBot/utility/plugin_template_generator.py my_example_plugin does not actually work and returns ModuleNotFoundError: No module named 'JJMumbleBot'. When I copied plugin_template_generator.py into the git root directory it worked as described.
This is the result of a misconfiguration that happened when I moved the source code a couple version ago. I can fix this in the next update.
there are no commands in metadata.ini, which i am guessing "example_echo" should go into
You're right, this is fixed in the latest dev branch. I'll include it in the next minor release.
what do the AudioPlugin and ImagePlugin flags do specifically?
These are deprecated flags that were used a long time ago when the plugin system was a lot more primitive. Currently they should serve no purpose, but I want to do a thorough code review before removing them. As a result these flags will probably stay until the next major update that I'm currently working on.
the example command in the python code is cmd_my_echo_command instead of cmd_example_echo
I fixed it in the latest dev branch, and will be included in the next minor release.
there is no register_callbacks function
I did this intentionally since each plugin is unique and most of them will not require callbacks registered to them. In addition, the way callbacks are configured are specific to the plugin as seen in the media.py
file in the media plugin and server_tools.py
file in the server_tools plugin. I can, however include it in the template and leave it blank like so:
def register_callbacks(self):
pass
shouldn't the code comment say !example_echo -> def cmd_example_echo(self, data)?
Yes it should, and I've fixed it in the latest dev branch which will be included in the next minor release.
what exactly is in the data parameter, is it only data.command and data.message?
Yes, it only consists of those two parameters.
why does data.message also have the command included? it seems redundant to me to always need to do data.message.strip().split(' ',1)[1].
This was a redundancy that was required for a much older version of the bot, and I plan on simplifying this in the next major release instead of a smaller update since this would have some fundamental changes to command handling across all plugins.
thanks for the updates. I just tested out the latest dev branch and have the same issues:
python3 JJMumbleBot/utility/plugin_template_generator.py my_example_plugin
and need to copy plugin_template_generator.py
to the root dir as I did previously.[2022-02-07 22:33:43,433]-[INFO]-[JJMumbleBot(5.2.0).StartUp]: Registered plugin command: example_echo:example_echo_clbk:cmd_example_echo
[2022-02-07 22:33:43,434]-[INFO]-[JJMumbleBot(5.2.0).StartUp]: Plugin Name v1.0.0 Plugin Initialized.
[2022-02-07 22:33:43,439]-[INFO]-[JJMumbleBot(5.2.0).Database]: Inserted new plugin into the database: voice_command
i figured out how to access a docker container's stderr so i also found this:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/app/__main__.py", line 412, in <module>
service.BotService(server_ip, int(server_port), server_password)
File "/app/JJMumbleBot/core/bot_service.py", line 93, in __init__
BotServiceHelper.initialize_plugins()
File "/app/JJMumbleBot/lib/helpers/bot_service_helper.py", line 426, in initialize_plugins
UtilityDB.import_privileges_to_db(db_conn=get_memory_db(),
File "/app/JJMumbleBot/lib/utils/database_utils.py", line 919, in import_privileges_to_db
command_data = GetDB.get_command(db_cursor=db_conn.cursor(), command_name=row['command'].strip())
KeyError: 'command'
I'm still unable to run python3 JJMumbleBot/utility/plugin_template_generator.py my_example_plugin and need to copy plugin_template_generator.py to the root dir as I did previously.
Hi, I haven't corrected this issue yet. I'll have a look as soon as I get some free time.
i figured out how to access a docker container's stderr so i also found this:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/app/__main__.py", line 412, in <module>
service.BotService(server_ip, int(server_port), server_password)
File "/app/JJMumbleBot/core/bot_service.py", line 93, in __init__
BotServiceHelper.initialize_plugins()
File "/app/JJMumbleBot/lib/helpers/bot_service_helper.py", line 426, in initialize_plugins
UtilityDB.import_privileges_to_db(db_conn=get_memory_db(),
File "/app/JJMumbleBot/lib/utils/database_utils.py", line 919, in import_privileges_to_db
command_data = GetDB.get_command(db_cursor=db_conn.cursor(), command_name=row['command'].strip())
KeyError: 'command'
I'll have to look into this further, thanks for bringing it to my attention.
there are some issues I am having with plugin_template_generator.py:
the command given on the wiki
python3 JJMumbleBot/utility/plugin_template_generator.py my_example_plugin
does not actually work and returnsModuleNotFoundError: No module named 'JJMumbleBot'
. When I copied plugin_template_generator.py into the git root directory it worked as described.the plugin that is generated crashes JJMumbleBot when I attempt to load it unmodified. There are a couple confusing things like:
"example_echo"
should go intoAudioPlugin
andImagePlugin
flags do specifically?cmd_my_echo_command
instead ofcmd_example_echo
register_callbacks
functionthe cmd callback is also a bit unclear to me:
!example_echo -> def cmd_example_echo(self, data)
?data
parameter, is it only data.command and data.message?data.message
also have the command included? it seems redundant to me to always need to dodata.message.strip().split(' ',1)[1]
.thanks for your help!