Class: Legion::Extensions::MicrosoftTeams::Actor::DirectChatPoller
- Inherits:
-
Actors::Every
- Object
- Actors::Every
- Legion::Extensions::MicrosoftTeams::Actor::DirectChatPoller
show all
- Includes:
- Helpers::Client, Helpers::HighWaterMark
- Defined in:
- lib/legion/extensions/microsoft_teams/actors/direct_chat_poller.rb
Constant Summary
Helpers::HighWaterMark::HWM_TTL
Instance Method Summary
collapse
#get_extended_hwm, #get_hwm, #hwm_key, #memory_runner, #new_messages, #persist_hwm_as_trace, #restore_hwm_from_traces, #set_extended_hwm, #set_hwm, #update_extended_hwm, #update_hwm_from_messages
#bot_connection, #graph_connection, #oauth_connection, #user_path
Constructor Details
Returns a new instance of DirectChatPoller.
11
12
13
14
15
16
|
# File 'lib/legion/extensions/microsoft_teams/actors/direct_chat_poller.rb', line 11
def initialize(**opts)
return unless enabled?
@bot_id = bot_id_from_settings
super
end
|
Instance Method Details
#check_subtask? ⇒ Boolean
24
|
# File 'lib/legion/extensions/microsoft_teams/actors/direct_chat_poller.rb', line 24
def check_subtask? = false
|
#delay ⇒ Object
21
|
# File 'lib/legion/extensions/microsoft_teams/actors/direct_chat_poller.rb', line 21
def delay = 60
|
#enabled? ⇒ Boolean
27
28
29
30
31
32
33
34
|
# File 'lib/legion/extensions/microsoft_teams/actors/direct_chat_poller.rb', line 27
def enabled?
settings.dig(:direct_chat_poller, :enabled) &&
defined?(Legion::Extensions::MicrosoftTeams::Runners::Bot) &&
Legion.const_defined?(:Transport, false)
rescue StandardError => e
handle_exception(e, level: :debug, operation: 'DirectChatPoller#enabled?')
false
end
|
#generate_task? ⇒ Boolean
25
|
# File 'lib/legion/extensions/microsoft_teams/actors/direct_chat_poller.rb', line 25
def generate_task? = false
|
#manual ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/legion/extensions/microsoft_teams/actors/direct_chat_poller.rb', line 36
def manual
log.debug('DirectChatPoller#manual starting')
token = delegated_token
unless token
log.debug('No token available, skipping poll')
return
end
log.info('Polling bot DM chats')
chats = fetch_bot_chats(token: token)
log.info("DirectChatPoller found #{chats.length} bot chats")
chats.each { |chat| poll_chat(chat_id: chat[:id], token: token) }
rescue StandardError => e
handle_exception(e, level: :error, operation: 'DirectChatPoller#manual')
end
|
#run_now? ⇒ Boolean
22
|
# File 'lib/legion/extensions/microsoft_teams/actors/direct_chat_poller.rb', line 22
def run_now? = false
|
#runner_function ⇒ Object
19
|
# File 'lib/legion/extensions/microsoft_teams/actors/direct_chat_poller.rb', line 19
def runner_function = 'handle_message'
|
#time ⇒ Object
20
|
# File 'lib/legion/extensions/microsoft_teams/actors/direct_chat_poller.rb', line 20
def time = settings.dig(:direct_chat_poller, :interval)
|
#use_runner? ⇒ Boolean
23
|
# File 'lib/legion/extensions/microsoft_teams/actors/direct_chat_poller.rb', line 23
def use_runner? = false
|