Beispiel #1
0
 IEnumerator DoCheck()
 {
     for (; ;)
     {
         try
         {
             if (AvatarToPost.Count != 0)
             {
                 ApiAvatar avatar = AvatarToPost.Peek();
                 AvatarToPost.Dequeue();
                 DiscordEmbedBuilder discordEmbed = new DiscordEmbedBuilder();
                 discordEmbed.WithAuthor(string.IsNullOrEmpty(config.BotName) ? "Loggy boi" : config.BotName, string.IsNullOrEmpty(config.AvatarURL) ? "https://i.imgur.com/No3R2yY.jpg" : config.AvatarURL, string.IsNullOrEmpty(config.AvatarURL) ? "https://i.imgur.com/No3R2yY.jpg" : config.AvatarURL);
                 discordEmbed.WithImageUrl(avatar.thumbnailImageUrl);
                 discordEmbed.WithColor(new DiscordColor(avatar.releaseStatus == "public" ? "#00FF00" : "#FF0000"));
                 discordEmbed.WithUrl($"https://vrchat.com/api/1/avatars/{avatar.id}?apiKey=JlE5Jldo5Jibnk5O5hTx6XVqsJu4WJ26");
                 discordEmbed.WithTitle("Click Me (API Link)");
                 discordEmbed.WithDescription("Must be logged in on VRChat.com to view api link ^^");
                 discordEmbed.WithTimestamp(DateTimeOffset.Now);
                 discordEmbed.AddField("Avatar ID:", avatar.id);
                 discordEmbed.AddField("Avatar Name:", avatar.name);
                 discordEmbed.AddField("Avatar Description:", avatar.description);
                 discordEmbed.AddField("Avatar Author ID:", avatar.authorId);
                 discordEmbed.AddField("Avatar Author Name:", avatar.authorName);
                 discordEmbed.AddField("Avatar Version:", avatar.version.ToString());
                 discordEmbed.AddField("Avatar Release Status:", avatar.releaseStatus);
                 discordEmbed.AddField("Avatar Asset URL:", avatar.assetUrl);
                 discordEmbed.AddField("Avatar Image URL:", avatar.imageUrl);
                 discordEmbed.AddField("Avatar Thumbnail Image URL:", avatar.thumbnailImageUrl);
                 discordEmbed.WithFooter("Made by KeafyIsHere", string.IsNullOrEmpty(config.AvatarURL) ? "https://i.imgur.com/No3R2yY.jpg" : config.AvatarURL);
                 RestWebhookExecutePayload webhookpayload = new RestWebhookExecutePayload
                 {
                     Content   = "",
                     Username  = string.IsNullOrEmpty(config.BotName) ? "Loggy boi" : config.BotName,
                     AvatarUrl = string.IsNullOrEmpty(config.AvatarURL) ? "https://i.imgur.com/No3R2yY.jpg" : config.AvatarURL,
                     IsTTS     = false,
                     Embeds    = new List <DiscordEmbed>()
                     {
                         discordEmbed.Build()
                     }
                 };
                 new HttpClient().PostAsync(avatar.releaseStatus == "public" ? config.PublicWebhook : config.PrivateWebhook, new StringContent(JsonConvert.SerializeObject(webhookpayload), Encoding.UTF8, "application/json"));
             }
         }
         catch (Exception ex)
         {
             MelonLoader.MelonLogger.Error(ex);
         }
         yield return(new WaitForSeconds(1f));
     }
 }
