summaryrefslogtreecommitdiff
path: root/commands
diff options
context:
space:
mode:
Diffstat (limited to 'commands')
-rw-r--r--commands/__init__.py2
-rw-r--r--commands/event.py20
-rw-r--r--commands/meta.py26
-rw-r--r--commands/users.py16
4 files changed, 47 insertions, 17 deletions
diff --git a/commands/__init__.py b/commands/__init__.py
index 2e0e009..7081c89 100644
--- a/commands/__init__.py
+++ b/commands/__init__.py
@@ -14,3 +14,5 @@ from .users import set_users, add_users, list_users, remove_users, \
chooser_user, who_is_next
from .movie import movie, movies, remove_movies
from .event import create_event, list_events
+from .announce import create_announcement
+
diff --git a/commands/event.py b/commands/event.py
index 5a7bf69..e06ea83 100644
--- a/commands/event.py
+++ b/commands/event.py
@@ -75,10 +75,26 @@ async def create_event(
if events == [] or is_past(events[-1]["when"]):
events.append(event_dict)
- await update.message.reply_text(EVENT_CREATED.format(when=event_when))
+ await update.message.reply_text(
+ EVENT_CREATED.format(
+ when=event_when,
+ movie=event_dict["movie"],
+ )
+ )
else:
+ old_when = events[-1]["when"]
+ old_where = events[-1]["where"]
events[-1] = event_dict
- await update.message.reply_text(EVENT_EDITED.format(when=event_when))
+
+ await update.message.reply_text(
+ EVENT_EDITED.format(
+ old_when=old_when,
+ old_where=old_where,
+ when=event_when,
+ where=event_where,
+ movie=event_dict["movie"],
+ )
+ )
async def list_events(
diff --git a/commands/meta.py b/commands/meta.py
index c98e770..5a61a84 100644
--- a/commands/meta.py
+++ b/commands/meta.py
@@ -11,22 +11,26 @@
from telegram import Update
from telegram.ext import ContextTypes
+from subprocess import check_output
+from strings import ABOUT
-async def about(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
- await update.message.reply_text('''
-Version InDev
-python-cinema-club-bot is a bot for Telegram specialized for managing cinema club activities. This software is released as Public Domain using CC0 license.
+VERSION="0.1"
+
-Project information: http://57.129.46.169/trac/wiki/python-cinema-club-bot
-Source code: http://57.129.46.169/cgit/python-cinema-club-bot/
+def _get_commit_hash() -> str:
+ return check_output(['git', 'rev-parse', 'HEAD']).decode('ascii').strip()
-Contributed in 2024 by Mikhail Kirillov (~w96k) <w96k@runbox.com>
-To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
+def _get_commit_short_hash() -> str:
+ return check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('ascii').strip()
-You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see:
-<http://creativecommons.org/publicdomain/zero/1.0/>
- ''')
+async def about(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
+ await update.message.reply_text(
+ ABOUT.format(
+ version=VERSION,
+ commit=_get_commit_short_hash(),
+ )
+ )
diff --git a/commands/users.py b/commands/users.py
index 9dcc125..8808bf6 100644
--- a/commands/users.py
+++ b/commands/users.py
@@ -16,11 +16,11 @@ from collections import deque
from strings import USER_NOT_PROVIDED, USERS_ADDED, USERS_REMOVED, \
EXPECTED_ONE_USER, USER_SET, USER_ADD, USER_REMOVE, ADD_MORE_USERS, \
NEXT_MOVIE_USER, USER_NOT_FOUND, USER_CHOOSE, NO_USERS, \
- EVENT_USER_HAD_EVENT
-from utils import context_init, create_users_string, normalize_username, \
- choose_next_user
+ EVENT_USER_HAD_EVENT, NEXT_MOVIE
+from utils import context_init, create_users_string, choose_next_user
from predicates import has_finished_event
+
async def set_users(
update: Update,
context: ContextTypes.DEFAULT_TYPE
@@ -86,7 +86,15 @@ async def who_is_next(
if has_finished_event(context, users[0]):
users = context.chat_data["users"] = choose_next_user(users)
- await update.message.reply_text(NEXT_MOVIE_USER.format(user=users[0]))
+ next_user_string = NEXT_MOVIE_USER.format(user=users[0])
+
+ last_movie = context.chat_data["movies"][0] \
+ if context.chat_data["movies"] != [] else None
+
+ if last_movie and last_movie["user"] == users[0]:
+ next_user_string += NEXT_MOVIE.format(movie=last_movie["title"])
+
+ await update.message.reply_text(next_user_string)
async def remove_users(