Class: TelegramWorkflow::Client
- Inherits:
-
Object
- Object
- TelegramWorkflow::Client
- Defined in:
- lib/telegram_workflow/client.rb
Constant Summary collapse
- API_VERSION =
"6.7"
- WebhookConfigPath =
Pathname.new("tmp/telegram_workflow/webhook_config.txt")
- AVAILABLE_ACTIONS =
%i( getUpdates getWebhookInfo getMe sendMessage forwardMessage copyMessage sendPhoto sendAudio sendDocument sendVideo sendAnimation sendVoice sendVideoNote sendMediaGroup sendLocation editMessageLiveLocation stopMessageLiveLocation sendVenue sendContact sendPoll sendDice sendChatAction getUserProfilePhotos getFile kickChatMember banChatMember unbanChatMember restrictChatMember promoteChatMember setChatAdministratorCustomTitle banChatSenderChat unbanChatSenderChat setChatPermissions exportChatInviteLink createChatInviteLink editChatInviteLink revokeChatInviteLink setChatPhoto deleteChatPhoto setChatTitle setChatDescription setMyDescription getMyDescription setMyShortDescription getMyShortDescription pinChatMessage unpinChatMessage unpinAllChatMessages leaveChat getChat getChatAdministrators getChatMembersCount getChatMemberCount getChatMember setChatStickerSet deleteChatStickerSet answerCallbackQuery answerWebAppQuery setMyCommands deleteMyCommands getMyCommands setChatMenuButton getChatMenuButton setMyDefaultAdministratorRights getMyDefaultAdministratorRights getCustomEmojiStickers createForumTopic editForumTopic closeForumTopic reopenForumTopic deleteForumTopic unpinAllForumTopicMessages getForumTopicIconStickers editGeneralForumTopic closeGeneralForumTopic reopenGeneralForumTopic hideGeneralForumTopic unhideGeneralForumTopic editMessageText editMessageCaption editMessageMedia editMessageReplyMarkup stopPoll deleteMessage sendSticker getStickerSet uploadStickerFile createNewStickerSet addStickerToSet setStickerPositionInSet deleteStickerFromSet setStickerSetThumbnail answerInlineQuery sendInvoice answerShippingQuery answerPreCheckoutQuery setPassportDataErrors sendGame setGameScore getGameHighScores logOut close )
- DEPRECATED_ACTIONS =
{ kickChatMember: :banChatMember, getChatMembersCount: :getChatMemberCount }
Instance Attribute Summary collapse
-
#api_url ⇒ Object
readonly
Returns the value of attribute api_url.
-
#inline ⇒ Object
Returns the value of attribute inline.
-
#inline_request ⇒ Object
Returns the value of attribute inline_request.
Instance Method Summary collapse
- #__setup_webhook(webhook_url = TelegramWorkflow.config.webhook_url, params = {}) ⇒ Object
- #delete_webhook(params = {}) ⇒ Object
-
#initialize(chat_id = nil) ⇒ Client
constructor
A new instance of Client.
- #set_webhook(params = {}) ⇒ Object
Constructor Details
#initialize(chat_id = nil) ⇒ Client
Returns a new instance of Client.
141 142 143 144 |
# File 'lib/telegram_workflow/client.rb', line 141 def initialize(chat_id = nil) @chat_id = chat_id @api_url = "https://api.telegram.org/bot#{TelegramWorkflow.config.api_token}" end |
Instance Attribute Details
#api_url ⇒ Object (readonly)
Returns the value of attribute api_url.
139 140 141 |
# File 'lib/telegram_workflow/client.rb', line 139 def api_url @api_url end |
#inline ⇒ Object
Returns the value of attribute inline.
138 139 140 |
# File 'lib/telegram_workflow/client.rb', line 138 def inline @inline end |
#inline_request ⇒ Object
Returns the value of attribute inline_request.
138 139 140 |
# File 'lib/telegram_workflow/client.rb', line 138 def inline_request @inline_request end |
Instance Method Details
#__setup_webhook(webhook_url = TelegramWorkflow.config.webhook_url, params = {}) ⇒ Object
156 157 158 159 160 161 162 163 164 165 |
# File 'lib/telegram_workflow/client.rb', line 156 def __setup_webhook(webhook_url = TelegramWorkflow.config.webhook_url, params = {}) TelegramWorkflow.config.logger.info "Checking webhook setup..." webhook_params = { url: webhook_url, allowed_updates: [], **params } if cached_webhook_config != webhook_params TelegramWorkflow.config.logger.info "Setting up a new webhook..." set_webhook(webhook_params) end end |
#delete_webhook(params = {}) ⇒ Object
151 152 153 154 |
# File 'lib/telegram_workflow/client.rb', line 151 def delete_webhook(params = {}) make_request("deleteWebhook", params) cached_webhook_config(params) end |
#set_webhook(params = {}) ⇒ Object
146 147 148 149 |
# File 'lib/telegram_workflow/client.rb', line 146 def set_webhook(params = {}) make_request("setWebhook", params) cached_webhook_config(params) end |