Skip to content

Commit

Permalink
add --version option to CLI
Browse files Browse the repository at this point in the history
also fix markseen logic and uprade deltabot-cli
  • Loading branch information
adbenitez committed Apr 27, 2024
1 parent 68adf4d commit 77e540e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
10 changes: 4 additions & 6 deletions faqbot/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
from sqlalchemy.exc import IntegrityError
from sqlalchemy.future import select

from ._version import __version__
from .orm import FAQ, init, session_scope
from .utils import get_answer_text, get_faq

cli = BotCli("faqbot")
cli.add_generic_option("-v", "--version", action="version", version=__version__)


@cli.on_init
Expand Down Expand Up @@ -58,6 +60,7 @@ def log_event(bot: Bot, accid: int, event: CoreEvent) -> None:

@cli.on(events.NewMessage(command="/help"))
def _help(bot: Bot, accid: int, event: NewMsgEvent) -> None:
bot.rpc.markseen_msgs(accid, [event.msg.id])
send_help(bot, accid, event.msg.chat_id)


Expand Down Expand Up @@ -152,12 +155,6 @@ def _save(bot: Bot, accid: int, event: NewMsgEvent) -> None:
bot.rpc.send_msg(accid, msg.chat_id, reply)


@cli.on(events.NewMessage(is_info=False))
def markseen_commands(bot: Bot, accid: int, event: NewMsgEvent) -> None:
if bot.has_command(event.command):
bot.rpc.markseen_msgs(accid, [event.msg.id])


@cli.on(events.NewMessage(is_info=False))
def _answer(bot: Bot, accid: int, event: NewMsgEvent) -> None:
if bot.has_command(event.command):
Expand Down Expand Up @@ -194,6 +191,7 @@ def _answer(bot: Bot, accid: int, event: NewMsgEvent) -> None:
def reply_to_command_in_dm(bot: Bot, accid: int, msg: Message) -> bool:
chat = bot.rpc.get_basic_chat_info(accid, msg.chat_id)
if chat.chat_type == ChatType.SINGLE:
bot.rpc.markseen_msgs(accid, [msg.id])
reply = MsgData(
text="Can't save notes in private, add me to a group and use the command there",
quoted_message_id=msg.id,
Expand Down
2 changes: 1 addition & 1 deletion pylama.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[pylama]
linters=mccabe,pyflakes,pylint,isort,mypy
ignore=R0903,C0116
skip=.*,build/*,tests/*,*/flycheck_*
skip=.*,build/*,tests/*,*/_version.py,*/flycheck_*
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ classifiers = [
]
dependencies = [
"SQLAlchemy>=2.0.25,<3.0",
"deltabot-cli>=6.0.0,<7.0",
"deltabot-cli>=6.1.0,<7.0",
]

[project.urls]
Expand All @@ -40,6 +40,7 @@ faqbot = "faqbot:main"

[tool.setuptools_scm]
# can be empty if no extra settings are needed, presence enables setuptools_scm
version_file = "faqbot/_version.py"

[tool.isort]
profile = "black"
Expand Down

0 comments on commit 77e540e

Please sign in to comment.