module RBotKit
Constants
- CommandCase
- Request
- RequestCallback
- VERSION
Public Class Methods
bot_key()
click to toggle source
# File lib/RBotKit.rb, line 16 def self.bot_key @@bot_key end
get_file_link(fileid)
click to toggle source
# File lib/RBotKit.rb, line 53 def self.get_file_link(fileid) responce = RestClient.get "https://api.telegram.org/#{RBotKit.bot_key}/getFile?file_id=#{fileid}" jresp = JSON.parse(responce.body) filepath = nil p jresp["result"] != nil if jresp["result"] != nil filepath = jresp["result"]["file_path"] return "https://api.telegram.org/file/#{RBotKit.bot_key}/#{filepath}" else p jresp return nil end end
new_case(state, cmdtext, cmdclass)
click to toggle source
# File lib/RBotKit.rb, line 69 def self.new_case(state, cmdtext, cmdclass) CommandCase.new(state, cmdtext, cmdclass) end
set_bot_key(bk)
click to toggle source
# File lib/RBotKit.rb, line 12 def self.set_bot_key(bk) @@bot_key = bk end
tel_parse_data(data)
click to toggle source
# File lib/RBotKit.rb, line 23 def self.tel_parse_data(data) id = data[:update_id] mes = data[:message] if mes != nil usr = mes[:from] chat_id = mes[:chat][:id].to_s user_id = usr[:id] username = usr[:first_name] text = mes[:text] != nil ? mes[:text].strip : nil photo = mes[:photo] fileid = nil if photo != nil photosize = photo.last fileid = photosize[:file_id] end req = Request.new(id, chat_id, user_id, text, username, fileid) else cb = data[:callback_query] if cb != nil mes = cb[:message] chat_id = mes[:chat][:id].to_s if mes != nil usr = cb[:from] user_id = usr[:id] username = usr[:first_name] text = cb[:data] req = RequestCallback.new(id, chat_id, user_id, text, username, nil) end end end