Example #1
0
        private async Task CheckBanListTwo()
        {
            TakeBanList();
            foreach (BanMembers it in BanList)
            {
                if (it.GetTime() == nowtime.ToString())
                {
                    try
                    {
                        var context = Client.GetChannel(718185523390185577) as SocketTextChannel;
                        await context.SendMessageAsync($"Лошок {it.GetName()} с ID {it.GetDiscId()} откинулся");

                        await ReadWriter.RemoveObj(it.GetDiscId(), "BanList");

                        var dmChannel = await Client.GetUser(it.GetDiscId()).GetOrCreateDMChannelAsync();

                        await dmChannel.SendMessageAsync($"Ваши Грехи были опущенны на сервере {context.Guild.Name}");
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("CheckBanListTwo Exception");
                    }
                }
            }
        }
Example #2
0
        private void TakeBanList()
        {
            BanList.Clear();
            List <string> tmp = ReadWriter.TakeStringList("./ini/BanList");

            foreach (string it in tmp)
            {
                string[] strtmp = it.Split('|');
                if (strtmp.Length == 3)
                {
                    BanList.Add(new BanMembers(Convert.ToUInt64(strtmp[0]),
                                               strtmp[1], strtmp[2], null, null));
                }
                else if (strtmp.Length == 4)
                {
                    BanList.Add(new BanMembers(Convert.ToUInt64(strtmp[0]),
                                               strtmp[1], strtmp[2], strtmp[3], null));
                }
                else if (strtmp.Length == 5)
                {
                    BanList.Add(new BanMembers(Convert.ToUInt64(strtmp[0]),
                                               strtmp[1], strtmp[2], strtmp[3], strtmp[4]));
                }
            }
            Program.isNeedToCheck = true;
        }
Example #3
0
 private void onBanChange(object sender, FileSystemEventArgs e)
 {
     if (e.ChangeType == WatcherChangeTypes.Changed && e.Name == "BanList")
     {
         BanList.Clear();
         List <string> tmp = ReadWriter.TakeStringList("./ini/BanList");
         foreach (string it in tmp)
         {
             string[] strtmp = it.Split('|');
             BanList.Add(new BanMembers(Convert.ToUInt64(strtmp[0]),
                                        strtmp[1], strtmp[2], strtmp[3], strtmp[4]));
         }
     }
 }
Example #4
0
        public async Task RunBotAsync()
        {
            Client   = new DiscordSocketClient();
            Commands = new CommandService();
            Services = new ServiceCollection()
                       .AddSingleton(Client)
                       .AddSingleton(Commands)
                       .BuildServiceProvider();

            Client.Log += Client_Log;

            TakeBanList();

            Answers        = ReadWriter.TakeStringList("./ini/Answers");
            TypingList     = ReadWriter.TakeUintList("./ini/TypingList");
            AdminList      = ReadWriter.TakeUintList("./ini/AdminList");
            ConnectedUsers = new List <MemberMovements>();

/*            Watcher.Path = @"Y:\Projects\Chizar\ChizarBot\bin\Debug\netcoreapp3.1";
 *          Watcher.NotifyFilter = NotifyFilters.LastWrite;
 *          Watcher.Filter = "*.*";
 */



            await RegisterCommandsAsync();

            await Client.LoginAsync(TokenType.Bot, token);

            await Client.StartAsync();


            try
            {
                Thread myThread   = new Thread(new ThreadStart(ChangeTime));
                Thread HourThread = new Thread(new ThreadStart(EveryHourBan));
                myThread.Start();
                HourThread.Start();
            }catch (Exception e)
            {
                Console.WriteLine("THREAD");
            }


            await Task.Delay(-1);
        }