Class: TelegramWorkflow::Client
- Inherits:
-
Object
- Object
- TelegramWorkflow::Client
- Defined in:
- lib/telegram_workflow/client.rb
Constant Summary collapse
- API_VERSION =
"5.3"- 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 setChatPermissions exportChatInviteLink createChatInviteLink editChatInviteLink revokeChatInviteLink setChatPhoto deleteChatPhoto setChatTitle setChatDescription pinChatMessage unpinChatMessage unpinAllChatMessages leaveChat getChat getChatAdministrators getChatMembersCount getChatMemberCount getChatMember setChatStickerSet deleteChatStickerSet answerCallbackQuery setMyCommands deleteMyCommands getMyCommands editMessageText editMessageCaption editMessageMedia editMessageReplyMarkup stopPoll deleteMessage sendSticker getStickerSet uploadStickerFile createNewStickerSet addStickerToSet setStickerPositionInSet deleteStickerFromSet setStickerSetThumb 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.
116 117 118 119 |
# File 'lib/telegram_workflow/client.rb', line 116 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.
114 115 116 |
# File 'lib/telegram_workflow/client.rb', line 114 def api_url @api_url end |
#inline ⇒ Object
Returns the value of attribute inline.
113 114 115 |
# File 'lib/telegram_workflow/client.rb', line 113 def inline @inline end |
#inline_request ⇒ Object
Returns the value of attribute inline_request.
113 114 115 |
# File 'lib/telegram_workflow/client.rb', line 113 def inline_request @inline_request end |
Instance Method Details
#__setup_webhook(webhook_url = TelegramWorkflow.config.webhook_url, params = {}) ⇒ Object
131 132 133 134 135 136 137 138 139 140 |
# File 'lib/telegram_workflow/client.rb', line 131 def __setup_webhook(webhook_url = TelegramWorkflow.config.webhook_url, params = {}) TelegramWorkflow.config.logger.info "[TelegramWorkflow] Checking webhook setup..." webhook_params = { url: webhook_url, allowed_updates: [], **params } if cached_webhook_config != webhook_params TelegramWorkflow.config.logger.info "[TelegramWorkflow] Setting up a new webhook..." set_webhook(webhook_params) end end |
#delete_webhook(params = {}) ⇒ Object
126 127 128 129 |
# File 'lib/telegram_workflow/client.rb', line 126 def delete_webhook(params = {}) make_request("deleteWebhook", params) cached_webhook_config(params) end |
#set_webhook(params = {}) ⇒ Object
121 122 123 124 |
# File 'lib/telegram_workflow/client.rb', line 121 def set_webhook(params = {}) make_request("setWebhook", params) cached_webhook_config(params) end |