Esempio n. 1
0
        public static void syncFiles(DriveService driveService, List <Google.Apis.Drive.v3.Data.File> list, string syncLocation, Discord.Channel txtchnl)
        {
            // Initialise a list to store which files need downloading.
            List <Google.Apis.Drive.v3.Data.File> toSync = new List <Google.Apis.Drive.v3.Data.File>();
            // Store what files are present locally.
            var localFiles = Directory.GetFiles(location + syncLocation);

            // Cycle through all files, If there isn't a local copy, add it to the list.
            foreach (Google.Apis.Drive.v3.Data.File file in list)
            {
                if (!localFiles.Contains(location + syncLocation + file.Name))
                {
                    toSync.Add(file);
                }
            }
            // Tell the channel how many files are to be downloaded.
            txtchnl.SendMessage($"Downloading {toSync.Count} files.");
            // For each file to be downloaded, download it.
            foreach (Google.Apis.Drive.v3.Data.File file in toSync)
            {
                if (!Directory.GetFiles(location + syncLocation).Contains(location + syncLocation + file.Name))
                {
                    DownloadFile(driveService, file, syncLocation + file.Name);
                }
            }
        }
Esempio n. 2
0
        async public void SendMessage(Discord.Channel channel, string msg)
        {
            if (channel == null)
            {
                channel = Program.growChannel;
            }

            await channel.SendMessage(msg);
        }
Esempio n. 3
0
        static async Task LewdSX(string chan, Discord.Channel c)
        {
            string        result = Helpers.GetRestClient("https://lewdchan.com").Execute(new RestRequest($"{chan}/src/list.php", Method.GET)).Content;
            List <string> list   = result.Split(new[] { Environment.NewLine }, StringSplitOptions.None).ToList();
            Regex         re     = new Regex(@"([^\s]+(\.(jpg|jpeg|png|gif|bmp)))");

            foreach (Match m in re.Matches(result))
            {
                list.Add(m.Value);
            }
            await c.SendMessage($"https://lewdchan.com/{chan}/src/{list[new Random().Next(0, list.Count())]}");
        }
Esempio n. 4
0
 public override void Execute(Server server, Discord.Channel channel, Discord.User user, string parameter, Dictionary <string, string> flags)
 {
     channel.SendMessage("Pong!");
 }