Exemplo n.º 1
0
def class_chat_check(mes):
    if mes.from_user.id in [CASTLE_BOT_ID, SUPER_ADMIN_ID, king_id
                            ] or check_access(mes.from_user.id):
        return False
    if mes.new_chat_members is not None:
        users = mes.new_chat_members
    else:
        users = [mes.from_user]
    for user in users:
        player = Player.get_player(user.id)
        if player is None or player.game_class is None or class_chats.get(player.game_class) != mes.chat_id or \
                player.castle != '🖤':
            return True
    return False
Exemplo n.º 2
0
def revoke_class_link(game_class):
    chat_id = class_chats.get(game_class)
    if chat_id is None:
        return -1
    barracks = Location.get_location(1)
    class_links = barracks.special_info.get("class_links")
    if class_links is None:
        class_links = {}
        barracks.special_info.update({"class_links": class_links})
    try:
        invite_link = dispatcher.bot.exportChatInviteLink(chat_id)
        if invite_link is not None:
            invite_link = invite_link[22:]  # Обрезаю https://t.me/joinchat/
            class_links.update({game_class: invite_link})
            barracks.update_location_to_database()
    except TelegramError:
        logging.error(traceback.format_exc())
        return 1
Exemplo n.º 3
0
def class_chat_kick(bot, update):
    mes = update.message
    if mes.new_chat_members is not None:
        users = mes.new_chat_members
    else:
        users = [update.message.from_user]
    for user in users:
        if class_chat_player_check(user.id, mes.chat_id):
            try:
                cl = class_chats_inverted.get(mes.chat_id)
                text = "Это чат <b>{}</b>. Он не для тебя.".format(cl)
                if mes.chat_id == class_chats.get('Sentinel'):
                    text = "Ты зашел в чат Б-гоизбранных Стражей Скалы. Но этот чат не для тебя, ничтожество. " \
                           "Иди погуляй, алебарду тебе в задницу"
                bot.kickChatMember(chat_id=mes.chat_id, user_id=user.id)
                bot.send_message(chat_id=mes.chat_id,
                                 text=text,
                                 parse_mode='HTML')
            except TelegramError:
                return
Exemplo n.º 4
0
def class_chat_player_check(player_id, chat_id):
    player = Player.get_player(player_id)
    if player is None or player.game_class is None or class_chats.get(player.game_class) != chat_id or \
            player.castle != '🖤':
        return True
    return False