зеркало из
https://github.com/glebtv/telegram-bot.git
synced 2026-09-04 02:05:52 +03:00
Fixed controller crashes on unsupported update types
Этот коммит содержится в:
@@ -17,11 +17,15 @@ module Telegram
|
||||
protected
|
||||
|
||||
def session
|
||||
@_session ||= SessionHash.new(self.class.session_store, session_key)
|
||||
@_session ||= begin
|
||||
key = session_key
|
||||
key ? SessionHash.new(self.class.session_store, key) : NullSessionHash.new
|
||||
end
|
||||
end
|
||||
|
||||
def session_key
|
||||
"#{bot.username}:#{from ? "from:#{from['id']}" : "chat:#{chat['id']}"}"
|
||||
subject = from || chat
|
||||
"#{bot.username}:#{subject['id']}" if subject
|
||||
end
|
||||
|
||||
# Rack::Session::Abstract::SessionHash is taken to provide lazy loading.
|
||||
@@ -59,6 +63,18 @@ module Telegram
|
||||
end
|
||||
end
|
||||
|
||||
class NullSessionHash < Session::SessionHash
|
||||
def initialize
|
||||
@data = {}
|
||||
@loaded = true
|
||||
@exists = true
|
||||
end
|
||||
|
||||
alias_method :destroy, :clear
|
||||
alias_method :load!, :id
|
||||
alias_method :commit, :id
|
||||
end
|
||||
|
||||
module ConfigMethods
|
||||
delegate :session_store, to: :config
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user