コード例 #1
0
        private async Task HelloUnknownUser(DiscordBotContext dbContext, DiscordUser discordUser)
        {
            await ReplyAsync($"Hello {Context.User.Username}, it seems we don't know each other yet. " +
                             $"I have reached out to you privately to get to known each better.");

            await GetToKnowHelper.GetToKnowUser(Context, _ladanseUrlBuilder, dbContext, discordUser);
        }
コード例 #2
0
        private async Task HelloForgottenUser(DiscordBotContext dbContext, DiscordUser discordUser)
        {
            await ReplyAsync($"Hello {Context.User.Username}, I remember you but I seem to have forgotten some of our adventure. " +
                             $"I have reached out to you privately to get to know each other again.");

            await GetToKnowHelper.GetToKnowUser(Context, _ladanseUrlBuilder, dbContext, discordUser);
        }
コード例 #3
0
        private string GetAccessToken(DiscordBotContext dbContext, DiscordUser discordUser)
        {
            var accessTokenMapping = dbContext.AccessTokenMappings
                                     .FirstOrDefault(a => a.DiscordUser == discordUser && a.State == AccessTokenState.Active);

            return(accessTokenMapping?.AccessToken);
        }
コード例 #4
0
 public BasicAuthenticationHandler(
     IOptionsMonitor <AuthenticationSchemeOptions> options,
     ILoggerFactory logger,
     UrlEncoder encoder,
     DiscordBotContext context,
     ISystemClock clock) : base(options, logger, encoder, clock)
 {
     _context = context;
 }
コード例 #5
0
 public ConnectController(
     LaDanseUrlBuilder laDanseUrlBuilder,
     LaDanseRestClient laDanseRestClient,
     ILogger <ConnectController> logger,
     DiscordBotContext dbContext)
 {
     _laDanseUrlBuilder = laDanseUrlBuilder;
     _laDanseRestClient = laDanseRestClient;
     _logger            = logger;
     _dbContext         = dbContext;
 }
コード例 #6
0
        public static async Task GetToKnowUser(
            SocketCommandContext socketCommandContext,
            LaDanseUrlBuilder laDanseUrlBuilder,
            DiscordBotContext dbContext,
            DiscordUser discordUser)
        {
            #region CleanUpAuthSessions

            var authSessions = dbContext.AuthSessions
                               .Where(b => b.DiscordUser == discordUser)
                               .ToList();

            foreach (var authSession in authSessions)
            {
                if (authSession.State == AuthSessionState.Pending)
                {
                    authSession.State = AuthSessionState.Removed;
                }
            }

            #endregion

            #region NewAuthSession

            var newAuthSession = new AuthSession
            {
                Nonce       = RandomStringUtils.Random(32),
                CreatedOn   = 0,
                DiscordUser = discordUser,
                State       = AuthSessionState.Pending
            };

            dbContext.AuthSessions.Add(newAuthSession);

            #endregion

            await socketCommandContext.User.SendMessageAsync(
                "Click on this URL and follow the instructions if you want us to get to know each other better ...\n\n" +
                laDanseUrlBuilder.GetDiscordAuthInformUrl(newAuthSession.Nonce, "http://localhost:57077/connect/website"));
        }
コード例 #7
0
 private async Task HelloKnownUser(DiscordBotContext dbContext, DiscordUser discordUser)
 {
     await ReplyAsync($"Hello {Context.User.Username}, nice to see you. How are you doing?");
 }
コード例 #8
0
 public CommandItemRepo(DiscordBotContext context)
 {
     _context = context;
 }
コード例 #9
0
ファイル: UserRepo.cs プロジェクト: JoyfulReaper/DiscordBot
 public UserRepo(DiscordBotContext context)
 {
     _context = context;
 }
コード例 #10
0
 public ServerLogItemRepo(DiscordBotContext context)
 {
     _context = context;
 }