Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FAQ] sample rails app with telegram-bot-ruby #161

Closed
kirantpatil opened this issue Nov 17, 2017 · 4 comments
Closed

[FAQ] sample rails app with telegram-bot-ruby #161

kirantpatil opened this issue Nov 17, 2017 · 4 comments
Labels

Comments

@kirantpatil
Copy link

Hi,

I would like to know how to use this gem with Rails app ?

If there is a sample app, please provide its source code url.

Thanks.

@masfree
Copy link

masfree commented Nov 17, 2017

Hi @kirantpatil , it look's like:

require 'telegram/bot'
class YourClass
  Telegram::Bot::Api.new(your_token).send_message(chat_id: your_chat_id, text: your_text)
end

do not forgot gem 'telegram-bot-ruby' in your bundle

@chriso0710
Copy link

Take a look at #19

@pskl
Copy link

pskl commented May 24, 2020

@kirantpatil Something like

class TelegramController < ApplicationController
  before_action :auth
  skip_before_action :verify_authenticity_token

  def webhook
    update = Telegram::Bot::Types::Update.new(params.permit!.to_h)
    message = update.message
    # do something
  end

  private

  def client
    @client ||= Telegram::Bot::Api.new(Rails.application.credentials.telegram[:bot_token])
  end

  def auth
    Raise "Unauthorized" unless params.require(:webhook_token) == Rails.application.credentials.telegram[:webhook_token]
  end
end

@github-actions
Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the stale label Feb 19, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants