Class: TelegramOnSteroids::Client
- Inherits:
-
Object
- Object
- TelegramOnSteroids::Client
- Defined in:
- lib/telegram_on_steroids/client.rb
Constant Summary collapse
- API_VERSION =
"5.5"
- AVAILABLE_ACTIONS =
WebhookConfigPath = Pathname.new(“tmp/telegram_workflow/webhook_config.txt”)
%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 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 = TelegramOnSteroids.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.
114 115 116 117 |
# File 'lib/telegram_on_steroids/client.rb', line 114 def initialize(chat_id = nil) @chat_id = chat_id @api_url = "https://api.telegram.org/bot#{TelegramOnSteroids.config.api_token}" end |
Instance Attribute Details
#api_url ⇒ Object (readonly)
Returns the value of attribute api_url.
112 113 114 |
# File 'lib/telegram_on_steroids/client.rb', line 112 def api_url @api_url end |
#inline ⇒ Object
Returns the value of attribute inline.
111 112 113 |
# File 'lib/telegram_on_steroids/client.rb', line 111 def inline @inline end |
#inline_request ⇒ Object
Returns the value of attribute inline_request.
111 112 113 |
# File 'lib/telegram_on_steroids/client.rb', line 111 def inline_request @inline_request end |
Instance Method Details
#__setup_webhook(webhook_url = TelegramOnSteroids.config.webhook_url, params = {}) ⇒ Object
129 130 131 132 133 134 135 136 137 138 |
# File 'lib/telegram_on_steroids/client.rb', line 129 def __setup_webhook(webhook_url = TelegramOnSteroids.config.webhook_url, params = {}) TelegramOnSteroids.config.logger.info "[TelegramWorkflow] Checking webhook setup..." webhook_params = { url: webhook_url, allowed_updates: [], **params } if cached_webhook_config != webhook_params TelegramOnSteroids.config.logger.info "[TelegramWorkflow] Setting up a new webhook..." set_webhook(webhook_params) end end |
#delete_webhook(params = {}) ⇒ Object
124 125 126 127 |
# File 'lib/telegram_on_steroids/client.rb', line 124 def delete_webhook(params = {}) make_request("deleteWebhook", params) cached_webhook_config(params) end |
#set_webhook(params = {}) ⇒ Object
119 120 121 122 |
# File 'lib/telegram_on_steroids/client.rb', line 119 def set_webhook(params = {}) make_request("setWebhook", params) cached_webhook_config(params) end |