Avatar ·

telegram-bot in a group chat

📁 Advanced Python Topics, work

I made a simple telegram-bot:

import telebot@bot.message_handler(content_types=[""text""])def repeat_all_messages(message):    if (message.text.split("" "")[0].upper() == 'BOT,'):        bot.send_message(message.chat.id, 'I\\'m here')

Everything works fine, but when I add it to a group chat, it stays silent. Tell me how to make it adapted for group chats?

Avatar ·

Look.

First, A and C must be coprime. If they are not coprime, then any linear combination (A * X) % C = A * X + C * Y will not equal one, meaning there is no answer.

Okay, suppose numbers A and C are coprime. To establish this, you must use the Euclidean algorithm to compute GCD. If you use the extended Euclidean algorithm, you will get not just the GCD, but also the coefficients alpha, beta such that

alpha * A + beta * C = GCD(A, C) = 1.

Here, alpha is your answer, since

(alpha * A) % C = (1 -                                

Log in to leave an answer

Blogs