public static bool ExecuteCommandByName(ChatMessage user, string commandName, string commandBody = null) { try { TwitchBotGlobalObjects.CheckAndAddOrEditUserIfNeed(user); DefaultBotCommand xBotCommand = DefaultCommandsList.FirstOrDefault(command => "!" + command.Name == commandName); TryExecuteCommand(user, commandBody, xBotCommand); PlayerBotCommand xPlayerCommand = PlayerCommandsList.FirstOrDefault(command => "!" + command.Name == commandName); TryExecuteCommand(user, commandBody, xPlayerCommand); CustomBotCommand xCustomCommand = CustomCommandsList.FirstOrDefault(command => "!" + command.Name == commandName); TryExecuteCommand(user, commandBody, xCustomCommand); return(true); } catch (Exception e) { return(false); } }
protected void FilterTrigerred() { bool isUseActions = false; TwitchBotGlobalObjects.CheckAndAddOrEditUserIfNeed(this._message); Viewer curentUser = AssistantDb.Instance.Viewers.Get(Convert.ToInt32(_message.UserId)); switch (this.MinIgnoreUserRang) { case TwitchRangs.Unfollower: isUseActions = true; break; case TwitchRangs.Follower: { if (!(curentUser.IsFollower || curentUser.IsSubscriber || curentUser.IsModerator || curentUser.IsBroadcaster)) { isUseActions = true; } } break; case TwitchRangs.Subscriber: { if (!(curentUser.IsSubscriber || curentUser.IsModerator || curentUser.IsBroadcaster)) { isUseActions = true; } } break; case TwitchRangs.Moderator: { if (!(curentUser.IsModerator || curentUser.IsBroadcaster)) { isUseActions = true; } } break; case TwitchRangs.Broadcaster: { if (!curentUser.IsBroadcaster) { isUseActions = true; } } break; default: break; } if (isUseActions) { UserActionInFilter currentUser = this._userActionInFilters.FirstOrDefault(user => user.User.Username == this._message.Username); if (currentUser == null) { var tmpUser = new UserActionInFilter() { User = this._message }; currentUser = tmpUser; _userActionInFilters.Add(currentUser); } ; currentUser.CountExecuting++; if (currentUser.CountExecuting >= CountingExecuteBeforeSanctions + 1) { currentUser.CountWarning++; if (currentUser.CountWarning == CountingExecuteBeforeTimeOut + 1) { TimeOutToUser(); _userActionInFilters.Remove(currentUser); } else { FilterResponce($"{this.WarningMessage} {CountingExecuteBeforeTimeOut - currentUser.CountWarning + 1}"); } } } }