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
collapse
- POLL_INTERVAL =
15
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.
13
14
15
16
17
18
|
# File 'lib/legion/extensions/microsoft_teams/actors/direct_chat_poller.rb', line 13
def initialize(**opts)
return unless enabled?
@bot_id = bot_id_from_settings
super
end
|
Instance Method Details
#check_subtask? ⇒ Boolean
26
|
# File 'lib/legion/extensions/microsoft_teams/actors/direct_chat_poller.rb', line 26
def check_subtask? = false
|
#delay ⇒ Object
23
|
# File 'lib/legion/extensions/microsoft_teams/actors/direct_chat_poller.rb', line 23
def delay = 60
|
#enabled? ⇒ Boolean
29
30
31
32
33
34
35
|
# File 'lib/legion/extensions/microsoft_teams/actors/direct_chat_poller.rb', line 29
def enabled?
defined?(Legion::Extensions::MicrosoftTeams::Runners::Bot) &&
Legion.const_defined?(:Transport, false)
rescue StandardError => e
log.debug("DirectChatPoller#enabled?: #{e.message}")
false
end
|
#generate_task? ⇒ Boolean
27
|
# File 'lib/legion/extensions/microsoft_teams/actors/direct_chat_poller.rb', line 27
def generate_task? = false
|
#manual ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/legion/extensions/microsoft_teams/actors/direct_chat_poller.rb', line 41
def manual
token = token_cache.cached_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("Found #{chats.length} bot chats")
chats.each { |chat| poll_chat(chat_id: chat[:id], token: token) }
rescue StandardError => e
log.error("DirectChatPoller: #{e.message}")
end
|
#run_now? ⇒ Boolean
24
|
# File 'lib/legion/extensions/microsoft_teams/actors/direct_chat_poller.rb', line 24
def run_now? = false
|
#runner_function ⇒ Object
21
|
# File 'lib/legion/extensions/microsoft_teams/actors/direct_chat_poller.rb', line 21
def runner_function = 'handle_message'
|
#time ⇒ Object
22
|
# File 'lib/legion/extensions/microsoft_teams/actors/direct_chat_poller.rb', line 22
def time = settings_interval(:direct_poll_interval, POLL_INTERVAL)
|
#use_runner? ⇒ Boolean
25
|
# File 'lib/legion/extensions/microsoft_teams/actors/direct_chat_poller.rb', line 25
def use_runner? = false
|