Example #1
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 #2
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 #3
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);
        }