private static bool Prefix([CanBeNull] CommandDriver __instance, ITwitchMessage twitchMessage) { if (__instance == null) { return(true); } if (!TkSettings.StoreState) { return(false); } Viewer viewer = Viewers.GetViewer(twitchMessage.Username); ITwitchMessage message = twitchMessage; if (!__instance.command.defName.Equals("Buy")) { message = twitchMessage.WithMessage($"!{CommandDefOf.Buy.command} {twitchMessage.Message.Substring(1)}"); } if (message !.Message.Split(' ').Length < 2) { return(false); } Purchase_Handler.ResolvePurchase(viewer, message); return(false); }
private static bool Prefix([CanBeNull] ITwitchMessage twitchMessage) { if (!TkSettings.Commands || twitchMessage?.Message == null) { return(!TkSettings.Commands); } Viewer viewer = Viewers.GetViewer(twitchMessage.Username); viewer.last_seen = DateTime.Now; if (viewer.IsBanned) { return(false); } string sanitized = GetCommandString(twitchMessage.Message); if (sanitized == null) { return(false); } List <string> segments = CommandFilter.Parse(sanitized).ToList(); bool text = segments.Any(i => i.EqualsIgnoreCase("--text")); if (segments.Count <= 0) { return(false); } if (text) { segments = segments.Where(i => !i.EqualsIgnoreCase("--text")).ToList(); } LocateCommand(segments.ToArray())?.Execute(twitchMessage.WithMessage("!" + CombineSegments(segments).Trim()) !, text); return(false); }