Ikabot-Collective / ikabot

A Python-based bot designed for automating tasks in the game Ikariam
https://discord.com/invite/3hyxPRj
MIT License
89 stars 62 forks source link

Add loading of custom modules #245

Closed ikagod closed 2 months ago

ikagod commented 3 months ago

This PR introduces a new way for users to load their own - or modified versions of the official - ikabot modules.

Users will simply select the Load custom ikabot module option under the Options / Settings page of the main menu and then they will be presented with a list of previously loaded custom modules, and an option to add new custom modules. The data for the module locations is saved under the 'shared' key in the session data (making is lobby-account specific). If a module is no longer present (if the path no longer exists) then it is removed from the list of known custom modules.

Also made main menu refresh on hitting enter.

susikaman commented 3 months ago

This idea has been thrown around for quite some time, great to see it finally alive! It seems to load the function just fine, although the task name goes by the "loadCustomModule" instead of the loaded module's name. But that's honestly pretty minor, as the task update does get updated just fine and that should be enough information for identifying a task imo.

I was expecting something like automatically scanning for .py files from a separate folder within Ikabot for listing modules which could be added. But by typing in the full path, we can just add modules/functions from anywhere which is pretty neat! Perhaps we could later add an alternative way of importing modules from the web as well, such as Github or Pastebin for example.

The solution of saving the module's in the userfile is great, it could be a pain in the ass to import multiple models into Ikabot especially with multiple accounts, but having them permanently save the possibly complicated path makes it worth the while.

The enter-to-refresh is just perfect! I've been using the update.py function for that, never bothered to pay more thought for it since it worked well enough. Refresh by enter is just as it should've always been! Excellent addition, there's not much more to it honestly.

Just tested the PR and it seems to work just as intended. Windows & Python 3.10