Skip to content

morzecrew/tg-bot-wrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tg-bot-wrapper

Usage

firstly set in variable KEY your bot token in main.rb

add your handler in handlers/custom directory

require_relative '../handler'

module Handlers
  class MyAwesomeHandler < Handler
    message_type! :text
    available_data! :any

    def self.handle(message, bot)
      bot.api.send_message(
        parse_mode: 'html',
        chat_id: message.chat.id,
        text: 'I'm works!'
      )
    end
  end
end

handle only messages "hello", "hi"

require_relative '../handler'

module Handlers
  class HelloHandler < Handler
    message_type! :text
    available_data! ['hello', 'hi']

    def self.handle(message, bot)
      bot.api.send_message(
        parse_mode: 'html',
        chat_id: message.chat.id,
        text: 'Hi!'
      )
    end
  end
end

handle click on inline button

require_relative '../handler'

module Handlers
  class BtnHandler < Handler
    message_type! :callback_query
    available_data! ['create_smth']

    def self.handle(message, bot)
      bot.api.send_message(
        parse_mode: 'html',
        chat_id: message.chat.id,
        text: 'Click on btn!'
      )
    end
  end
end

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages