How do I send messages to Telegram?

Asked

Viewed 8 times

0

def set_chat_id(c):
    chat_ids.append(c)
def main():
    
    api_config = {}
    with open('api_config.json') as json_data:
        api_config = json.load(json_data)
        json_data.close()
    TOKEN = api_config['telegram_bot_token']
    tb = telebot.TeleBot(TOKEN) 
    def send_message(chat_id, msg):
        try:
            tb.send_message(chat_id, msg)
        except:
            pass
    
    def send_to_all_chat_ids(msg):
        for chat_id in chat_ids:
            send_message(chat_id, msg)
    @tb.message_handler(commands=['start', 'help'])
    def send_welcome(message):
        set_chat_id(message.chat.id)
        tb.reply_to(message, "CoinPump!")
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.