private string _userId      = "user"; // dummy username for google stuff

        public GoogleCalendarSyncService(
            IConfigurationRoot config,
            InteractiveService interactiveService,
            ScheduleService scheduleService,
            DatabaseServers datbaseServers)
        {
            _config = config;

            _interactiveService = interactiveService;
            _scheduleService    = scheduleService;
            _databaseServers    = datbaseServers;
        }
Ejemplo n.º 2
0
        public TimeSpan _timerInterval = TimeSpan.FromMinutes(5); // how often the timer will run, in minutes

        public RaidEventsService(
            DiscordSocketClient discord,
            GoogleCalendarSyncService googleCalendarSyncService,
            ScheduleService scheduleService,
            DatabaseServers databaseServers)
        {
            _discord = discord;

            _googleCalendarSyncService = googleCalendarSyncService;
            _scheduleService           = scheduleService;
            _databaseServers           = databaseServers;
        }
Ejemplo n.º 3
0
        public async Task ToggleRemindersAsync()
        {
            var server = DbDiscordServers.ServerList.Find(x => x.DiscordServerObject == Context.Guild);

            if (server.RemindersEnabled)
            {
                server.RemindersEnabled = false;
            }
            else if (server.RemindersEnabled == false)
            {
                server.RemindersEnabled = true;
            }

            await ReplyAsync($"Toggled reminders to: {server.RemindersEnabled}.");

            await DatabaseServers.EditServerInfo(server.ServerId, "reminders_enabled", server.RemindersEnabled);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets the database manager to execute T-SQL statements against it
        /// </summary>
        /// <returns></returns>
        protected void SetContainer(DatabaseServers dBServer = DatabaseServers.DB_DEMO)
        {
            var configurationName = this.Configuration["ENVIRONMENT"];

            var keyName           = $"{configurationName}:{dBServer.ToString()}";
            var connection        = this.Configuration[keyName];
            var commandTimeout    = this.Configuration["FRAMEWORK.COMMAND.TIMEOUT"].ToInt();
            var connectionTimeout = this.Configuration["FRAMEWORK.CONNECTION.TIMEOUT"].ToInt();
            var traceEnabled      = this.Configuration["FRAMEWORK.TRACE.ENABLED"].ToBool();
            var traceFilePath     = this.Configuration["FRAMEWORK.TRACE.PATH"];

            if (!traceEnabled)
            {
                traceFilePath = string.Empty;
            }

            connection = Cryptography.DecryptUsingTripleDES(connection);

            var databaseContext    = new SQLDatabaseContext(connection, commandTimeout, connectionTimeout);
            var databaseRepository = new SQLDatabaseRepository(false, traceFilePath);

            container = new ContainerDI(databaseContext, databaseRepository);
        }
Ejemplo n.º 5
0
        public async Task ConfigureServerAsync()
        {
            ulong configChannelId;
            ulong reminderChannelId;

            // config channel
            await ReplyAndDeleteAsync($"Tag the channel you want **configuration** messages sent to (for example, {MentionUtils.MentionChannel(Context.Channel.Id)}).", false, null, TimeSpan.FromMinutes(1));

            var response = await NextMessageAsync(true, true, TimeSpan.FromSeconds(30));

            if (response != null)
            {
                if (response.MentionedChannels.FirstOrDefault() != null)
                {
                    configChannelId = MentionUtils.ParseChannel(response.Content);
                }
                else
                {
                    await ReplyAsync("You didn't correctly tag a channel. Follow the instructions, dingus.");

                    return;
                }
            }
            else
            {
                await ReplyAsync("I didn't get a response in time. Try again.");

                return;
            }


            // reminder channel
            await ReplyAndDeleteAsync($"Tag the channel you want **reminders & the schedule** sent to (for example, {MentionUtils.MentionChannel(Context.Channel.Id)}).", false, null, TimeSpan.FromMinutes(1));

            response = await NextMessageAsync(true, true, TimeSpan.FromSeconds(30));

            if (response != null)
            {
                if (response.MentionedChannels.FirstOrDefault() != null)
                {
                    reminderChannelId = MentionUtils.ParseChannel(response.Content);
                }
                else
                {
                    await ReplyAsync("You didn't correctly tag a channel. Follow the instructions, dingus.");

                    return;
                }
            }
            else
            {
                await ReplyAsync("I didn't get a response in time. Try again.");

                return;
            }

            // build our new server object
            var newServer = new DbDiscordServer()
            {
                ConfigChannelId   = configChannelId.ToString(),
                ReminderChannelId = reminderChannelId.ToString(),
                ServerId          = Context.Guild.Id.ToString(),
                ServerName        = Context.Guild.Name,
                RemindersEnabled  = true
            };

            // add this server's data to the database
            await DatabaseServers.AddServerInfo(newServer);

            // initialize this server
            RaidEventsService.SetServerDiscordObjects(newServer);

            // update the ServerList with the new server
            DbDiscordServers.ServerList.Add(newServer);

            // set up google api authentication
            await AuthAsync();
        }
Ejemplo n.º 6
0
 private string GetDataStoreForDatabaseServer(DatabaseServers server)
 {
     return(string.Format(_connectionStrings.CookieDBConnectionTemplate, server.DatabaseServer, server.DatabaseName));
 }
Ejemplo n.º 7
0
        internal ServerManager(Session session)
        {
            _session = session;

            Groups = new Groups(_session, Caching.Enabled);
            Projects = new Projects(_session, Caching.Enabled);
            DatabaseServers = new DatabaseServers(_session, Caching.Enabled);
            Users = new Users(_session, Caching.Enabled);
            Modules = new IndexedRDList<ModuleType, IModule>(GetModules, x => x.Type, Caching.Enabled);
            AsynchronousProcesses = new RDList<IAsynchronousProcess>(GetAsynchronousProcesses, Caching.Disabled);
            ApplicationServers = new ApplicationServers(_session, Caching.Enabled);
        }