static void Main(string[] args) { ConstVariables.SetDelegate(new Program().Messege); AppDomain currentDomain = AppDomain.CurrentDomain; currentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyHandler); #if !DEBUG if (args.Length != 0) { ConstVariables.Patch = args[0]; } #endif if (ConstVariables.InstallationLists()) { ConstVariables.Logger.Info("Запуск программы"); #if !DEBUG new Program().Youtube(); new Program().Twitch(); #endif try { ConstVariables.LegionDiscordThread.Start(); } catch (Exception e) { ConstVariables.Logger.Error(e.Message); } } Console.ReadKey(); }
private async Task MessageRec(SocketMessage Messag) { string mess = Messag.Content.ToLower(); SocketUserMessage Messege = Messag as SocketUserMessage; SocketCommandContext Context = new SocketCommandContext(_Client, Messege); if (!ConstVariables.ThisTest || Messag.Author.IsBot) { return; } bool IsTrigger = false; ConstVariables.CDiscord guild = ConstVariables.CServer[Context.Guild.Id]; ISocketMessageChannel channel = Context.Channel; if ((guild.IsEntryOrСategoryChannel(channel.Id) && !Context.User.IsBot) || ConstVariables.ThisTest) { int count = ConstVariables.CountTextRequst(mess, Context.Guild.Id); if (count > 0) { string str = ConstVariables.TextRequst(mess, Context.Guild.Id); if (str != ConstVariables.NCR) { if (str.IndexOf("{0}") >= 0) { str = String.Format(str, Context.User.Mention); } await channel.SendMessageAsync(str); IsTrigger = true; } } ConstVariables.ResultIndexOfText result = ConstVariables.IndexOfText(mess); if (result.isSearch && (result.GuildID == Context.Guild.Id || result.GuildID == 0 || ConstVariables.ThisTest)) { if (result.Condition == "{0}") { if (result.TextAnswer.IndexOf("{0}") >= 0) { result.TextAnswer = String.Format(result.TextAnswer, Context.User.Mention); } await channel.SendMessageAsync(result.TextAnswer); } else { bool IsCondition = false; bool IsParam1 = false; if (result.Condition.IndexOf("{1}") > -1) { if ((guild.CountRes < guild.Restruction) && (!ConstVariables.CServer[Context.Guild.Id].Trigger)) { IsCondition = true; } IsParam1 = true; } else { IsCondition = true; } if (result.Condition.IndexOf("{2}") > -1) { if (mess.IndexOf("бот") == 0 || MentionUser(Context, _Client.CurrentUser.Id)) { IsCondition &= true; } else { IsCondition = false; } } else { IsCondition &= true; } if (IsCondition) { if (result.TextAnswer.IndexOf("{0}") >= 0) { result.TextAnswer = String.Format(result.TextAnswer, Context.User.Mention); } await channel.SendMessageAsync(result.TextAnswer); if (IsParam1) { guild.CountRes++; ConstVariables.CServer[Context.Guild.Id].Trigger = true; new Program().OneMin(Context.Guild.Id); } } } IsTrigger = true; } if (IsTrigger) { ConstVariables.Logger.Info($" Сработал тригер: '{mess}'! is Guid '{guild.GetGuild().Name}' is channel '{channel.Name}' is user '{Context.User.Username}#{Context.User.Discriminator}'"); } } }