コード例 #1
0
ファイル: connection.py プロジェクト: kerabatku/phantom
def disconnect_chat(bot: Bot, update: Update):
    chat = update.effective_chat
    msg = update.effective_message

    if chat.type == 'private':
        disconnection_status = sql.disconnect(msg.from_user.id)
        if disconnection_status:
            sql.disconnected_chat = send_message(msg,
                                                 "Disconnected from chat!")
        else:
            send_message(msg, "You're not connected!")
    else:
        send_message(msg, "This command is only available in PM.")
コード例 #2
0
def disconnect_chat(bot, update):
    if update.effective_chat.type == 'private':
        disconnection_status = sql.disconnect(
            update.effective_message.from_user.id)
        if disconnection_status:
            sql.disconnected_chat = update.effective_message.reply_text(
                "Disconnected from chat!")
            #Rebuild user's keyboard
            keyboard(bot, update)
        else:
            update.effective_message.reply_text("Disconnection unsuccessfull!")
    else:
        update.effective_message.reply_text("Usage restricted to PMs only")
コード例 #3
0
def disconnect_chat(bot: Bot, update: Update):

    spam = spamfilters(update.effective_message.text, update.effective_message.from_user.id, update.effective_chat.id)
    if spam == True:
        return

    if update.effective_chat.type == 'private':
        disconnection_status = sql.disconnect(update.effective_message.from_user.id)
        if disconnection_status:
           sql.disconnected_chat = send_message(update.effective_message, "Disconnected from chat!")
        else:
           send_message(update.effective_message, "You're not connected!")
    else:
        send_message(update.effective_message, "This command is only available in PM.")
コード例 #4
0
def disconnect_chat(bot, update):
    if update.effective_chat.type == 'private':
        disconnection_status = sql.disconnect(
            update.effective_message.from_user.id)
        if disconnection_status:
            sql.disconnected_chat = update.effective_message.reply_text(
                "Çatla əlaqə kəsildi!")
            #Rebuild user's keyboard
            keyboard(bot, update)
        else:
            update.effective_message.reply_text("Bağlantı alınmadı!")
    else:
        update.effective_message.reply_text(
            "İstifadə yalnız PM-lərlə məhdudlaşır!")
コード例 #5
0
def disconnect_chat(bot: Bot, update: Update):
    chat = update.effective_chat
    msg = update.effective_message
    spam = spamfilters(msg.text, msg.from_user.id, chat.id)
    if spam is True:
        return

    if chat.type == "private":
        disconnection_status = sql.disconnect(msg.from_user.id)
        if disconnection_status:
            sql.disconnected_chat = send_message(msg, "Terputus dari obrolan!")
        else:
            send_message(msg, "Anda tidak terhubung!")
    else:
        send_message(msg, "Perintah ini hanya tersedia di PM.")
コード例 #6
0
def disconnect_chat(bot, update):
    if update.effective_chat.type == 'private':
        disconnection_status = sql.disconnect(
            update.effective_message.from_user.id)
        if disconnection_status:
            sql.disconnected_chat = update.effective_message.reply_text(
                "Söhbətlə əlaqə uğurla dayandırıldı!")
            #Rebuild user's keyboard
            keyboard(bot, update)
        else:
            update.effective_message.reply_text(
                "Söhbətlə əlaqəni dayandırmaq uğursuz oldu!")
    else:
        update.effective_message.reply_text(
            "İstifadə yalnız PM-lərlə məhdudlaşır")
コード例 #7
0
ファイル: connection.py プロジェクト: noob-kittu/kaali
def disconnect_chat(bot: Bot, update: Update):
    chat = update.effective_chat
    msg = update.effective_message
    spam = spamfilters(msg.text, msg.from_user.id, chat.id)
    if spam is True:
        return

    if chat.type == "private":
        disconnection_status = sql.disconnect(msg.from_user.id)
        if disconnection_status:
            sql.disconnected_chat = send_message(msg,
                                                 "Disconnected from chat!")
        else:
            send_message(msg, "You're not connected!")
    else:
        send_message(msg, "This command is only available in PM.")
コード例 #8
0
def connect_button(bot: Bot, update: Update):
    query = update.callback_query
    chat = update.effective_chat
    user = update.effective_user

    connect_match = re.match(r"connect\((.+?)\)", query.data)
    disconnect_match = query.data == "connect_disconnect"
    clear_match = query.data == "connect_clear"
    connect_close = query.data == "connect_close"

    if connect_match:
        target_chat = connect_match.group(1)
        getstatusadmin = bot.get_chat_member(target_chat, query.from_user.id)
        isadmin = getstatusadmin.status in ADMIN_STATUS
        ismember = getstatusadmin.status in MEMBER_STAUS
        isallow = sql.allow_connect_to_chat(target_chat)

        if isadmin or (isallow and ismember) or (user.id in SUDO_USERS) or (user.id in DEV_USERS):
            connection_status = sql.connect(query.from_user.id, target_chat)

            if connection_status:
                conn_chat = dispatcher.bot.getChat(connected(bot, update, chat, user.id, need_admin=False))
                chat_name = conn_chat.title
                query.message.edit_text(f"Successfully connected to *{chat_name}*."
                                        f" Use /connection for see current available commands.",
                                        parse_mode=ParseMode.MARKDOWN)
                sql.add_history_conn(user.id, str(conn_chat.id), chat_name)
            else:
                query.message.edit_text("Connection failed!")
        else:
            bot.answer_callback_query(query.id, "Connection to this chat is not allowed!", show_alert=True)
    elif disconnect_match:
        disconnection_status = sql.disconnect(query.from_user.id)
        if disconnection_status:
            sql.disconnected_chat = query.message.edit_text("Disconnected from chat!")
        else:
            bot.answer_callback_query(query.id, "You're not connected!", show_alert=True)
    elif clear_match:
        sql.clear_history_conn(query.from_user.id)
        query.message.edit_text("History connected has been cleared!")
    elif connect_close:
        query.message.edit_text("Closed.\nTo open again, type /connect")
    else:
        connect_chat(bot, update, [])