Browse Source

Checking

master
Lev 3 years ago
parent
commit
8e5908e228
  1. 4
      community.py
  2. 12
      templates.txt
  3. 2
      user.py
  4. 11
      views.py

4
community.py

@ -93,9 +93,7 @@ class Community:
def add_answer(self, user_id: typing.Union[int, bool], answer: bool, bot: Bot):
answer = bool(answer)
if user_id not in self.users_to_poll():
return
if user_id in self.pool:
while user_id in self.pool:
self.pool.remove(user_id)
self.pool += [user_id] * answer
self.default_answers[user_id] = bool(answer)

12
templates.txt

@ -87,3 +87,15 @@ Canceled
//| ru |//
Отменено
||<| err_not_private |>||
//| en |//
This command can only be used in private chats.
//| ru |//
Эта команда может быть использована только в личных чатах.
||<| err_not_community |>||
//| en |//
This command can only be used in groups.
//| ru |//
Эта команда может быть использована только в группах.

2
user.py

@ -2,10 +2,10 @@ from __future__ import annotations
from dataclasses import dataclass, field, asdict
import typing
import time
from community import Community
if typing.TYPE_CHECKING:
from bot import Bot
from community import Community
@dataclass

11
views.py

@ -28,14 +28,19 @@ def views(bot: Bot):
@bot.handle_commands(['/request', '📝 Request a meeting', '📝 Запросить встречу'])
def request_meeting(msg, user, _args):
# todo: don't allow this command in chats
comm_ids_and_names = [(community.chat_id, community.name) for community in user.communities]
if msg.chat.type != 'private':
bot.reply_with_template(msg, 'err_not_private')
return
comm_ids_and_names = [(community.chat_id, community.name) for community in user.get_communities(bot)]
bot.reply_with_template(msg, 'request_meeting', comm_list=comm_ids_and_names)
@bot.handle_commands(['/join'])
def join_community(msg, user, args):
# check if it really is a community
if msg.chat.type == 'private':
bot.reply_with_template(msg, 'err_not_community')
return
# send community link
# todo: check if it really is a community
community = Community.by_id(msg.chat.id, bot)
bot.reply_with_template(msg, 'welcome', community=community, join=True)

Loading…
Cancel
Save