示例#1
0
        private async void TwitchOnWhisperReceived(object sender, TwitchLib.Client.Events.OnWhisperReceivedArgs e)
        {
            UserEntry user = await Program.Users.GetUserByTwitchID(e.WhisperMessage.UserId);

            if (user == null)
            {
                return;
            }
            string message = e.WhisperMessage.Message.Trim();

            string[] args = message.Split(' ');
            if (args.Length != 1)
            {
                return;
            }
            int pin = 000000;

            int.TryParse(args[0], out pin);
            if (pin == 000000)
            {
                return;
            }
            if (Tokens.Exists(p => p.PIN == pin))
            {
                LinkToken token = Tokens.Find(p => p.PIN == pin);
                token.twitchID = e.WhisperMessage.UserId;
                MatchToken(token);
            }
        }
示例#2
0
        public async Task SetupAndInformLinkToken(UserEntry user)
        {
            if (user.linked)
            {
                return;
            }
            LinkToken token;
            bool      informOnTwitch = true;

            if (user._discordUID != 0)
            {
                token          = new LinkToken(user._discordUID);
                informOnTwitch = false;
            }
            else
            {
                token = new LinkToken(user._twitchUID);
            }
            Tokens.Add(token);
            if (informOnTwitch)
            {
                Program.TwitchClient.SendWhisper(user._twitchUsername,
                                                 $"Next step is to send me this code '{token.PIN}' in a direct message on Discord. Make sure to only send the code. Code expires in 180s."
                                                 );
            }
            else
            {
                SocketUser u = Program.DiscordClient.GetUser(user._discordUID);
                await Discord.UserExtensions.SendMessageAsync(u,
                                                              $"Next step is to send me this code '{token.PIN}' in a whisper on Twitch. Make sure to only send the code. Code expires in 180s."
                                                              );
            }
        }
示例#3
0
        private async void MatchToken(LinkToken token)
        {
            Tokens.RemoveAll(p => p.discordID == token.discordID);
            UserEntry tUser = await Program.Users.GetUserByTwitchID(token.twitchID);

            UserEntry dUser = await Program.Users.GetUserByDiscordID(Core.StringToUlong(token.discordID));

            if (tUser != null && dUser != null)
            {
                await Program.Users.LinkAccounts(dUser, tUser);
            }
        }