예제 #1
0
 public LinkSteamCommand(IConstants constants, IBarebonesSteamOpenId openId, IUrlShortenerService urlShortenerService, EfDatabaseContextFactory databaseContextFactory)
 {
     _constants              = constants;
     _openId                 = openId;
     _urlShortenerService    = urlShortenerService;
     _databaseContextFactory = databaseContextFactory;
 }
예제 #2
0
 public LinkSteamCommand(IConstants constants, IBarebonesSteamOpenId openId,
                         EfDatabaseContextFactory databaseContextFactory)
 {
     _constants = constants;
     _openId    = openId;
     _databaseContextFactory = databaseContextFactory;
 }
예제 #3
0
        public ArkDiscordBot(
            DiscordSocketClient discord,
            CommandService commands,
            IServiceProvider serviceProvider,
            IConfig config,
            IConstants constants,
            IBarebonesSteamOpenId openId,
            EfDatabaseContextFactory databaseContextFactory,
            ILifetimeScope scope,
            ArkContextManager contextManager,
            VotingManager votingManager)
        {
            _discord                     = discord;
            _commands                    = commands;
            _serviceProvider             = serviceProvider;
            _config                      = config;
            _constants                   = constants;
            _databaseContextFactory      = databaseContextFactory;
            _openId                      = openId;
            _openId.SteamOpenIdCallback += _openId_SteamOpenIdCallback;
            _scope          = scope;
            _contextManager = contextManager;
            _votingManager  = votingManager;

            //_context.Updated += _context_Updated;

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

            var args = Environment.GetCommandLineArgs();

            if (args != null && args.Contains("/restart", StringComparer.OrdinalIgnoreCase))
            {
                _wasRestarted = true;
            }
        }
예제 #4
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;
            }
        }