Class: Legion::Extensions::MicrosoftTeams::Actor::ChannelPoller
- Inherits:
-
Actors::Every
- Object
- Actors::Every
- Legion::Extensions::MicrosoftTeams::Actor::ChannelPoller
show all
- Includes:
- Helpers::Client
- Defined in:
- lib/legion/extensions/microsoft_teams/actors/channel_poller.rb
Constant Summary
collapse
- DEFAULT_INTERVAL =
60
- DEFAULT_MAX_TEAMS =
10
- DEFAULT_MAX_CHANNELS =
5
Instance Method Summary
collapse
#bot_connection, #graph_connection, #oauth_connection, #user_path
Constructor Details
Returns a new instance of ChannelPoller.
14
15
16
17
18
19
|
# File 'lib/legion/extensions/microsoft_teams/actors/channel_poller.rb', line 14
def initialize(**opts)
return unless enabled?
@channel_hwm = {}
super
end
|
Instance Method Details
#check_subtask? ⇒ Boolean
27
|
# File 'lib/legion/extensions/microsoft_teams/actors/channel_poller.rb', line 27
def check_subtask? = false
|
#delay ⇒ Object
24
|
# File 'lib/legion/extensions/microsoft_teams/actors/channel_poller.rb', line 24
def delay = 300
|
#enabled? ⇒ Boolean
38
39
40
41
42
43
44
45
|
# File 'lib/legion/extensions/microsoft_teams/actors/channel_poller.rb', line 38
def enabled?
return false unless defined?(Legion::Extensions::MicrosoftTeams::Helpers::TokenCache)
channel_setting(:enabled, false) == true
rescue StandardError => e
log.debug("ChannelPoller#enabled?: #{e.message}")
false
end
|
#generate_task? ⇒ Boolean
28
|
# File 'lib/legion/extensions/microsoft_teams/actors/channel_poller.rb', line 28
def generate_task? = false
|
#manual ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/legion/extensions/microsoft_teams/actors/channel_poller.rb', line 51
def manual
log.info('ChannelPoller polling team channels')
token = token_cache.cached_delegated_token
unless token
log.debug('No token available, skipping poll')
return
end
teams = fetch_joined_teams(token: token)
log.debug("Found #{teams.length} joined team(s)")
teams.first(max_teams).each do |team|
poll_team(team: team, token: token)
rescue StandardError => e
log.error("Error polling team #{team['displayName']}: #{e.message}")
end
rescue StandardError => e
log.error("ChannelPoller: #{e.message}")
end
|
#memory_available? ⇒ Boolean
30
31
32
|
# File 'lib/legion/extensions/microsoft_teams/actors/channel_poller.rb', line 30
def memory_available?
defined?(Legion::Extensions::Agentic::Memory::Trace::Runners::Traces)
end
|
#memory_runner ⇒ Object
34
35
36
|
# File 'lib/legion/extensions/microsoft_teams/actors/channel_poller.rb', line 34
def memory_runner
@memory_runner ||= Object.new.extend(Legion::Extensions::Agentic::Memory::Trace::Runners::Traces)
end
|
#run_now? ⇒ Boolean
25
|
# File 'lib/legion/extensions/microsoft_teams/actors/channel_poller.rb', line 25
def run_now? = false
|
#runner_class ⇒ Object
21
|
# File 'lib/legion/extensions/microsoft_teams/actors/channel_poller.rb', line 21
def runner_class = self.class
|
#runner_function ⇒ Object
22
|
# File 'lib/legion/extensions/microsoft_teams/actors/channel_poller.rb', line 22
def runner_function = 'manual'
|
#time ⇒ Object
23
|
# File 'lib/legion/extensions/microsoft_teams/actors/channel_poller.rb', line 23
def time = channel_setting(:poll_interval, DEFAULT_INTERVAL)
|
#use_runner? ⇒ Boolean
26
|
# File 'lib/legion/extensions/microsoft_teams/actors/channel_poller.rb', line 26
def use_runner? = false
|