Exemplo n.º 1
0
 public bool MapIsUploadedToWebsite(string filename)
 {
     return(MapModule.CheckIfMapIsUploaded(filename));
 }
Exemplo n.º 2
0
            public override string runcommand(MessageEventArgs msg, string param)
            {
                string[] parameters = param.Split(new char[] { ' ' }, 3);
                int      index;

                if (parameters[0].Length == 0)
                {
                    return("Invalid parameters for !insert. Syntax: !insert <index> <filename> <url> <notes>");
                }
                try
                {
                    index = int.Parse(parameters[0]);
                }
                catch
                {
                    return("Invalid parameters for !insert. Syntax: !insert <index> <filename> <url> <notes>");
                }

                Map map = new Map();

                map.Submitter = msg.Sender.identifier.ToString();

                map.SubmitterName = msg.Sender.DisplayName;

                try
                {
                    map.Filename = parameters[1];
                }
                catch (Exception exception)
                {
                    return(string.Format("Your new file name was rejected because: {0}", exception.Message));
                }

                map.Notes = string.Format("Inserted in position {0} by {1} //", index, msg.Sender.identifier.ToString());

                if (MapModule.CheckIfMapIsUploaded(map.Filename)) //Check if the map is uploaded
                {
                    map.DownloadURL = "Uploaded";
                    if (parameters.Length > 1)
                    {
                        map.Notes += parameters.Last();
                    }
                }
                else if (parameters.Length > 2) //If its not uploaded check if a URL was there
                {
                    parameters = param.Split(new char[] { ' ' }, 4);

                    map.DownloadURL = parameters[2];
                    if (parameters.Length > 3)
                    {
                        map.Notes += parameters.Last();
                    }
                }
                else //If a url isn't there lets return an error
                {
                    return("Your map isn't uploaded! Please use include the url with the syntax: !add <filename> <url> (notes)");
                }
                string Reply = string.Format("Map '{0}' added.", map.Filename);

                MapModule.mapList.InsertMap(index, map);

                MapModule.savePersistentData();

                return(Reply);
            }
Exemplo n.º 3
0
            private Tuple <string, string> GetMapsWithFilter(string Filter, MapSearchFilter FilterType, bool OnlyReturnUploadedMaps)
            {
                IReadOnlyList <Map> maps = module.mapList.GetAllMaps();

                if (maps.Count == 0)
                {
                    return(new Tuple <string, string>("The map list is empty", " "));
                }
                else
                {
                    string chatResponse = "";
                    string pmResponse   = "";

                    int MapsAddedToResponse = 0;
                    int MapsInResponseLimit = module.MaxMapNumber;

                    //Build Chat Response
                    for (int i = 0; i < maps.Count; i++)
                    {
                        if (OnlyReturnUploadedMaps && (module.CheckIfMapIsUploaded(maps[i].Filename) == false))
                        {
                            // do nothing
                        }
                        else if (MapNamePassesFilter(maps[i].Filename, FilterType, Filter))
                        {
                            if (MapsAddedToResponse < MapsInResponseLimit)
                            {
                                if (MapsAddedToResponse > 0)
                                {
                                    chatResponse += " , ";
                                }

                                chatResponse += maps[i].Filename;
                                MapsAddedToResponse++;
                            }
                            int    Nextnum = i + 1;
                            string mapLine = string.Format(Nextnum + ") {0} // {1} // {2} ({3})", maps[i].Filename, maps[i].DownloadURL, maps[i].SubmitterName, maps[i].Submitter.ToString());

                            if (!string.IsNullOrEmpty(maps[i].Notes))
                            {
                                mapLine += " \nNotes: " + maps[i].Notes;
                            }

                            if (i < maps.Count - 1)
                            {
                                mapLine += " \n";
                            }

                            pmResponse += mapLine;
                        }
                    }

                    if (maps.Count > MapsAddedToResponse)
                    {
                        chatResponse += string.Format(" (and {0} more at: http://vbot.website )", maps.Count - MapsAddedToResponse);
                    }
                    else
                    {
                        chatResponse += " at: http://vbot.website";
                    }

                    if (MapsAddedToResponse == 0)
                    {
                        return(new Tuple <string, string>("There were no maps found with those search terms!", ""));
                    }

                    return(new Tuple <string, string>(chatResponse, pmResponse));
                }
            }