case message.data
when 'touch'
touch = [
Telegram::Bot::Types::InlineKeyboardButton.new(text: '2-клавиатура', callback_data: 'touch3')
]
touch1 = Telegram::Bot::Types::InlineKeyboardMarkup.new(inline_keyboard: touch)
bot.api.send_message(chat_id: message.from.id, text: "Он там?", reply_markup: touch1)
when 'test'
test = [
Telegram::Bot::Types::InlineKeyboardButton.new(text: '1-клавиатура', callback_data: 'touch3')
]
test1 = Telegram::Bot::Types::InlineKeyboardMarkup.new(inline_keyboard: test)
bot.api.send_message(chat_id: message.from.id, text: "Ты тут?", reply_markup: test1)
end
when Telegram::Bot::Types::Message
case message.text
when '/start'
kb = [
Telegram::Bot::Types::InlineKeyboardButton.new(text: '1-клава', callback_data: 'test'),
Telegram::Bot::Types::InlineKeyboardButton.new(text: '2-клава', callback_data: 'touch')
]
markup = Telegram::Bot::Types::InlineKeyboardMarkup.new(inline_keyboard: kb)
bot.api.send_message(chat_id: message.chat.id, text: 'Выбери кнопку', reply_markup: markup)
end
end
end
end
import os
import requests
from telegram.ext import CommandHandler, Updater
class Bot:
def __init__(self, token, debug=False):
self._token = token
self._updater = Updater(token)
self._debug = debug
self._init_handlers()
def run(self):
port = int(os.environ.get('PORT', '5000'))
self._updater.start_webhook(listen='0.0.0.0', port=port,
url_path=self._token)
self._updater.bot.set_webhook(os.environ.get("URL") +
self._token)
self._updater.idle()
def _init_handlers(self):
self._updater.dispatcher.add_handler(CommandHandler('rate', self._check_rate))
def log_params(method_name, update):
logger.debug("Method: %s\nFrom: %s\nchat_id: %d\nText: %s" %
(method_name,
update.message.from_user,
update.message.chat_id,
update.message.text))
def start(bot, update):
log_params('start', update)
bot.sendMessage(update.message.chat_id
, text="""Привет!""")
def bot():
updater = Updater(TOKEN)
# Get the dispatcher to register handlers
dp = updater.dispatcher
# Add handlers for Telegram messages
dp.addTelegramCommandHandler("start", start)
updater.start_polling()
updater.idle()
if __name__ == '__bot__':
bot()
2017-04-10T14:08:21.086556+00:00 app[web.1]: ModuleNotFoundError: No module named 'telebot'
2017-04-10T14:08:21.086517+00:00 app[web.1]: import telebot
2017-04-10T14:08:21.194284+00:00 heroku[web.1]: State changed from starting to crashed
2017-04-10T17:00:00.641113+00:00 heroku[web.1]: State changed from crashed to starting
2017-04-10T17:00:06.063036+00:00 heroku[web.1]: Starting process with command `python3 main.py`
2017-04-10T17:00:08.472895+00:00 app[web.1]: Traceback (most recent call last):
2017-04-10T17:00:08.472917+00:00 app[web.1]: File "main.py", line 3, in
2017-04-10T17:00:08.473066+00:00 app[web.1]: import telebot
2017-04-10T17:00:08.473106+00:00 app[web.1]: ModuleNotFoundError: No module named 'telebot'
2017-04-10T17:00:08.586876+00:00 heroku[web.1]: State changed from starting to crashed
2017-04-10T17:00:08.570948+00:00 heroku[web.1]: Process exited with status 1
-----> Failed to detect app matching https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/nodejs.tgz buildpack
More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
! Push failed
правильно..