Beispiel #2
0
        private static void DoCheck()
        {
            for (;;)
            {
                try
                {
                    if (AvatarToPost.Count != 0)
                    {
                        var avatar = AvatarToPost.Peek();
                        AvatarToPost.Dequeue();
                        var discordEmbed = new DiscordEmbedBuilder();
                        discordEmbed.WithAuthor(string.IsNullOrEmpty(Config.BotName) ? "Loggy boi" : Config.BotName,
                                                string.IsNullOrEmpty(Config.AvatarURL)
                                ? "https://i.imgur.com/No3R2yY.jpg"
                                : Config.AvatarURL,
                                                string.IsNullOrEmpty(Config.AvatarURL)
                                ? "https://i.imgur.com/No3R2yY.jpg"
                                : Config.AvatarURL);
                        discordEmbed.WithImageUrl(avatar.thumbnailImageUrl);
                        discordEmbed.WithColor(avatar.releaseStatus.Equals("public") ? PublicColor : PrivateColor);
                        if (avatar.releaseStatus.Equals("public"))
                        {
                            discordEmbed.WithUrl(
                                $"https://vrchat.com/api/1/avatars/{avatar.id}?apiKey=JlE5Jldo5Jibnk5O5hTx6XVqsJu4WJ26");
                            discordEmbed.WithTitle("Click Me (API Link)");
                            discordEmbed.WithDescription("Must be logged in on VRChat.com to view api link ^^");
                        }

                        discordEmbed.WithTimestamp(DateTimeOffset.Now);
                        discordEmbed.AddField("Avatar ID:", avatar.id);
                        discordEmbed.AddField("Avatar Name:", avatar.name);
                        discordEmbed.AddField("Avatar Description:", avatar.description);
                        discordEmbed.AddField("Avatar Author ID:", avatar.authorId);
                        discordEmbed.AddField("Avatar Author Name:", avatar.authorName);
                        discordEmbed.AddField("Avatar Version:", avatar.version.ToString());
                        discordEmbed.AddField("Avatar Release Status:", avatar.releaseStatus);
                        discordEmbed.AddField("Avatar Asset URL:", avatar.assetUrl);
                        discordEmbed.AddField("Avatar Image URL:", avatar.imageUrl);
                        discordEmbed.AddField("Avatar Thumbnail Image URL:", avatar.thumbnailImageUrl);
                        discordEmbed.WithFooter("Made by KeafyIsHere",
                                                string.IsNullOrEmpty(Config.AvatarURL)
                                ? "https://i.imgur.com/No3R2yY.jpg"
                                : Config.AvatarURL);
                        var restWebhookPayload = new RestWebhookExecutePayload
                        {
                            Content   = "",
                            Username  = string.IsNullOrEmpty(Config.BotName) ? "Loggy boi" : Config.BotName,
                            AvatarUrl = string.IsNullOrEmpty(Config.AvatarURL)
                                ? "https://i.imgur.com/No3R2yY.jpg"
                                : Config.AvatarURL,
                            IsTTS  = false,
                            Embeds = new List <DiscordEmbed> {
                                discordEmbed.Build()
                            }
                        };
                        if (avatar.releaseStatus == "public")
                        {
                            foreach (var url in Config.PublicWebhook)
                            {
                                WebHookClient.PostAsync(url,
                                                        new StringContent(JsonConvert.SerializeObject(restWebhookPayload), Encoding.UTF8,
                                                                          "application/json"));
                            }
                        }
                        else
                        {
                            foreach (var url in Config.PrivateWebhook)
                            {
                                WebHookClient.PostAsync(url,
                                                        new StringContent(JsonConvert.SerializeObject(restWebhookPayload), Encoding.UTF8,
                                                                          "application/json"));
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MelonLogger.Error(ex);
                }

                Thread.Sleep(1000);
            }
        }
Beispiel #3
0
        IEnumerator DoCheckV2()
        {
            for (; ;)
            {
                try
                {
                    if (AvatarToPost.Count > 0)
                    {
                        RestWebhookExecutePayload whplprivate = new RestWebhookExecutePayload
                        {
                            Content   = "",
                            Username  = string.IsNullOrEmpty(config.BotName) ? "Loggy boi" : config.BotName,
                            AvatarUrl = string.IsNullOrEmpty(config.AvatarURL) ? "https://i.imgur.com/No3R2yY.jpg" : config.AvatarURL,
                            IsTTS     = false,
                            Embeds    = new List <DiscordEmbed>()
                        };

                        RestWebhookExecutePayload whplpublic = new RestWebhookExecutePayload
                        {
                            Content   = "",
                            Username  = string.IsNullOrEmpty(config.BotName) ? "Loggy boi" : config.BotName,
                            AvatarUrl = string.IsNullOrEmpty(config.AvatarURL) ? "https://i.imgur.com/No3R2yY.jpg" : config.AvatarURL,
                            IsTTS     = false,
                            Embeds    = new List <DiscordEmbed>()
                        };

                        for (int i = 0; i < AvatarToPost.Count; i++)
                        {
                            ApiAvatar avi = AvatarToPost[i];
                            if (avi != null)
                            {
                                DiscordEmbedBuilder discordEmbed = new DiscordEmbedBuilder();
                                discordEmbed.WithAuthor(string.IsNullOrEmpty(config.BotName) ? "Loggy boi" : config.BotName, string.IsNullOrEmpty(config.AvatarURL) ? "https://i.imgur.com/No3R2yY.jpg" : config.AvatarURL, string.IsNullOrEmpty(config.AvatarURL) ? "https://i.imgur.com/No3R2yY.jpg" : config.AvatarURL);
                                discordEmbed.WithImageUrl(avi.thumbnailImageUrl);
                                discordEmbed.WithColor(new DiscordColor(avi.releaseStatus == "public" ? "#00FF00" : "#FF0000"));
                                discordEmbed.WithUrl($"https://vrchat.com/api/1/avatars/{avi.id}?apiKey=JlE5Jldo5Jibnk5O5hTx6XVqsJu4WJ26");
                                discordEmbed.WithTitle("Click Me (API Link)");
                                discordEmbed.WithDescription("Must be logged in on VRChat.com to view api link ^^");
                                discordEmbed.WithTimestamp(DateTimeOffset.Now);
                                discordEmbed.AddField("Avatar ID:", avi.id);
                                discordEmbed.AddField("Avatar Name:", avi.name);
                                discordEmbed.AddField("Avatar Description:", avi.description);
                                discordEmbed.AddField("Avatar Author ID:", avi.authorId);
                                discordEmbed.AddField("Avatar Author Name:", avi.authorName);
                                discordEmbed.AddField("Avatar Version:", avi.version.ToString());
                                discordEmbed.AddField("Avatar Release Status:", avi.releaseStatus);
                                discordEmbed.AddField("Avatar Asset URL:", avi.assetUrl);
                                discordEmbed.AddField("Avatar Image URL:", avi.imageUrl);
                                discordEmbed.AddField("Avatar Thumbnail Image URL:", avi.thumbnailImageUrl);
                                discordEmbed.WithFooter("Made by KeafyIsHere", string.IsNullOrEmpty(config.AvatarURL) ? "https://i.imgur.com/No3R2yY.jpg" : config.AvatarURL);
                                if (APIUser.IsFriendsWith(avi.authorId) && !config.CanPostFriendsAvatar)
                                {
                                    if (avi.releaseStatus == "public")
                                    {
                                        whplpublic.Embeds.Add(discordEmbed.Build());
                                    }
                                    else
                                    {
                                        whplprivate.Embeds.Add(discordEmbed.Build());
                                    }
                                }

                                if (whplprivate.Embeds.Count > 23) // Max 25 embeds but keep it 23 so theres no weird like glitches (it just helps ok ok)
                                {
                                    PostingClient.PostAsync(config.PrivateWebhook, new StringContent(JsonConvert.SerializeObject(whplprivate), Encoding.UTF8, "application/json"));
                                    whplprivate.Embeds.Clear();
                                }

                                if (whplpublic.Embeds.Count > 23)// Max 25 embeds but keep it 23 so theres no weird like glitches (it just helps ok ok)
                                {
                                    PostingClient.PostAsync(config.PrivateWebhook, new StringContent(JsonConvert.SerializeObject(whplpublic), Encoding.UTF8, "application/json"));
                                    whplpublic.Embeds.Clear();
                                }
                            }
                            AvatarToPost.Remove(avi);
                        }

                        if (whplprivate.Embeds.Count > 0)
                        {
                            PostingClient.PostAsync(config.PrivateWebhook, new StringContent(JsonConvert.SerializeObject(whplprivate), Encoding.UTF8, "application/json"));
                        }



                        if (whplpublic.Embeds.Count > 0)
                        {
                            PostingClient.PostAsync(config.PublicWebhook, new StringContent(JsonConvert.SerializeObject(whplpublic), Encoding.UTF8, "application/json"));
                        }
                    }
                }
                catch (Exception ex)
                {
                    MelonLoader.MelonLogger.Error(ex);
                }
                yield return(new WaitForSeconds(1f));
            }


            yield return(new WaitForSeconds(1f));
        }