Телеграм боты
Как сделать тг-бота с помощью Yandex Cloud Functions?
-
Создаем бота в @botfather, получаем токен
-
Ставим либу
-
Пишем функцию
import json import os import telegram def handler(event, context): bot = telegram.Bot(token=os.environ['TG_TOKEN']) update = telegram.Update.de_json(json.loads(event['body']), bot) chat = update.message.chat_id msg = update.message.text bot.send_message(chat, msg) return {'statusCode': 200, 'body': '', }
-
Заливаем ее, напр. с помощью плагина
-
Дружим бота и функцию
Источник: https://cloud.yandex.ru/docs/api-gateway/tutorials/telegram-bot-serverless