예제 #1
0
    public override void Handle()
    {
        Regex afkPattern = PatternCreator.Create(Alias, ChatMessage.Channel.Prefix, @"\safk\s\w+");

        if (afkPattern.IsMatch(ChatMessage.Message))
        {
            Response = $"{ChatMessage.Username}, ";
            string username = ChatMessage.LowerSplit[2];
            int?   userId   = TwitchApi.GetUserId(username);
            if (userId is null)
            {
                Response += PredefinedMessages.UserNotFoundMessage;
                return;
            }

            UserNew?user = DbController.GetUser(userId.Value, username);
            if (user is null)
            {
                Response += PredefinedMessages.UserNotFoundMessage;
                return;
            }

            if (user.IsAfk == true)
            {
                Response += new AfkMessage(userId.Value).GoingAway !;
                string message = user.AfkMessage.Decode();
                if (!string.IsNullOrEmpty(message))
                {
                    Response += $": {message}";
                }
                Response += $" ({TimeHelper.GetUnixDifference(user.AfkTime)} ago)";
            }
            else
            {
                Response += $"{username} is not afk";
            }
            return;
        }

        Regex reminderPattern = PatternCreator.Create(Alias, ChatMessage.Channel.Prefix, @"\sreminder\s\d+");

        if (reminderPattern.IsMatch(ChatMessage.Message))
        {
            Response = $"{ChatMessage.Username}, ";
            int      id       = ChatMessage.Split[2].ToInt();
            Reminder?reminder = DbController.GetReminder(id);
            if (reminder is null)
            {
                Response += PredefinedMessages.ReminderNotFoundMessage;
                return;
            }

            Response += $"From: {reminder.GetAuthor()} || To: {reminder.GetTarget()} || ";
            Response += $"Set: {TimeHelper.GetUnixDifference(reminder.Time)} ago || ";
            Response += reminder.ToTime > 0 ? $"Fires in: {TimeHelper.GetUnixDifference(reminder.ToTime)} || " : string.Empty;
            Response += $"Message: {reminder.Message.Decode()}";
            return;
        }
    }
예제 #2
0
    public static BttvRequest?GetBttvRequest(string channel)
    {
        int?id = TwitchApi.GetUserId(channel);

        if (id.HasValue)
        {
            return(GetBttvRequest(id.Value));
        }
        return(null);
    }
예제 #3
0
    public override void Handle()
    {
        Response = $"{ChatMessage.Username}, ";
        Regex pattern = PatternCreator.Create(Alias, ChatMessage.Channel.Prefix, @"\s\w+");

        if (pattern.IsMatch(ChatMessage.Message))
        {
            string username = ChatMessage.LowerSplit[1];
            string?userId   = TwitchApi.GetUserId(username)?.ToString();
            Response += userId ?? PredefinedMessages.TwitchUserDoesntExistMessage;
        }
        else
        {
            Response += ChatMessage.UserId.ToString();
        }
    }