Module: ESM

Defined in:
lib/esm/command/base.rb,
lib/esm.rb,
lib/esm/api.rb,
lib/esm/bot.rb,
lib/esm/embed.rb,
lib/esm/command.rb,
lib/esm/message.rb,
lib/esm/version.rb,
lib/esm/database.rb,
lib/esm/exception.rb,
lib/esm/websocket.rb,
lib/esm/model/user.rb,
lib/esm/message/data.rb,
lib/esm/model/server.rb,
lib/esm/error_handler.rb,
lib/esm/message/error.rb,
lib/esm/model/request.rb,
lib/esm/message/player.rb,
lib/esm/message/target.rb,
lib/esm/model/arma/sqf.rb,
lib/esm/model/community.rb,
lib/esm/websocket/queue.rb,
lib/esm/command/argument.rb,
lib/esm/message/metadata.rb,
lib/esm/websocket/server.rb,
lib/esm/command/arguments.rb,
lib/esm/command/server/me.rb,
lib/esm/connection/client.rb,
lib/esm/connection/ledger.rb,
lib/esm/connection/server.rb,
lib/esm/connection/socket.rb,
lib/esm/event/member_join.rb,
lib/esm/websocket/request.rb,
lib/esm/command/my/aliases.rb,
lib/esm/command/server/sqf.rb,
lib/esm/connection/promise.rb,
lib/esm/connection/request.rb,
lib/esm/model/exile/player.rb,
lib/esm/model/notification.rb,
lib/esm/command/base/checks.rb,
lib/esm/command/base/timers.rb,
lib/esm/command/my/requests.rb,
lib/esm/command/server/info.rb,
lib/esm/command/server/logs.rb,
lib/esm/connection/response.rb,
lib/esm/event/server_create.rb,
lib/esm/model/arma/hash_map.rb,
lib/esm/model/server_reward.rb,
lib/esm/model/steam_account.rb,
lib/esm/command/base/helpers.rb,
lib/esm/command/community/id.rb,
lib/esm/command/general/help.rb,
lib/esm/command/my/steam_uid.rb,
lib/esm/command/server/reset.rb,
lib/esm/command/server/stuck.rb,
lib/esm/event/discord_log_v1.rb,
lib/esm/model/user/ephemeral.rb,
lib/esm/bot/delivery_overseer.rb,
lib/esm/command/pictures/birb.rb,
lib/esm/command/pictures/meow.rb,
lib/esm/command/pictures/snek.rb,
lib/esm/command/server/gamble.rb,
lib/esm/command/server/player.rb,
lib/esm/command/server/reward.rb,
lib/esm/command/server/server.rb,
lib/esm/command/server/uptime.rb,
lib/esm/command/territory/add.rb,
lib/esm/command/territory/pay.rb,
lib/esm/connection/encryption.rb,
lib/esm/event/send_to_channel.rb,
lib/esm/model/exile/territory.rb,
lib/esm/command/base/lifecycle.rb,
lib/esm/command/base/migration.rb,
lib/esm/command/community/mode.rb,
lib/esm/command/my/preferences.rb,
lib/esm/command/pictures/doggo.rb,
lib/esm/command/request/accept.rb,
lib/esm/model/request/overseer.rb,
lib/esm/model/xm8_notification.rb,
lib/esm/command/base/definition.rb,
lib/esm/command/community/whois.rb,
lib/esm/command/request/decline.rb,
lib/esm/model/arma/class_lookup.rb,
lib/esm/command/base/permissions.rb,
lib/esm/command/development/eval.rb,
lib/esm/command/general/register.rb,
lib/esm/command/server/broadcast.rb,
lib/esm/command/territory/demote.rb,
lib/esm/command/territory/remove.rb,
lib/esm/command/territory/set_id.rb,
lib/esm/connection/client_socket.rb,
lib/esm/connection/server_socket.rb,
lib/esm/model/application_record.rb,
lib/esm/websocket/server_request.rb,
lib/esm/command/community/servers.rb,
lib/esm/command/territory/promote.rb,
lib/esm/command/territory/restore.rb,
lib/esm/command/territory/upgrade.rb,
lib/esm/event/application_command.rb,
lib/esm/event/xm8_notification_v1.rb,
lib/esm/model/application_command.rb,
lib/esm/command/server/territories.rb,
lib/esm/websocket/request/overseer.rb,
lib/esm/connection/client/lifecycle.rb,
lib/esm/event/send_xm8_notification.rb,
lib/esm/event/server_initialization.rb,
lib/esm/connection/connection_manager.rb,
lib/esm/model/xm8_notification/custom.rb,
lib/esm/websocket/connection/overseer.rb,
lib/esm/event/server_initialization_v1.rb,
lib/esm/command/community/reset_cooldown.rb,
lib/esm/event/discord_message_channel_v1.rb,
lib/esm/model/xm8_notification/base_raid.rb,
lib/esm/model/xm8_notification/flag_stolen.rb,
lib/esm/model/xm8_notification/hack_started.rb,
lib/esm/command/territory/server_territories.rb,
lib/esm/model/xm8_notification/flag_restored.rb,
lib/esm/model/xm8_notification/grind_started.rb,
lib/esm/model/xm8_notification/marxet_item_sold.rb,
lib/esm/model/xm8_notification/flag_steal_started.rb,
lib/esm/model/xm8_notification/charge_plant_started.rb,
lib/esm/model/xm8_notification/protection_money_due.rb,
lib/esm/model/xm8_notification/protection_money_paid.rb,
lib/esm/event/send_xm8_notification/notification_manager.rb

