1
0
зеркало из https://github.com/glebtv/telegram-bot.git synced 2026-09-03 17:55:52 +03:00
Collect all api helper-methods in Client::ApiHelper module.
Add bin/fetch-telegram-methods to update methods list from website.
Этот коммит содержится в:
Max Melentiev
2017-11-24 10:57:44 +03:00
родитель 81c18034a5
Коммит 9e396cabc4
8 изменённых файлов: 155 добавлений и 70 удалений

31
lib/telegram/bot/client/api_helper.rb Обычный файл
Просмотреть файл

@@ -0,0 +1,31 @@
require 'active_support/core_ext/string/inflections'
module Telegram
module Bot
class Client
module ApiHelper
METHODS_LIST_FILE = File.expand_path('../api_methods.txt', __FILE__)
class << self
def methods_list(file = METHODS_LIST_FILE)
File.read(file).lines.
map(&:strip).
reject { |x| x.empty? || x.start_with?('#') }
end
# Defines method with underscored name to post to specific endpoint:
#
# define_method :getMe
# # defines #get_me
def define_helpers(*list)
list.map(&:to_s).each do |method|
define_method(method.underscore) { |*args| request(method, *args) }
end
end
end
define_helpers(*methods_list)
end
end
end
end

68
lib/telegram/bot/client/api_methods.txt Обычный файл
Просмотреть файл

@@ -0,0 +1,68 @@
# Generated with bin/fetch-telegram-methods
# Bot API 3.5.
getUpdates
setWebhook
deleteWebhook
getWebhookInfo
getMe
sendMessage
forwardMessage
sendPhoto
sendAudio
sendDocument
sendVideo
sendVoice
sendVideoNote
sendMediaGroup
sendLocation
editMessageLiveLocation
stopMessageLiveLocation
sendVenue
sendContact
sendChatAction
getUserProfilePhotos
getFile
kickChatMember
unbanChatMember
restrictChatMember
promoteChatMember
exportChatInviteLink
setChatPhoto
deleteChatPhoto
setChatTitle
setChatDescription
pinChatMessage
unpinChatMessage
leaveChat
getChat
getChatAdministrators
getChatMembersCount
getChatMember
setChatStickerSet
deleteChatStickerSet
answerCallbackQuery
editMessageText
editMessageCaption
editMessageReplyMarkup
deleteMessage
sendSticker
getStickerSet
uploadStickerFile
createNewStickerSet
addStickerToSet
setStickerPositionInSet
deleteStickerFromSet
answerInlineQuery
sendInvoice
answerShippingQuery
answerPreCheckoutQuery
sendGame
setGameScore
getGameHighScores