Changeset 23bddf3
- Timestamp:
- Oct 10, 2024, 6:20:52 AM (5 weeks ago)
- Branches:
- master
- Children:
- 1f94544
- Parents:
- 8d2d5ac
- Files:
-
- 1 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
commands/__init__.py
r8d2d5ac r23bddf3 15 15 from .movie import movie, movies, remove_movies 16 16 from .event import create_event, list_events 17 from .announce import create_announcement 18 -
commands/event.py
r8d2d5ac r23bddf3 76 76 if events == [] or is_past(events[-1]["when"]): 77 77 events.append(event_dict) 78 await update.message.reply_text(EVENT_CREATED.format(when=event_when)) 78 await update.message.reply_text( 79 EVENT_CREATED.format( 80 when=event_when, 81 movie=event_dict["movie"], 82 ) 83 ) 79 84 else: 85 old_when = events[-1]["when"] 86 old_where = events[-1]["where"] 80 87 events[-1] = event_dict 81 await update.message.reply_text(EVENT_EDITED.format(when=event_when)) 88 89 await update.message.reply_text( 90 EVENT_EDITED.format( 91 old_when=old_when, 92 old_where=old_where, 93 when=event_when, 94 where=event_where, 95 movie=event_dict["movie"], 96 ) 97 ) 82 98 83 99 -
commands/meta.py
r8d2d5ac r23bddf3 12 12 from telegram import Update 13 13 from telegram.ext import ContextTypes 14 from subprocess import check_output 15 16 from strings import ABOUT 17 18 19 VERSION="0.1" 20 21 22 def _get_commit_hash() -> str: 23 return check_output(['git', 'rev-parse', 'HEAD']).decode('ascii').strip() 24 25 26 def _get_commit_short_hash() -> str: 27 return check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('ascii').strip() 14 28 15 29 16 30 async def about(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: 17 await update.message.reply_text(''' 18 Version InDev 19 20 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. 21 22 Project information: http://57.129.46.169/trac/wiki/python-cinema-club-bot 23 Source code: http://57.129.46.169/cgit/python-cinema-club-bot/ 24 25 Contributed in 2024 by Mikhail Kirillov (~w96k) <w96k@runbox.com> 26 27 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. 28 29 You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see: 30 <http://creativecommons.org/publicdomain/zero/1.0/> 31 32 ''') 31 await update.message.reply_text( 32 ABOUT.format( 33 version=VERSION, 34 commit=_get_commit_short_hash(), 35 ) 36 ) -
commands/users.py
r8d2d5ac r23bddf3 17 17 EXPECTED_ONE_USER, USER_SET, USER_ADD, USER_REMOVE, ADD_MORE_USERS, \ 18 18 NEXT_MOVIE_USER, USER_NOT_FOUND, USER_CHOOSE, NO_USERS, \ 19 EVENT_USER_HAD_EVENT 20 from utils import context_init, create_users_string, normalize_username, \ 21 choose_next_user 19 EVENT_USER_HAD_EVENT, NEXT_MOVIE 20 from utils import context_init, create_users_string, choose_next_user 22 21 from predicates import has_finished_event 22 23 23 24 24 async def set_users( … … 87 87 users = context.chat_data["users"] = choose_next_user(users) 88 88 89 await update.message.reply_text(NEXT_MOVIE_USER.format(user=users[0])) 89 next_user_string = NEXT_MOVIE_USER.format(user=users[0]) 90 91 last_movie = context.chat_data["movies"][0] \ 92 if context.chat_data["movies"] != [] else None 93 94 if last_movie and last_movie["user"] == users[0]: 95 next_user_string += NEXT_MOVIE.format(movie=last_movie["title"]) 96 97 await update.message.reply_text(next_user_string) 90 98 91 99 -
main.py
r8d2d5ac r23bddf3 59 59 app.add_handler(CommandHandler("event", commands.create_event)) 60 60 app.add_handler(CommandHandler("events", commands.list_events)) 61 app.add_handler(CommandHandler("announce", commands.create_announcement)) 61 62 62 63 # Movie commands … … 70 71 app.add_handler(CommandHandler("list", commands.list_users)) 71 72 app.add_handler(CommandHandler("users", commands.list_users)) 73 app.add_handler(CommandHandler("queue", commands.list_users)) 72 74 app.add_handler(CommandHandler("remove", commands.remove_users)) 73 75 app.add_handler(CommandHandler("chooser", commands.chooser_user)) -
predicates.py
r8d2d5ac r23bddf3 30 30 last_event["user"] == normalize_username(username) and \ 31 31 is_past(last_event["when"]) 32 33 34 def has_unfinished_event(context: ContextTypes.DEFAULT_TYPE) -> bool: 35 events = context.chat_data["events"] 36 last_event = events[-1] if events != [] else None 37 38 return False if last_event is None else not is_past(last_event["when"]) -
strings.py
r8d2d5ac r23bddf3 21 21 MOVIE_SET = "Movie \"{title}\" proposed by {user} is succesfully set as next to watch" 22 22 MOVIES_LIST = "\"{title}\" IMDB:{id} by {user} \n" 23 NO_MOVIES = "No movies "23 NO_MOVIES = "No movies. You can add movie if you are next to choose (see /next). Too add a movie use /movie <imdb_id>" 24 24 25 25 USER_NOT_FOUND = "Provided user ({user}) not found. Check /list" … … 28 28 ADD_MORE_USERS = "There is no users added. You can add people who can choose movies using /add nickname" 29 29 NEXT_MOVIE_USER = "Next movie choice is up to {user}" 30 NEXT_MOVIE = " and they have choosen to watch \"{movie}\"" 30 31 31 32 USER_ADD = "User {user} has been added" … … 41 42 /event 1.08.2024/18:00 <where> 42 43 """ 43 EVENT_CANT_BE_IN_PAST = "Event can't happen in the past. You set {when}, but todayis {today}"44 EVENT_CANT_BE_IN_PAST = "Event can't happen in the past. You set {when}, but now is {today}" 44 45 EVENT_ARGS_NOT_PROVIDED = """ 45 46 Event commands need arguments provided: … … 53 54 """ 54 55 55 EVENT_CREATED = "Event at {when} was created"56 EVENT_EDITED = "Event at {when} was modified"56 EVENT_CREATED = "Event \"{movie}\" at {when} was created" 57 EVENT_EDITED = "Event \"{movie}\" at {old_when} in {old_where} was modified to {when} in {where}" 57 58 EVENTS_LIST = "[{finished}] \"{movie}\" by {user} at {when} in {where}\n" 58 59 EVENT_MOVIE_NOT_CHOOSEN = "You should choose a film first using /movie <imdb_id>" 59 60 EVENT_MOVIE_NOT_SET = "<None>" 60 61 EVENT_USER_HAD_EVENT = "User {user} have already finished event, so he can't choose twice. See /next or /list" 61 NO_EVENTS = "No events "62 NO_EVENTS = "No events." 62 63 63 64 UNDEFINED_ERROR = "Exception: something unexpected happened. Check the logs." 65 66 ANNOUNCEMENT_FINISHED_EVENT = "There is no planned events. Create one using /event <when> <where>" 67 ANNOUNCEMENT_TEMPLATE = """ 68 {intro} 69 70 Movie: {movie_title} 71 Choosen by: @{user} 72 Runtime: {movie_runtime} minutes 73 74 When: {when} 75 Where: {where} 76 77 Rating: {rating} 78 Genres: {genres} 79 80 https://imdb.com/title/tt{movie_id}/ 81 """ 82 83 ABOUT = """ 84 v{version} #{commit} 85 86 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. 87 88 Project information: http://57.129.46.169/trac/wiki/python-cinema-club-bot 89 Source code: http://57.129.46.169/cgit/python-cinema-club-bot/ 90 91 Contributed in 2024 by Mikhail Kirillov (~w96k) <w96k@runbox.com> 92 93 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. 94 95 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/> 96 """
Note:
See TracChangeset
for help on using the changeset viewer.