Class: Legion::Extensions::MicrosoftTeams::Actor::ChannelPoller

Inherits:
Actors::Every
  • Object
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

Methods included from Helpers::Client

#bot_connection, #graph_connection, #oauth_connection, #user_path

Constructor Details

#initialize(**opts) ⇒ ChannelPoller

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

Returns:

  • (Boolean)


27
# File 'lib/legion/extensions/microsoft_teams/actors/channel_poller.rb', line 27

def check_subtask?  = false

#delayObject



24
# File 'lib/legion/extensions/microsoft_teams/actors/channel_poller.rb', line 24

def delay           = 300

#enabled?Boolean

Returns:

  • (Boolean)


38
39
40
41
42
43
# File 'lib/legion/extensions/microsoft_teams/actors/channel_poller.rb', line 38

def enabled?
  channel_setting(:enabled, false) == true
rescue StandardError => e
  handle_exception(e, level: :debug, operation: 'ChannelPoller#enabled?')
  false
end

#generate_task?Boolean

Returns:

  • (Boolean)


28
# File 'lib/legion/extensions/microsoft_teams/actors/channel_poller.rb', line 28

def generate_task?  = false

#manualObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/legion/extensions/microsoft_teams/actors/channel_poller.rb', line 45

def manual
  log.info('ChannelPoller polling team channels')
  token = delegated_token
  unless token
    log.debug('No token available, skipping poll')
    return
  end

  teams = fetch_joined_teams(token: token)
  log.debug("ChannelPoller#manual found #{teams.length} joined team(s)")

  teams.first(max_teams).each do |team|
    poll_team(team: team, token: token)
  rescue StandardError => e
    handle_exception(e, level: :error, operation: 'ChannelPoller#manual',
                     team: team['displayName'])
  end
rescue StandardError => e
  handle_exception(e, level: :error, operation: 'ChannelPoller#manual')
end

#memory_available?Boolean

Returns:

  • (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_runnerObject



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

Returns:

  • (Boolean)


25
# File 'lib/legion/extensions/microsoft_teams/actors/channel_poller.rb', line 25

def run_now?        = false

#runner_classObject



21
# File 'lib/legion/extensions/microsoft_teams/actors/channel_poller.rb', line 21

def runner_class    = self.class

#runner_functionObject



22
# File 'lib/legion/extensions/microsoft_teams/actors/channel_poller.rb', line 22

def runner_function = 'manual'

#timeObject



23
# File 'lib/legion/extensions/microsoft_teams/actors/channel_poller.rb', line 23

def time            = channel_setting(:poll_interval, DEFAULT_INTERVAL)

#use_runner?Boolean

Returns:

  • (Boolean)


26
# File 'lib/legion/extensions/microsoft_teams/actors/channel_poller.rb', line 26

def use_runner?     = false