-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redesigned for plugins and aliases support #19
Conversation
- Invalidate most of the readme - Update the filetree to match the upcoming updates - Minor updates to the files to preserve the bot functioning
The core part of the bot does not handle it in a proper plugin manner (yet), but it's going to be fixed in the next commit(s)
Implemented the action lookup function that will be used to find the action function corresponding to received commands. Added terminology.txt (temp file) that states the differences between plugin, action, and command.
Implemented the run-rawrun-shell functionality as a plugin, represented key/type actions through that plugin implementation and made use of them in the main file, dropping their previous implementations; Added plugin helpers, which currently contain decorators for notifying of action execution; Removed dangling stuff from Rimokon/__main__.py and Rimokon/__util__.py.
Fixed a missing import; fixed bugs in `cmd_get_*`, extended `cmd_get_rest` to preserve whitespace when requested.
In import_config.py implemented importing config and canonicalizing actions and aliases defined in it.
The long description at config.py.example are going to be moved to Wikis (#18)
One more step on the way to #15
Oops, forgot about the README and the /help command |
+ removed the temporary terminology.txt
Generate help message from the enabled actions and aliases. Modified and moved /start message, fixed #16
610a93e
to
ce2056d
Compare
Pylint reports unexpected keyword argument "notify"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are things to fix
Rimokon/util.py
Outdated
|
||
def cmd_get_rest(s: str, cut_first_whitespace: bool = True) -> str: | ||
""" | ||
Cut the first word of the string and (optionally, default) the first whitespace symbol after it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cut the first word of the string and (optionally, default) the first whitespace symbol after it. | |
Cut the first word of the string and, optionally, the first whitespace symbol after it (default). |
README.md
Outdated
[@myidbot](https://t.me/myidbot). | ||
- Copy `Rimokon/config.py.example` to `Rimokon/config.py` and modify it according to your use case. | ||
Optionally, install `xdotool`/`ydotool` or a similar utility for graphics interaction. | ||
Use [@BotFather |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?..
Rimokon/__main__.py
Outdated
|
||
|
||
# Decorator that prevents the actions when executed by a non-admin user. | ||
# Must be specified UNDER the `@bot.*_handler` decorator (must be applied before it) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Must be specified UNDER the `@bot.*_handler` decorator (must be applied before it) | |
# Must be specified UNDER the `@bot.*_handler` decorator (that is, be applied before it) |
Rimokon/config.py.example
Outdated
# It is an array of arrays of strings. Second-level arrays represent lines of keyboard (top-to-bottom), | ||
# strings in them are the commands for the keyboard. | ||
# | ||
# `quick_access_cmds` can be empty (or completely omitted in the config), but its subarrays and the strings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can't be omitted any longer, can it?
Rimokon/import_config.py
Outdated
# TODO: use logger object | ||
logger.critical(*args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# TODO: use logger object | |
logger.critical(*args) | |
logger.critical(*args) |
Rimokon/import_config.py
Outdated
if k in updated_aliases.keys(): | ||
die('Attempt to redefine alias %s (in `config.aliases`)', repr(k)) | ||
if k in updated_actions.keys(): | ||
die('Alias %s attempts to overwrite an existing action', repr(k_)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would make this error messages look more similar
Rimokon/import_config.py
Outdated
if k in updated_actions.keys(): | ||
die('Alias %s attempts to overwrite an existing action', repr(k_)) | ||
if isinstance(v_, str): | ||
base_plugin = cmd_get_action_name(v_) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
base_action_name
?
Rimokon/plugins/plugin_helpers.py
Outdated
|
||
Modifes an action function (which accepts `telebot.TeleBot` and `telebot.Message` as its | ||
first position arguments) such that an additional kw-only argument `notify` is added to | ||
the function. If it is `True` (default), the behavior is the same with `notify_of_execution`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the function. If it is `True` (default), the behavior is the same with `notify_of_execution`; | |
the function. If it is `True` (default), the behavior is the same as with `notify_of_execution`; |
But maybe it's better to elaborate on the behavior instead of referring to another function
Rimokon/config.py.example
Outdated
aliases = { | ||
# A "simple alias" (or "string alias") just expands the given action name in the beginning of the | ||
# received commands to the value. Notice that it is interpreted just like other action names, | ||
# i.e. letters lower/upper case or trailing slashes do not matter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# i.e. letters lower/upper case or trailing slashes do not matter. | |
# i.e. letters lower/upper case or leading slashes do not matter. |
Rimokon/import_config.py
Outdated
else: | ||
die('The alias %s specifies neither a string nor a callable object', repr(k_)) | ||
# Note: the above checks are not comprehensive, as the function isn't ensured to | ||
# accept the correct set of parameters. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here it's unclear what function we are talking about
0eef5f0
to
3e92662
Compare
Decomposed Rimokon code into core and plugins. Introduced aliases.
Resolves #13