Browse Source

Templates, requesting meetings

master
Lev 2 years ago
parent
commit
cb034901d3
  1. 1
      README.md
  2. 2
      community.py
  3. 30
      templates.txt
  4. 9
      views.py

1
README.md

@ -12,6 +12,5 @@ Random meetings for chats, kind of like RandomCoffee.
4. The bot sends the matches and links to their Telegram accounts
TODO:
- A button to request a meeting
- Add commands like info
- In templates replace "this week" with "soon"

2
community.py

@ -74,7 +74,7 @@ class Community:
# Check if there isn't a meeting in archived_meetings with its scheduling date today or yesterday
return not any(
r in [date.today(), date.today() - timedelta(days=1)] and user_id in [l, m]
for l, m, r in self.scheduled_meetings + self.archived_meetings)
for l, m, r in self.scheduled_meetings + self.archived_meetings) and user_id not in self.pool
def add_member(self, user_id: int, bot: Bot) -> bool:
chat_member_info: ChatMember = bot.get_chat_member(self.chat_id, user_id)

30
templates.txt

@ -1,14 +1,16 @@
||<| start |>||
||<| info |>||
//| ru |//
Здравствуйте, <b>{{ tg_user.first_name }}</b>!
//| en |//
Hello, <b>{{ tg_user.first_name }}</b>!
{% if start %}Привет, <b>{{ tg_user.first_name }}</b>!{% endif %}
Этот бота создан для неформальных 1-1 встреч с людьми в чатах. {#
#}Бот назначает людям партнеров (как правило, раз в неделю), после чего они встречаются очно или онлайн и знакомятся.
Приятного общения!
||<| help |>||
//| en |//
/help - Help
//| ru |//
/help - помощь
{% if start %}Hello, <b>{{ tg_user.first_name }}</b>!{% endif %}
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 #}
||<| admin_stats |>||
//| |//
@ -63,6 +65,18 @@ What community do you want to have a meeting in?
>>| {{ name }} :-: request_meeting_{{ id }} |<<
{% endfor %}
||<| request_meeting_success |>||
//| en |//
You have successfully requested a meeting in the community <b>{{ community.name }}</b>. You'll get your match soon.
//| ru |//
Вы успешно запросили встречу в сообществе <b>{{ community.name }}</b>. Вам придет сообщение с партнером в ближайшее время.
||<| request_meeting_failure |>||
//| en |//
You have already requested a meeting in the community <b>{{ community.name }}</b> recently. You'll be able to request another meeting in a few days.
//| ru |//
Вы уже запрашивали встречу в сообществе <b>{{ community.name }}</b> недавно. Вы сможете запросить еще одну встречу через несколько дней.
||<| canceled |>||
//| en |//
Canceled

9
views.py

@ -1,3 +1,5 @@
from datetime import date
from bot import Bot
from community import Community
@ -17,11 +19,11 @@ def views(bot: Bot):
bot.reply_with_template(msg, 'community_added', community=community, already_member=False)
else:
bot.reply_with_template(msg, 'err_not_a_member', community=community)
bot.reply_with_template(msg, 'start')
bot.reply_with_template(msg, 'info', start=True)
@bot.handle_commands(['/help', ' About', ' О боте'])
def handle_help(msg, _user, _args):
bot.reply_with_template(msg, 'help')
bot.reply_with_template(msg, 'info', start=False)
@bot.handle_commands(['/request', '📝 Request a meeting', '📝 Запросить встречу'])
def request_meeting(msg, user, _args):
@ -32,7 +34,8 @@ def views(bot: Bot):
def request_meeting_callback(msg, user, args):
community = Community.by_id(int(args), bot)
if community.can_user_request_a_meeting(user.user_id):
# todo: request the meeting and write the template
community.polled[user.user_id] = date.today()
community.pool.append(user.user_id)
bot.reply_with_template(msg, 'request_meeting_success', community=community)
else:
bot.reply_with_template(msg, 'request_meeting_failure', community=community)

Loading…
Cancel
Save