Exemplo n.º 1
0
        public static string[] GetIDs(string name, IDType category, string AccessToken, int amount = 5000)
        {
            if (category != IDType.retweeters)
            {
                string response = WebRequest("https://api.twitter.com/1.1/" + category.ToString() + "/ids.json?screen_name=" + name + "&count=" + amount, AccessToken);

                if (!string.IsNullOrEmpty(response))
                {
                    response = response.Remove(0, 8);
                    response = response.Remove(response.IndexOf(']', response.Length - response.IndexOf(']')));
                    return(response.Split(','));
                }
            }
            else
            {
                //Basically do the same,
                string response = WebRequest("https://api.twitter.com/1.1/statuses/retweeters/ids.json?id=" + name + "&count=" + amount, AccessToken);

                if (!string.IsNullOrEmpty(response))
                {
                    response = response.Remove(0, 8);
                    response = response.Remove(response.IndexOf(']', response.Length - response.IndexOf(']')));
                    return(response.Split(','));
                }
            }
            return(null);
        }
Exemplo n.º 2
0
        public static EventResponse CreateUser(string ID, IDType IDVariant)
        {
            EventResponse Response   = new EventResponse();
            bool          UserExists = false;

            if (UserData.UserExists(ID, IDVariant))
            {
                UserExists = true;
            }

            if (UserExists)
            {
                Response.Message = "User already exists"; return(Response);
            }

            if (IDVariant == IDType.Discord)
            {
                foreach (Newtonsoft.Json.Linq.JObject Connection in GetConnections(ID)["connected_accounts"])
                {
                    if (Connection["type"].ToString() == "twitch")
                    {
                        if (UserData.UserExists(Connection["id"].ToString(), IDType.Twitch))
                        {
                            Newtonsoft.Json.Linq.JToken R = UserData.GetUser(Connection["id"].ToString(), IDType.Twitch);
                            if (R["Status"].ToString() != "200")
                            {
                                Response.Message = Shared.ConfigHandler.Config["CommandResponses"]["Errors"]["WhoKnows"].ToString(); return(Response);
                            }
                            Newtonsoft.Json.Linq.JToken User = R["Data"];
                            if (User["DiscordId"].ToString() == "")
                            {
                                User["DiscordId"] = ID.ToString();
                                WebRequests.POST("/update/user", null, User.ToString());
                                return(Response);
                            }
                        }
                        else
                        {
                            Dictionary <string, string> Headers1 = new Dictionary <string, string> {
                            };
                            Headers1.Add("DiscordId", ID.ToString()); Headers1.Add("TwitchId", Connection["id"].ToString());
                            WebRequests.POST("/create/user", Headers1);
                            Response.Success = true;
                            Response.Message = "Created User Account and added Twitch";
                            return(Response);
                        }
                    }
                }
            }
            Dictionary <string, string> Headers2 = new Dictionary <string, string> {
            };

            Headers2.Add(IDVariant.ToString() + "Id", ID.ToString());
            WebRequests.POST("/create/user", Headers2);
            Response.Success = true;
            Response.Message = "Created User Account";

            return(Response);
        }
Exemplo n.º 3
0
        public static Newtonsoft.Json.Linq.JToken GetUser(string ID, IDType IDVariant)
        {
            Dictionary <string, string> Headers = new Dictionary <string, string> {
            };

            Headers.Add(IDVariant.ToString() + "Id", ID);
            Newtonsoft.Json.Linq.JToken Response = WebRequests.POST("/user", Headers, "", false, false);
            return(Response);
        }
Exemplo n.º 4
0
        public InvItem(IDType id)
        {
            this.id = id;

            // generate path i.e. SmokeBomb becomes UI/SmokeBombIcon
            string iconPath   = "UI/" + id.ToString() + "Icon";
            string prefabPath = "Prefabs/" + id.ToString();

            // load icon
            icon   = Resources.Load <Texture2D> (iconPath);
            prefab = Resources.Load <GameObject> (prefabPath);

            // error if icon cannot be loaded
            if (icon == null)
            {
                Debug.LogError(iconPath + " icon cannot be loaded");
            }
        }
Exemplo n.º 5
0
 public bool Search(string str)
 {
     if (ID.ToString().Contains(str) || IDType.ToString().Contains(str))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 6
0
    public static int CreateNew(IDType type)
    {
        switch (type)
        {
        case IDType.CATAGORY:   return(Managers.Data.FileData.IDTrackerModel.CatagoryID + 1);

        case IDType.EXPENSE:    return(Managers.Data.FileData.IDTrackerModel.ExpenseID + 1);

        default:
            Debug.Log($"[ERROR] Unable to assign a new {type.ToString()} ID");
            return(-1);
        }
    }
Exemplo n.º 7
0
        public static EventResponse AddID(string CurrentID, IDType CurrentIDVariant, string NewID, IDType NewIDVariant)
        {
            EventResponse Response = new EventResponse();

            bool UserExists = false;

            if (UserData.UserExists(CurrentID, CurrentIDVariant))
            {
                UserExists = true;
            }

            if (!UserExists)
            {
                Response.Message = "User doesnt exist"; return(Response);
            }

            Newtonsoft.Json.Linq.JToken R = UserData.GetUser(CurrentID, CurrentIDVariant);
            if (R["Status"].ToString() != "200")
            {
                Response.Message = Shared.ConfigHandler.Config["CommandResponses"]["Errors"]["WhoKnows"].ToString(); return(Response);
            }
            Newtonsoft.Json.Linq.JToken User = R["Data"];
            User[NewIDVariant.ToString() + "Id"] = NewID;
            Newtonsoft.Json.Linq.JToken D = WebRequests.POST("/update/user", null, User.ToString());

            if (D["Status"].ToString() == "200")
            {
                Response.Success = true;
                Response.Message = "Set " + NewIDVariant.ToString() + "ID";
            }
            else
            {
                Response.Message = "Error occured while setting " + NewIDVariant.ToString() + "ID";
            }

            return(Response);
        }
Exemplo n.º 8
0
        public void GetValues(ref List <string> takenValues)
        {
#if DEBUG
            GeneralClass.CheckNotNull(takenValues);
#endif
            takenValues.Clear();
            takenValues.Add(ID.ToString());
            takenValues.Add(NameOfField.ToString());
            takenValues.Add(IDType.ToString());
            takenValues.Add(DefaultValue.ToString());
            takenValues.Add(IfMandatory.ToString());
            takenValues.Add(IfHidden.ToString());
            takenValues.Add(IDTable.ToString());
            takenValues.Add(IfDependent.ToString());
            takenValues.Add(IDMasterField.ToString());
            takenValues.Add(IfUnique.ToString());
            takenValues.Add(IDConstraint.ToString());
            takenValues.Add(Description.ToString());
        }