Overview

Overseer watches and checks pending requests to servers for timeouts

Defined Under Namespace

Modules: Arma, Command, Connection, Event, Exception, Exile Classes: API, ApplicationCommand, ApplicationRecord, Bot, Community, Database, Embed, ErrorHandler, Message, Notification, Request, Server, ServerReward, SteamAccount, User, Websocket, Xm8Notification

Constant Summary collapse

REDIS_OPTS =
{
  host: ENV.fetch("REDIS_HOST", "localhost"),
  reconnect_attempts: 10
}.freeze
VERSION =
"2.4.0"

Class Method Summary collapse

Class Method Details

.backtrace_cleanerObject



181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/esm.rb', line 181

def backtrace_cleaner
  @backtrace_cleaner ||= begin
    cleaner = ActiveSupport::BacktraceCleaner.new

    cleaner.add_filter { |line| line.gsub(root.to_s, "") }

    cleaner.add_silencer do |line|
      /\/ruby.gems|\/nix/.match?(line)
    end

    cleaner
  end
end

.botObject



126
127
128
# File 'lib/esm.rb', line 126

def bot
  @bot ||= ESM::Bot.new
end

.cacheObject



155
156
157
# File 'lib/esm.rb', line 155

def cache
  @cache ||= ActiveSupport::Cache::RedisCacheStore.new(namespace: "esm_bot", redis: redis)
end

.configObject



163
164
165
166
167
168
169
170
171
172
# File 'lib/esm.rb', line 163

def config
  @config ||= begin
    config = YAML.safe_load(
      ERB.new(File.read(File.expand_path("config/config.yml"))).result,
      aliases: true
    )[env.to_s]

    config.to_struct
  end
end

.envObject



159
160
161
# File 'lib/esm.rb', line 159

def env
  @env ||= Inquirer.new(:production, :staging, :test, :development).set(ENV["ESM_ENV"].presence || :development)
end

.load!Object

Load everything right meow



140
141
142
143
# File 'lib/esm.rb', line 140

def load!
  loader.setup
  loader.eager_load
end

.loaderObject



174
175
176
177
178
179
# File 'lib/esm.rb', line 174

def loader
  @loader ||= begin
    Zeitwerk::Loader.attr_predicate(:setup, :eager_loaded)
    Zeitwerk::Loader.for_gem(warn_on_extra_files: false)
  end
end

.redisObject



149
150
151
152
153
# File 'lib/esm.rb', line 149

def redis
  @redis ||= ConnectionPool::Wrapper.new do
    Redis.new(**REDIS_OPTS)
  end
end

.rootObject



145
146
147
# File 'lib/esm.rb', line 145

def root
  @root ||= Pathname.new(File.expand_path("."))
end

.run!(async: false) ⇒ Object



130
131
132
133
134
135
136
137
# File 'lib/esm.rb', line 130

def run!(async: false, **)
  info!("Starting Exile Server Manager...")

  require_relative "post_init"
  require_relative "post_init_dev" if ESM.env.development?

  bot.run(async:, **)
end