示例#1
0
        public ArkDiscordBot(
            DiscordSocketClient discord,
            CommandService commands,
            IServiceProvider serviceProvider,
            IConfig config,
            IConstants constants,
            EfDatabaseContextFactory databaseContextFactory,
            ILifetimeScope scope,
            ArkContextManager contextManager)
        {
            _discord                = discord;
            _commands               = commands;
            _serviceProvider        = serviceProvider;
            _config                 = config;
            _constants              = constants;
            _databaseContextFactory = databaseContextFactory;
            _scope          = scope;
            _contextManager = contextManager;

            _discord.GuildAvailable  += DiscordOnGuildAvailable;
            _discord.MessageReceived += HandleCommandAsync;

            var args = Environment.GetCommandLineArgs();

            if (args != null && args.Contains("/restart", StringComparer.OrdinalIgnoreCase))
            {
                _wasRestarted = true;
            }
        }
示例#2
0
 public LinkSteamCommand(IConstants constants, IBarebonesSteamOpenId openId,
                         EfDatabaseContextFactory databaseContextFactory)
 {
     _constants = constants;
     _openId    = openId;
     _databaseContextFactory = databaseContextFactory;
 }
示例#3
0
 public PlayerListCommand(EfDatabaseContextFactory databaseContextFactory, IArkContext context, IConfig config, ArkContextManager contextManager)
 {
     _databaseContextFactory = databaseContextFactory;
     _context        = context;
     _config         = config;
     _contextManager = contextManager;
 }
示例#4
0
 public LinkSteamCommand(IConstants constants, IBarebonesSteamOpenId openId, IUrlShortenerService urlShortenerService, EfDatabaseContextFactory databaseContextFactory)
 {
     _constants              = constants;
     _openId                 = openId;
     _urlShortenerService    = urlShortenerService;
     _databaseContextFactory = databaseContextFactory;
 }
示例#5
0
 public VoteCommand(IArkContext context, IConfig config, EfDatabaseContextFactory databaseContextFactory, ISavedState savedstate, ArkContextManager contextManager)
 {
     _context = context;
     _config  = config;
     _databaseContextFactory = databaseContextFactory;
     _savedstate             = savedstate;
     _contextManager         = contextManager;
 }
示例#6
0
 public CheckFoodCommand(
     IConfig config,
     IArkContext context,
     IConstants constants,
     EfDatabaseContextFactory databaseContextFactory,
     ArkContextManager contextManager)
 {
     _config    = config;
     _context   = context;
     _constants = constants;
     _databaseContextFactory = databaseContextFactory;
     _contextManager         = contextManager;
 }
示例#7
0
 public ArkBotLinkHub(
     ArkContextManager contextManager,
     NotificationManager notificationManager,
     EfDatabaseContextFactory databaseContextFactory,
     IDatabaseRepo databaseRepo,
     IConfig config)
 {
     _contextManager         = contextManager;
     _notificationManager    = notificationManager;
     _databaseContextFactory = databaseContextFactory;
     _databaseRepo           = databaseRepo;
     _config = config;
 }
示例#8
0
 public RconCommand(
     ILifetimeScope scope,
     IConfig config,
     IConstants constants,
     EfDatabaseContextFactory databaseContextFactory,
     ISavedState savedstate,
     IArkServerService arkServerService,
     ISavegameBackupService savegameBackupService,
     ArkContextManager contextManager,
     ScheduledTasksManager scheduledTasksManager)
 {
     _config         = config;
     _contextManager = contextManager;
 }
示例#9
0
 public ServersController(
     IConfig config,
     EfDatabaseContextFactory databaseContextFactory,
     ArkContextManager contextManager,
     Discord.DiscordManager discordManager,
     IArkServerService serverService,
     ArkBotAnonymizeData anonymizeData) : base(config)
 {
     _databaseContextFactory = databaseContextFactory;
     _contextManager         = contextManager;
     _discordManager         = discordManager;
     _serverService          = serverService;
     _anonymizeData          = anonymizeData;
 }
示例#10
0
 public AdminCommand(
     ILifetimeScope scope,
     IArkContext context,
     IConfig config,
     IConstants constants,
     EfDatabaseContextFactory databaseContextFactory,
     ISavedState savedstate,
     IArkServerService arkServerService,
     ISavegameBackupService savegameBackupService,
     ArkContextManager contextManager,
     ScheduledTasksManager scheduledTasksManager)
 {
     _context   = context;
     _config    = config;
     _constants = constants;
     _databaseContextFactory = databaseContextFactory;
     _savedstate             = savedstate;
     _arkServerService       = arkServerService;
     _savegameBackupService  = savegameBackupService;
     _contextManager         = contextManager;
     _scheduledTasksManager  = scheduledTasksManager;
 }
示例#11
0
        public VotingManager(
            ArkContextManager contextManager,
            DiscordManager discordManager,
            ScheduledTasksManager scheduledTasksManager,
            EfDatabaseContextFactory databaseContextFactory,
            IConfig config,
            IConstants constants,
            ILifetimeScope scope,
            IProgress <string> progress)
        {
            _contextManager         = contextManager;
            _discordManager         = discordManager;
            _scheduledTasksManager  = scheduledTasksManager;
            _databaseContextFactory = databaseContextFactory;
            _config    = config;
            _constants = constants;
            _scope     = scope;
            _progress  = progress;

            _contextManager.VoteInitiated           += _contextManager_VoteInitiated;
            _contextManager.VoteResultForced        += _contextManager_VoteResultForced;
            _contextManager.InitializationCompleted += _contextManager_InitializationCompleted;
        }
