Browse Source

Some little fixes, todos, templates

master
Lev 2 years ago
parent
commit
ca1d278415
  1. 2
      README.md
  2. 11
      bot.py
  3. 4
      templates.txt
  4. 1
      views.py

2
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

11
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):

4
templates.txt

@ -4,6 +4,8 @@
Этот бота создан для неформальных 1-1 встреч с людьми в чатах. {#
#}Бот назначает людям партнеров (как правило, раз в неделю), после чего они встречаются очно или онлайн и знакомятся.
Приятного общения!
Чтобы сделать ваше сообщество более сплоченным и помочь людям найти собеседников, просто добавьте этого бота в свой чат.
Используйте /request чтобы запросить встречу, /help чтобы вывести это сообщение
//| en |//
{% if start %}Hello, <b>{{ tg_user.first_name }}</b>!{% 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 |>||
//| |//

1
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)

Loading…
Cancel
Save