2021-04-09 10:17:38 +02:00
|
|
|
import time
|
|
|
|
|
2021-04-12 19:47:21 +02:00
|
|
|
from idm.api.proto.chat_manager_service_pb2 import Chat as ChatPb
|
2021-04-09 10:17:38 +02:00
|
|
|
from nexus.bot.application import TelegramApplication
|
|
|
|
|
|
|
|
|
|
|
|
class BanlistWidget:
|
2021-04-12 19:47:21 +02:00
|
|
|
def __init__(self, application: TelegramApplication, chat: ChatPb):
|
2021-04-09 10:17:38 +02:00
|
|
|
self.application = application
|
|
|
|
self.chat = chat
|
|
|
|
|
2021-04-12 19:47:21 +02:00
|
|
|
async def render(self, chat_list: list[ChatPb]):
|
2021-04-09 10:17:38 +02:00
|
|
|
if not chat_list:
|
|
|
|
return 'Nobody is banned'
|
|
|
|
separator = '------------\n'
|
|
|
|
return separator.join(
|
|
|
|
map(
|
|
|
|
lambda chat: (
|
2021-04-12 19:47:21 +02:00
|
|
|
f'```{chat.username} ({chat.chat_id})\n'
|
2021-04-09 10:17:38 +02:00
|
|
|
f'Until: {time.ctime(chat.ban_until)}\n'
|
|
|
|
f'Message: {chat.ban_message}```\n'
|
2021-04-12 19:47:21 +02:00
|
|
|
f'/unban_{chat.chat_id}\n'
|
2021-04-09 10:17:38 +02:00
|
|
|
),
|
|
|
|
chat_list
|
|
|
|
)
|
|
|
|
)
|