示例#12
0
        public ArkDiscordBot(
            DiscordClient discord,
            IConfig config,
            IArkContext context,
            IConstants constants,
            IBarebonesSteamOpenId openId,
            EfDatabaseContextFactory databaseContextFactory,
            IEnumerable <ICommand> commands,
            ILifetimeScope scope,
            ArkContextManager contextManager,
            VotingManager votingManager)
        {
            _discord   = discord;
            _config    = config;
            _context   = context;
            _constants = constants;
            _databaseContextFactory = databaseContextFactory;
            _openId = openId;
            _openId.SteamOpenIdCallback += _openId_SteamOpenIdCallback;
            _scope          = scope;
            _contextManager = contextManager;
            _votingManager  = votingManager;

            _context.Updated += _context_Updated;

            _discord.UsingCommands(x =>
            {
                x.PrefixChar         = '!';
                x.AllowMentionPrefix = true;
            });

            _discord.ServerAvailable += _discord_ServerAvailable;

            var cservice = _discord.GetService <CommandService>();

            cservice.CommandExecuted += Commands_CommandExecuted;
            cservice.CommandErrored  += Commands_CommandErrored;
            foreach (var command in commands)
            {
                //if (command.DebugOnly && !_config.Debug) continue;

                var cbuilder = cservice.CreateCommand(command.Name);
                if (command.Aliases != null && command.Aliases.Length > 0)
                {
                    cbuilder.Alias(command.Aliases);
                }
                var rrc = command as IRoleRestrictedCommand;
                if (rrc != null && rrc.ForRoles?.Length > 0)
                {
                    cbuilder.AddCheck((a, b, c) =>
                                      c.Client.Servers.Any(x =>
                                                           x.Roles.Any(y => y != null && rrc.ForRoles.Contains(y.Name, StringComparer.OrdinalIgnoreCase) == true && y.Members.Any(z => z.Id == b.Id))), null);
                }

                cbuilder.AddCheck((a, b, c) =>
                {
                    return(c.IsPrivate || !(_config.EnabledChannels?.Length > 0) || (c?.Name != null && _config.EnabledChannels.Contains(c.Name, StringComparer.OrdinalIgnoreCase)));
                });

                command.Init(_discord);
                command.Register(cbuilder);
                cbuilder.Do(command.Run);
            }



            var args = Environment.GetCommandLineArgs();

            if (args != null && args.Contains("/restart", StringComparer.OrdinalIgnoreCase))
            {
                _wasRestarted = true;
            }
        }
示例#13
0
 public MyKibblesCommand(IArkContext context, IConstants constants, EfDatabaseContextFactory databaseContextFactory)
 {
     _context   = context;
     _constants = constants;
     _databaseContextFactory = databaseContextFactory;
 }
示例#14
0
 public WhoAmICommand(IConstants constants, EfDatabaseContextFactory databaseContextFactory)
 {
     _constants = constants;
     _databaseContextFactory = databaseContextFactory;
 }
示例#15
0
 public ServersController(IConfig config, EfDatabaseContextFactory databaseContextFactory, ArkContextManager contextManager)
 {
     _config = config;
     _databaseContextFactory = databaseContextFactory;
     _contextManager         = contextManager;
 }
示例#16
0
 public UnlinkSteamCommand(IConstants constants, IConfig config, EfDatabaseContextFactory databaseContextFactory)
 {
     _config = config;
     _databaseContextFactory = databaseContextFactory;
 }
示例#17
0
        //todo: this method does not really belong here and should be moved elsewhere
        public static async Task <ArkSavegameToolkitNet.Domain.ArkPlayer> GetCurrentPlayerOrSendErrorMessage(CommandEventArgs e, EfDatabaseContextFactory databaseContextFactory, ArkServerContext serverContext)
        {
            using (var db = databaseContextFactory.Create())
            {
                var user = db.Users.FirstOrDefault(x => x.DiscordId == (long)e.User.Id && !x.Unlinked);
                if (user == null)
                {
                    await e.Channel.SendMessage($"<@{e.User.Id}>, this command can only be used after you link your Discord user with your Steam account using **!linksteam**.");

                    return(null);
                }

                var player = serverContext.Players.FirstOrDefault(x => x.SteamId != null && x.SteamId.Equals(user.SteamId.ToString()));
                if (player == null)
                {
                    await e.Channel.SendMessage($"<@{e.User.Id}>, we have no record of you playing in the last month.");

                    return(null);
                }

                return(player);
            }
        }
示例#18
0
 public MyDinoHistoryCommand(IArkContext context, EfDatabaseContextFactory databaseContextFactory)
 {
     _context = context;
     _databaseContextFactory = databaseContextFactory;
 }
示例#19
0
 public DatabaseRepo(EfDatabaseContextFactory databaseContextFactory)
 {
     _databaseContextFactory = databaseContextFactory;
 }