A
A
axtrace2016-06-24 17:17:26
Python
axtrace, 2016-06-24 17:17:26

Telebot (python): how to kick a user out of a chat?

I'm making a bot. Primary authorization - by phone number. I get the user's phone number, check if it is in the database. I don't know how to throw it out (or not let it write) if it is not in the database.

import config
import getNumber
import telebot
from telebot import types

bot = telebot.TeleBot(config.token)
numId = getNumber.NumberIdentifier()


@bot.message_handler(commands=['start', 'help'])
def send_welcome(message):
    # Получаем номер телефона от пользователя
    markup = types.ReplyKeyboardMarkup(one_time_keyboard=True)
    batton = types.KeyboardButton("Логин по номеру телефона", request_contact=True)
    markup.add(batton)
    msg = bot.reply_to(message, 'Так-с. А вы точно не шпион? Проверю-ка я ваш номер телефона...', reply_markup=markup)
    bot.register_next_step_handler(msg, process_step)


def process_step(message):
    if numId.checkPhoneNumber(message.contact.phone_number)=='bad':
        #Не знаю, как тут прекратить с ним общение
    bot.sendMessage(message.chat.id, 'I am hiding it', reply_markup=types.hide_keyboard)

@bot.message_handler(content_types=["text"])

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2016-07-18
@axtrace

just when processing each message, check whether the given user is suitable, do not send anything, or send a text that he is not authorized, it is not at all necessary to stop communication. and forbid him to write

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question