From ca1d278415cfa13e9a4f24bf26363517d4abe29d Mon Sep 17 00:00:00 2001 From: ennucore Date: Wed, 22 Jun 2022 10:14:24 +0300 Subject: [PATCH] Some little fixes, todos, templates --- README.md | 2 ++ bot.py | 11 +++++++---- templates.txt | 4 ++++ views.py | 1 + 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2fbff4e..42d8e3f 100644 --- a/README.md +++ b/README.md @@ -14,3 +14,5 @@ Random meetings for chats, kind of like RandomCoffee. TODO: - Add commands like info - In templates replace "this week" with "soon" +- Send the polling message when the user starts the bot +- Link to get the invite info in a chat diff --git a/bot.py b/bot.py index 470627c..85e5812 100644 --- a/bot.py +++ b/bot.py @@ -191,15 +191,18 @@ class Bot(telebot.TeleBot): for community_data in self.db.communities.find(): yield Community.from_dict(community_data) + def poll_user_for_community(self, user: User, community: Community): + def_answer = community.default_answers.get(user.user_id, True) + self.send_template(user.user_id, 'poll_user', community=community, answer=def_answer) + community.pool += [user.user_id] * def_answer + community.polled[user.user_id] = datetime.date.today() + def poll_users_in_community(self, community: Community): for user_id in community.users_to_poll(): user = User.by_id(user_id, self) if user is None: continue - def_answer = community.default_answers.get(user_id, True) - self.send_template(user_id, 'poll_user', community=community, answer=def_answer) - community.pool += [user_id] * def_answer - community.polled[user_id] = datetime.date.today() + self.poll_user_for_community(user, community) self.save_community(community) def send_meeting_info_in_community(self, community: Community): diff --git a/templates.txt b/templates.txt index ceda139..3815a3c 100644 --- a/templates.txt +++ b/templates.txt @@ -4,6 +4,8 @@ Этот бота создан для неформальных 1-1 встреч с людьми в чатах. {# #}Бот назначает людям партнеров (как правило, раз в неделю), после чего они встречаются очно или онлайн и знакомятся. Приятного общения! +Чтобы сделать ваше сообщество более сплоченным и помочь людям найти собеседников, просто добавьте этого бота в свой чат. +Используйте /request чтобы запросить встречу, /help чтобы вывести это сообщение //| en |// {% if start %}Hello, {{ tg_user.first_name }}!{% endif %} @@ -11,6 +13,8 @@ This bot is created for non-formal 1-1 meetings with people in chat. {# #}The bot assigns people partners (usually once a week), after which they meet online or in person and get to know each other. Have a nice chat! {# todo: add commands and information on adding to a chat #} +To make your community more connected just add the bot to your chat +Use /request to request a meeting, /help for this information ||<| admin_stats |>|| //| |// diff --git a/views.py b/views.py index b94df61..6ccc8af 100644 --- a/views.py +++ b/views.py @@ -17,6 +17,7 @@ def views(bot: Bot): bot.reply_with_template(msg, 'community_added', community=community, already_member=True) elif community.add_member(user.user_id, bot): bot.reply_with_template(msg, 'community_added', community=community, already_member=False) + bot.poll_user_for_community(user, community) else: bot.reply_with_template(msg, 'err_not_a_member', community=community) bot.reply_with_template(msg, 'info', start=True)