Module: ChatgptAssistant::Bots::Telegram::Permissions

Included in:
TelegramBot
Defined in:
lib/chatgpt_assistant/bots/telegram/permissions.rb

Instance Method Summary collapse

Instance Method Details

#audio_allowed?Boolean

Returns:

  • (Boolean)

Raises:



40
41
42
43
44
# File 'lib/chatgpt_assistant/bots/telegram/permissions.rb', line 40

def audio_allowed?
  raise UserNotLoggedInError if user.nil?
  raise AccountNotVerifiedError unless user.active?
  raise NoChatSelectedError if user.current_chat.nil?
end

#common_allowed?Boolean

Returns:

  • (Boolean)

Raises:



30
31
32
33
# File 'lib/chatgpt_assistant/bots/telegram/permissions.rb', line 30

def common_allowed?
  raise UserNotLoggedInError if user.nil?
  raise AccountNotVerifiedError unless user.active?
end

#hist_allowed?Boolean

Returns:

  • (Boolean)

Raises:



7
8
9
10
11
12
# File 'lib/chatgpt_assistant/bots/telegram/permissions.rb', line 7

def hist_allowed?
  raise UserNotLoggedInError if user.nil?
  raise AccountNotVerifiedError unless user.active?
  raise NoChatSelectedError if user.current_chat.nil?
  raise NoMessagesFoundedError if user.current_chat.messages.count.zero?
end

#list_allowed?Boolean

Returns:

  • (Boolean)

Raises:



14
15
16
17
18
# File 'lib/chatgpt_assistant/bots/telegram/permissions.rb', line 14

def list_allowed?
  raise UserNotLoggedInError if user.nil?
  raise AccountNotVerifiedError unless user.active?
  raise NoChatsFoundedError if user.chats.count.zero?
end

#register_allowed?(user_info) ⇒ Boolean

Returns:

  • (Boolean)

Raises:



20
21
22
23
24
25
26
27
28
# File 'lib/chatgpt_assistant/bots/telegram/permissions.rb', line 20

def register_allowed?()
  raise NoRegisterInfoError if .nil?
  raise UserLoggedInError if user

  email, password = .split(":")
  raise NoRegisterEmailError if email.nil? || password.nil?

  [email, password]
end

#select_allowed?(chat) ⇒ Boolean

Returns:

  • (Boolean)

Raises:



35
36
37
38
# File 'lib/chatgpt_assistant/bots/telegram/permissions.rb', line 35

def select_allowed?(chat)
  raise ChatNotFoundError if chat.nil?
  raise ChatNotFoundError unless user.update(current_chat_id: chat.id)
end