зеркало из
https://github.com/glebtv/telegram-bot.git
synced 2026-08-28 15:26:18 +03:00
Сравнить коммиты
11 Коммитов
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
ca4ea9e6cb | ||
|
|
68ec0257bd | ||
|
|
b50bd30137 | ||
|
|
80362da270 | ||
|
|
294d762785 | ||
|
|
1cb3265371 | ||
|
|
c44529725f | ||
|
|
fa43561765 | ||
|
|
cea856c928 | ||
|
|
5a93c1efc6 | ||
|
|
38ee303912 |
@@ -25,10 +25,3 @@ matrix:
|
||||
gemfile: gemfiles/rails_60.gemfile
|
||||
notifications:
|
||||
email: false
|
||||
|
||||
# for 2.5.0 until 2.5.1 is released:
|
||||
# https://github.com/travis-ci/travis-ci/issues/8978
|
||||
# https://github.com/travis-ci/travis-ci/issues/8969#issuecomment-354135622
|
||||
before_install:
|
||||
- gem update --system
|
||||
- gem install bundler
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
# Unreleased
|
||||
|
||||
# 0.14.2
|
||||
|
||||
- Add reply helpers: `answer_pre_checkout_query`, `answer_shipping_query`.
|
||||
- Update to Bot API 4.3.
|
||||
|
||||
# 0.14.1
|
||||
|
||||
- Read config from secrets when credentials don't provide it in rails >= 5.2.
|
||||
- Remove botan.io support. It's already shut down, so it should not be a braking change.
|
||||
https://github.com/botanio/sdk#this-service-will-be-shut-down-on-25th-may-2018
|
||||
- Update to Bot API 4.1.
|
||||
|
||||
# 0.14.0
|
||||
|
||||
|
||||
@@ -100,10 +100,12 @@ development:
|
||||
|
||||
For Rails >= 5.2 `Telegram::Bot` searches for config first in credentials and then in secrets.
|
||||
To use credentials as config store, add telegram section to credentials instead of secrets using
|
||||
`rails credentials:edit`. In this case be aware of that [Rails may not load
|
||||
`rails credentials:edit`. In this case be aware of that [Rails < 6.0 may not load
|
||||
credentials in dev environment by default](https://github.com/telegram-bot-rb/telegram-bot/issues/74#issuecomment-384205609).
|
||||
In Rails >= 6.0 run `rails credentials:edit --environment development` to configure bot
|
||||
in each environment.
|
||||
|
||||
I suggest not using Rails 5.2 credentials because it can lead to leakage of sesitive data
|
||||
I suggest not using Rails 5.2 credentials because it can lead to leakage of sensitive data
|
||||
and it's more difficult to use in multiple environments. See
|
||||
[secure_credentials](https://github.com/printercu/secure_credentials) gem for better option.
|
||||
|
||||
@@ -229,6 +231,8 @@ def reply_with(type, params); end
|
||||
def answer_inline_query(results, params = {}); end
|
||||
def answer_callback_query(text, params = {}); end
|
||||
def edit_message(type, params = {}); end
|
||||
def answer_pre_checkout_query(ok, params = {}); end
|
||||
def answer_shipping_query(ok, params = {}); end
|
||||
```
|
||||
|
||||
#### Optional typecasting
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Generated with bin/fetch-telegram-methods
|
||||
# Bot API 4.1
|
||||
# Bot API 4.3
|
||||
|
||||
getUpdates
|
||||
setWebhook
|
||||
@@ -22,6 +22,7 @@ editMessageLiveLocation
|
||||
stopMessageLiveLocation
|
||||
sendVenue
|
||||
sendContact
|
||||
sendPoll
|
||||
sendChatAction
|
||||
getUserProfilePhotos
|
||||
getFile
|
||||
@@ -49,6 +50,7 @@ editMessageText
|
||||
editMessageCaption
|
||||
editMessageMedia
|
||||
editMessageReplyMarkup
|
||||
stopPoll
|
||||
deleteMessage
|
||||
|
||||
sendSticker
|
||||
|
||||
@@ -7,13 +7,13 @@ module Telegram
|
||||
module Bot
|
||||
# Base class to create update processors. With callbacks, session and helpers.
|
||||
#
|
||||
# Define public methods for each command and they will be called when
|
||||
# update has this command. Message is automatically parsed and
|
||||
# words are passed as method arguments. Be sure to use default values and
|
||||
# Public methods ending with `!` handle messages with commands.
|
||||
# Message text is automatically parsed into method arguments.
|
||||
# Be sure to use default values and
|
||||
# splat arguments in every action method to not get errors, when user
|
||||
# sends command without necessary args / with extra args.
|
||||
#
|
||||
# def start(token = nil, *)
|
||||
# def start!(token = nil, *)
|
||||
# if token
|
||||
# # ...
|
||||
# else
|
||||
@@ -21,25 +21,21 @@ module Telegram
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# def help(*)
|
||||
# def help!(*)
|
||||
# respond_with :message, text:
|
||||
# end
|
||||
#
|
||||
# To process plain text messages (without commands) or other updates just
|
||||
# define public method with name of payload type. They will receive payload
|
||||
# as an argument.
|
||||
# define public method with name of payload type.
|
||||
# By default they receive payload as an argument, but some of them are called
|
||||
# with more usefuk args:
|
||||
#
|
||||
# def message(message)
|
||||
# respond_with :message, text: "Echo: #{message['text']}"
|
||||
# end
|
||||
#
|
||||
# def inline_query(query)
|
||||
# answer_inline_query results_for_query(query), is_personal: true
|
||||
# end
|
||||
#
|
||||
# # To process conflicting commands (`/message args`) just use `on_` prefix:
|
||||
# def on_message(*args)
|
||||
# # ...
|
||||
# def inline_query(query, offset)
|
||||
# answer_inline_query results_for_query(query, offset), is_personal: true
|
||||
# end
|
||||
#
|
||||
# To process update run:
|
||||
|
||||
@@ -21,7 +21,7 @@ module Telegram
|
||||
respond_with(type, params)
|
||||
end
|
||||
|
||||
# Same as reply_with, but for inline queries.
|
||||
# Same as respond_with, but for inline queries.
|
||||
def answer_inline_query(results, params = {})
|
||||
params = params.merge(
|
||||
inline_query_id: payload['id'],
|
||||
@@ -30,7 +30,7 @@ module Telegram
|
||||
bot.answer_inline_query(params)
|
||||
end
|
||||
|
||||
# Same as reply_with, but for callback queries.
|
||||
# Same as respond_with, but for callback queries.
|
||||
def answer_callback_query(text, params = {})
|
||||
params = params.merge(
|
||||
callback_query_id: payload['id'],
|
||||
@@ -39,6 +39,23 @@ module Telegram
|
||||
bot.answer_callback_query(params)
|
||||
end
|
||||
|
||||
# Same as respond_with, but for pre checkout queries.
|
||||
def answer_pre_checkout_query(ok, params = {})
|
||||
params = params.merge(
|
||||
pre_checkout_query_id: payload['id'],
|
||||
ok: ok,
|
||||
)
|
||||
bot.answer_pre_checkout_query(params)
|
||||
end
|
||||
|
||||
def answer_shipping_query(ok, params = {})
|
||||
params = params.merge(
|
||||
shipping_query_id: payload['id'],
|
||||
ok: ok,
|
||||
)
|
||||
bot.answer_shipping_query(params)
|
||||
end
|
||||
|
||||
# Edit message from callback query.
|
||||
def edit_message(type, params = {})
|
||||
params =
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module Telegram
|
||||
module Bot
|
||||
VERSION = '0.14.1'.freeze
|
||||
VERSION = '0.14.2'.freeze
|
||||
|
||||
def self.gem_version
|
||||
Gem::Version.new VERSION
|
||||
|
||||
@@ -26,6 +26,6 @@ Gem::Specification.new do |spec|
|
||||
spec.add_dependency 'activesupport', '>= 4.0', '< 6.0'
|
||||
spec.add_dependency 'httpclient', '~> 2.7'
|
||||
|
||||
spec.add_development_dependency 'bundler', '~> 1.16'
|
||||
spec.add_development_dependency 'bundler', '> 1.16'
|
||||
spec.add_development_dependency 'rake', '~> 10.0'
|
||||
end
|
||||
|
||||
Ссылка в новой задаче
Block a user