Иконка ресурса

FREE RusterNET : 4.2.5 4.2.5

Нет прав для скачивания
C#:
// Все права принадлежат дискорд сообществу https://discord.gg/VgNHPpNrz6

/* 
                                                                                                                                                                                        
 ____            _            _   _ _____ _____                                                                                                                                         
|  _ \ _   _ ___| |_ ___ _ __| \ | | ____|_   _|                                                                                                                                        
| |_) | | | / __| __/ _ \ '__|  \| |  _|   | |                                                                                                                                          
|  _ <| |_| \__ \ ||  __/ |_ | |\  | |___  | |                                                                                                                                          
|_| \_\\__,_|___/\__\___|_(_)|_| \_|_____| |_|                                                                                                                                          
                                                                                                                                                                                        
       DO             NOT           MODIFY                                                                                                                                              
               NOR           EDIT                                                                                                                                                       
                    THANKS!                                                                                                                                                             
 */
/*                                                                                                                                                                                      
End-User License Agreement (EULA) of Ruster.NET
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This End-User License Agreement ("EULA") is a legal agreement between you and Raul-Sorin Sorban.This EULA agreement governs your acquisition and use of our Ruster.NET software ("Software") directly from Raul-Sorin Sorban or indirectly through a Raul-Sorin Sorban authorized reseller or distributor (a "Reseller").Please read this EULA agreement carefully before completing the installation process and using the Ruster.NET software.It provides a license to use the Ruster.NET software and contains warranty information and liability disclaimers.If you register for a free trial of the Ruster.NET software, this EULA agreement will also govern that trial.By clicking "accept" or installing and/or using the Ruster.NET software, you are confirming your acceptance of the Software and agreeing to become bound by the terms of this EULA agreement.If you are entering into this EULA agreement on behalf of a company or other legal entity, you represent that you have the authority to bind such entity and its affiliates to these terms and conditions.If you do not have such authority or if you do not agree with the terms and conditions of this EULA agreement, do not install or use the Software, and you must not accept this EULA agreement.This EULA agreement shall apply only to the Software supplied by Raul-Sorin Sorban herewith regardless of whether other software is referred to or described herein.The terms also apply to any Raul-Sorin Sorban updates, supplements, Internet-based services, and support services for the Software, unless other terms accompany those items on delivery.If so, those terms apply.License Grant                                                                                                                                                                           
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Raul-Sorin Sorban hereby grants you a personal, non-transferable, non-exclusive licence to use the Ruster.NET software on your devices in accordance with the terms of this EULA agreement.You are permitted to load the Ruster.NET software (for example a PC, laptop, mobile or tablet) under your control.You are responsible for ensuring your device meets the minimum requirements of the Ruster.NET software.You are not permitted to:                                                                                                                                                               
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
* Edit, alter, modify, adapt, translate or otherwise change the whole or any part of the Software nor permit the whole or any part of the Software to be combined with or become incorporated in any other software, nor decompile, disassemble or reverse engineer the Software or attempt to do any such things.* Reproduce, copy, distribute, resell or otherwise use the Software for any commercial purpose.* Allow any third party to use the Software on behalf of or for the benefit of any third party.* Use the Software in any way which breaches any applicable local, national or international law.* Use the Software for any purpose that Raul-Sorin Sorban considers is a breach of this EULA agreement.* Intellectual Property and Ownership                                                                                                                                                   
                                                                                                                                                                                        
Raul-Sorin Sorban shall at all times retain ownership of the Software as originally downloaded by you and all subsequent downloads of the Software by you.The Software (and the copyright, and other intellectual property rights of whatever nature in the Software, including any modifications made thereto) are and shall remain the property of Raul-Sorin Sorban.Raul-Sorin Sorban reserves the right to grant licences to use the Software to third parties.Termination                                                                                                                                                                             
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This EULA agreement is effective from the date you first use the Software and shall continue until terminated.You may terminate it at any time upon written notice to Raul-Sorin Sorban.It will also terminate immediately if you fail to comply with any term of this EULA agreement.Upon such termination, the licenses granted by this EULA agreement will immediately terminate and you agree to stop all access and use of the Software.The provisions that by their nature continue and survive will survive any termination of this EULA agreement.Governing Law                                                                                                                                                                           
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This EULA agreement, and any dispute arising out of or in connection with this EULA agreement, shall be governed by and construed in accordance with the laws of at.*/
// Reference: RusterNET.Core
// Reference: System.Drawing
// Requires: GridAPI
// Requires: ImageLibrary
using CompanionServer;
using Facepunch;
using Humanlights;
using Humanlights.Components;
using Humanlights.Extensions;
using Network;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Oxide.Core;
using Oxide.Core.Libraries;
using Oxide.Core.Libraries.Covalence;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using UnityEngine;
using UnityEngine.Networking;
namespace Oxide.Plugins {
    [Info("RusterNET", "Raul-Sorin Sorban", "4.2.5")]
    [Description("Rust's first social-media network for your enemies and uncles.")]
    public class RusterNET : RustPlugin {
        public static RusterNET Instance {
            get;
            private set;
        }
#region Version
        public string LatestVersion {
            get;
            set;
        }
        public void FetchLatestVersion(Action<string> onFetched) {
            webrequest.Enqueue("https://codefling.com/capi/file-867/?do=apiCall", string.Empty, (code, data) => {
                if (string.IsNullOrEmpty(data)) return;
                var jObject = (JObject)null;
                try {
                    jObject = JObject.Parse(data);
                }
                catch {
                    return;
                }
                onFetched?.Invoke(jObject["file"]["file_version"].ToObject<string>());
            }
            , this);
        }
        public bool IsRunningLatestVersion() {
            return LatestVersion == Version.ToString();
        }
#endregion
#region Pro
        public JObject ProConfig {
            get;
            private set;
        }
        public bool IsPro() {
            return RusterNETPro != null && RusterNETPro.IsLoaded;
        }
        public T GetProConfig<T>(string property, T original) {
            if (ProConfig == null) return original;
            var value = ProConfig[property].Value<T>();
            if (value?.ToString() == "0") return original;
            return string.IsNullOrEmpty(value?.ToString()) ? original : value;
        }
        public void RefreshPro() {
            UnloadPro();
            ProConfig = RusterNETPro.Call<JObject>("GetConfig");
            if (!ProConfig["AppendEmojis"].ToString().ToBool()) Emojis.Clear();
            foreach (var emoji in ProConfig["Emojis"]) {
                var name = emoji["Name"].ToString();
                var shortname = emoji["Shortname"].ToString();
                var iconUrl = emoji["IconUrl"].ToString();
                if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(shortname) && !string.IsNullOrEmpty(iconUrl)) Emojis.Add(new RusterEmoji(name, shortname, iconUrl));
            }
        }
        public void UnloadPro() {
            Emojis.Clear();
            Emojis.AddRange(GetDefaultEmojis());
            ProConfig = null;
        }
#endregion
#region Adverts
        public const bool AdHourlyChange = true;
        public const int AdChance = 3;
        public const int AdPossiblities = 50;
        public const int AdInitialSeed = 103;
        public static int AdPlacementSeed {
            get {
                var date = DateTime.Now;
                var seed = AdInitialSeed + date.Year + date.Month + date.Day;
                if (AdHourlyChange) seed += date.Hour;
                return seed;
            }
        }
#endregion
#region Flea Market
        public Dictionary<string, int> DefaultStackSizes {
            get;
            set;
        }
        = new Dictionary<string, int>();
        public const string FleaGetRoute = @"http://167.86.121.152:8802/rusternet-ms?method=flea.get";
        public const string FleaBuyRoute = @"http://167.86.121.152:8802/rusternet-ms?method=flea.buy";
        public const string FleaVendorsRoute = @"http://167.86.121.152:8802/rusternet-ms?method=flea.vendors";
        public const string DefaultStacksizesUrl = @"https://raw.githubusercontent.com/raulssorban/rusternet-lang/main/default_stacksizes.json";
        public Dictionary<ulong, string[]> VendorPhrases {
            get;
            set;
        }
        = new Dictionary<ulong, string[]>();
        public TimeSince TimeSinceVendorFetch {
            get;
            set;
        }
        = 10f;
        public bool IsInFleaMarket(RusterBrowser browser) {
            return IsInternetOnline && browser.CustomFeed1 == FleaMarketId;
        }
        public RusterFeed GetFleaMarket() {
            if (TimeSinceVendorFetch > 5f) {
                webrequest.Enqueue(FleaVendorsRoute, string.Empty, (int statusCode, string data) => {
                    VendorPhrases.Clear();
                    var vendors = JsonConvert.DeserializeObject<JToken>(data);
                    foreach (var vendor in vendors) {
                        var user = Data.GetUser(vendor["Id"].ToObject<ulong>());
                        user.IsBot = true;
                        user.CustomDisplayName = vendor["PublicName"].ToObject<string>();
                        user.CurrentDisplayName = vendor["FullName"].ToObject<string>();
                        user.AvatarUrl = vendor["AvatarUrl"].ToObject<string>();
                        user.AllowBusinessCard = false;
                        if (!VendorPhrases.ContainsKey(user.Id)) VendorPhrases.Add(user.Id, vendor["Phrases"].ToObject<string[]>());
                    }
                }
                , this, RequestMethod.GET);
                TimeSinceVendorFetch = 0f;
            }
            var fleaMarket = Data.GetFeed(FleaMarketId);
            {
                fleaMarket.Title = "Flea Market";
                fleaMarket.BackgroundUrl = "https://cdn.discordapp.com/attachments/844914604080889867/889202161689456670/ruster_fleamarket.png";
                fleaMarket.FeedType = RusterFeed.FeedTypes.Shop;
                fleaMarket.DarkMode = false;
                fleaMarket.EnableCensorship = false;
                fleaMarket.AllowAdverts = true;
                fleaMarket.AllowPurchases = true;
                fleaMarket.AllowRatings = false;
                fleaMarket.AllowRestocking = false;
                fleaMarket.CanFilter = false;
                fleaMarket.ShowHashtags = true;
                fleaMarket.ShowLocation = true;
                fleaMarket.ShowRatings = false;
                fleaMarket.ShowReplies = true;
                fleaMarket.ShowDate = false;
                fleaMarket.IsLocked = true;
                fleaMarket.Hashtags = null;
            }
            return fleaMarket;
        }
        public void FetchFleaMarket(Action<bool> onFetched = null) {
            var fleaMarket = GetFleaMarket();
            webrequest.Enqueue(FleaGetRoute, $@"{{ ""sessionId"": ""{(global::RusterNET.Core.Internet.GetSessionId())}"" }}", (int statusCode, string data) => {
                if (statusCode != 200) {
                    onFetched?.Invoke(false);
                    return;
                }
                var flea = JsonConvert.DeserializeObject<JToken>(data);
                fleaMarket.Posts.Clear();
                foreach (var vendor in VendorPhrases) {
                    var feed = Data.GetFeed(vendor.Key);
                    feed.Posts.Clear();
                    var count = flea.Count(x => x["VendorId"].ToString() == vendor.Key.ToString());
                    var post = new RusterFeed.RusterPost() {
                        Id = RusterFeed.RusterPost.GetId(), UserId = vendor.Key, Content = $"Premium Flea-Market seller.Open replies to browse {count:n0} {count.Plural("item", "items")} for sale.", CanRate = false, Ticks = DateTick.Current.Ticks, IsPinned = true
                    }
                    ;
                    var postFeed = Data.GetFeed(post);
                    postFeed.Posts.Clear();
                    fleaMarket.Posts.Add(post);
                }
                foreach (var listing in flea) {
                    var id = listing["Id"].ToObject<int>();
                    var shortName = listing["ItemShortname"].ToObject<string>();
                    var availableStack = listing["AvailableStack"].ToObject<int>();
                    var totalStack = listing["TotalStack"].ToObject<int>();
                    var definition = ItemManager.FindItemDefinition(shortName);
                    var user = Data.GetUser(listing["VendorId"].ToObject<ulong>());
                    var phrases = VendorPhrases.ContainsKey(user.Id) ? VendorPhrases[user.Id] : new string[] {
                        "Problem?"
                    }
                    ;
                    var phrase = phrases[RandomEx.GetRandomInteger(0, phrases.Length - 1, id)];
                    var feed = Data.GetFeed(user.GetPosts()[0]);
                    var post = new RusterFeed.RusterPost() {
                        Id = id, UserId = user.Id, Content = string.Format(phrase, definition.displayName.english, $"{availableStack:n0}", $"{totalStack:n0}"), MarketplaceListing = new RusterMarketplaceListing {
                            Shortname = shortName, Skin = listing["ItemSkin"].ToObject<ulong>(), Price = (int)(listing["Price"].ToObject<int>() * GetItemAmplifier(shortName)), Amount = totalStack, AmountLeft = availableStack, WholeStack = false, IsPurchased = availableStack <= 0
                        }
                        , CanRate = false, Ticks = DateTick.Current.Ticks, IsPinned = false
                    }
                    ;
                    feed.FeedType = RusterFeed.FeedTypes.Shop;
                    feed.Title = $"{user.GetUsername()}'s Sales";
                    feed.Posts.Add(post);
                    feed.IsLocked = true;
                    feed.ShowReplies = false;
                    if (feed.Hashtags != null) feed.Hashtags.Clear();
                    else feed.Hashtags = new List<RusterHashtag>();
                    foreach (var item in feed.Posts) {
                        if (feed.Hashtags.Any(x => x.Filter == item.MarketplaceListing.Shortname && x.FilterType == RusterHashtag.FilterTypes.ItemShortname)) continue;
                        feed.Hashtags.Add(new RusterHashtag(item.MarketplaceListing.Shortname, RusterHashtag.FilterTypes.ItemShortname) {
                            Instances = feed.Posts.Count(x => x.MarketplaceListing.Shortname == item.MarketplaceListing.Shortname)
                        }
                        );
                    }
                    GetSteamWorkshopIcon(post.MarketplaceListing.Skin, url => {
                        post.PhotoUrl = url;
                    }
                    );
                }
                onFetched?.Invoke(true);
            }
            , this, RequestMethod.PUT);
        }
        public void GetVanillaStackSizes() {
            webrequest.Enqueue(DefaultStacksizesUrl, string.Empty, (int code, string data) => {
                DefaultStackSizes = JsonConvert.DeserializeObject<Dictionary<string, int>>(data);
                Log($"Downloaded vanilla stack sizes.");
            }
            , this);
        }
        [ConsoleCommand("rusterdefaultstacksizes")]
        private void ExportVanillaStackSizes(ConsoleSystem.Arg arg) {
            // if (!arg.IsAdmin) return;
            //
            // var bundles = AssetBundle.GetAllLoadedAssetBundles();
            // foreach (var b in bundles) Puts(b.name);
            //
            // var root = bundles.FirstOrDefault(x => x.name == null || string.IsNullOrEmpty(x.name));
            // var bundle = bundles.FirstOrDefault(x => x.name.Contains("items.preload.bundle"));
            //
            // var definitions = bundle.LoadAllAssets<GameObject>();
            // var originalItemDefinitions = (from x in definitions
            // 							   select x.GetComponent<ItemDefinition>() into x
            // 							   where x != null
            // 							   select x).ToList();
            //
            // var dictionary = new Dictionary<string, int>();
            // foreach (var item in originalItemDefinitions) { dictionary.Add(item.shortname, item.stackable); }
            //
            // OsEx.File.Create($"oxide/temp/default_stacksizes.json", JsonConvert.SerializeObject(dictionary, Formatting.Indented));
            //
            // var appleOriginalDefinition = originalItemDefinitions.FirstOrDefault(x => x.shortname == "apple");
            // Puts(appleOriginalDefinition.stackable.ToString());
            //
            // var appleModifiedDefinition = ItemManager.FindItemDefinition("apple");
            // Puts(appleModifiedDefinition.stackable.ToString());
        }
        public float GetItemAmplifier(string shortName) {
            var original = (float)DefaultStackSizes[shortName];
            var current = (float)ItemManager.FindItemDefinition(shortName).stackable;
            return current.Scale(original, 1000, 1, 37.5f);
        }
#endregion
#region (ma name) GIF
        public System.Drawing.Image[] GetFrames(System.Drawing.Image image, int everyFrame = 1) {
            var frameCount = image.GetFrameCount(System.Drawing.Imaging.FrameDimension.Time);
            var frames = new System.Drawing.Image[frameCount];
            everyFrame = frameCount.Scale(15, 250, 0, 3);
            for (int i = 0; i < frameCount; i++) {
                if (everyFrame != 0 && i % everyFrame != 0) continue;
                image.SelectActiveFrame(System.Drawing.Imaging.FrameDimension.Time, i);
                frames[i] = new System.Drawing.Bitmap(image);
            }
            image.Dispose();
            return frames;
        }
#endregion
#region Skins
        public const string RusterSkinName = "Ruster.NET";
        public const ulong RusterSkinId = 2751157264;
        public const string RusterMarketplace24hAdvertSkinName = "Ruster.NET 24h Advert";
        public const ulong RusterMarketplace24hAdvertSkinId = 2751522930;
        public const string RusterMarketplace1wAdvertSkinName = "Ruster.NET 1w Advert";
        public const ulong RusterMarketplace1wAdvertSkinId = 2751524225;
        public const string RusterBusinessCardSkinName = "{0}'s Ruster.NET Business Card";
        public const ulong RusterBusinessCardSkinId = 2751518631;
        public const string RusterShortFlipbookSkinName = "Ruster.NET Short Flipbook";
        public const ulong RusterShortFlipbookSkinId = 2741149446;
        public const string RusterMediumFlipbookSkinName = "Ruster.NET Medium Flipbook";
        public const ulong RusterMediumFlipbookSkinId = 2741150219;
        public const string RusterLongFlipbookSkinName = "Ruster.NET Long Flipbook";
        public const ulong RusterLongFlipbookSkinId = 2741150823;
        public const string RusterLegitLotteryTicketSkinName = "Ruster.NET Legit Lottery Ticket";
        public const ulong RusterLegitLotteryTicketSkinId = 2747116980;
        public const string RusterLuckyCharmLotteryTicketSkinName = "Ruster.NET Lucky-Charm Lottery Ticket";
        public const ulong RusterLuckyCharmLotteryTicketSkinId = 2747116358;
        public const string RusterIconicLotteryTicketSkinName = "Ruster.NET Iconic Lottery Ticket";
        public const ulong RusterIconicLotteryTicketSkinId = 2747115474;
        public const string RusterGiftCardSkinName = "Ruster.NET {0} Gift Card";
        public const ulong RusterGiftCardSkinId = 2752332299;
#endregion
#region Install
        public const int CommunityFeedId = 0;
        public const int MarketplaceFeedId = 1;
        public const int UserStoreFeedId = 2;
        public const int LotteryStoreFeedId = 3;
        public const int BlackmarketFeedId = 666;
        public const int RedRoomFeedId = 667;
        public const int FleaMarketId = 668;
        public const int ReportGroupId = -400;
        public const int CodeflingBotId = 6969;
        protected WebRequests WebRequest = new WebRequests();
        public void InstallEventCommands() {
            Log($"Installing CUI commands...");
            cmd.AddConsoleCommand(LanguageDialogCmd, this, nameof(LanguageDialog));
            cmd.AddConsoleCommand(LanguageDialogChangeCmd, this, nameof(LanguageDialogChange));
            cmd.AddConsoleCommand(LanguageDialogCloseCmd, this, nameof(LanguageDialogClose));
            cmd.AddConsoleCommand(WithdrawCmd, this, nameof(Withdraw));
            cmd.AddConsoleCommand(RestockAllCmd, this, nameof(RestockAll));
            cmd.AddConsoleCommand(MainFeedChangeCmd, this, nameof(MainFeedChange));
            cmd.AddConsoleCommand(MainDMsCmd, this, nameof(MainDMs));
            cmd.AddConsoleCommand(ChangeHashtagCmd, this, nameof(ChangeHashtag));
            cmd.AddConsoleCommand(HashtagFilterCmd, this, nameof(HashtagFilter));
            cmd.AddConsoleCommand(HashtagFilterSubmitCmd, this, nameof(HashtagFilterSubmit));
            cmd.AddConsoleCommand(HashtagFilterCancelCmd, this, nameof(HashtagFilterCancel));
            cmd.AddConsoleCommand(HashtagFilterChangeCmd, this, nameof(HashtagFilterChange));
            cmd.AddConsoleCommand(AddFriendCmd, this, nameof(AddFriend));
            cmd.AddConsoleCommand(CancelFriendRequestCmd, this, nameof(CancelFriendRequest));
            cmd.AddConsoleCommand(HandleFriendRequestCmd, this, nameof(HandleFriendRequest));
            cmd.AddConsoleCommand(RemoveFriendCmd, this, nameof(RemoveFriend));
            cmd.AddConsoleCommand(CloseCmd, this, nameof(Close));
            cmd.AddConsoleCommand(LikeCmd, this, nameof(Like));
            cmd.AddConsoleCommand(DislikeCmd, this, nameof(Dislike));
            cmd.AddConsoleCommand(VoteCmd, this, nameof(Vote));
            cmd.AddConsoleCommand(NewPostCmd, this, nameof(NewPost));
            cmd.AddConsoleCommand(NewPostCloseCmd, this, nameof(NewPostClose));
            cmd.AddConsoleCommand(NewPostContentCmd, this, nameof(NewPostContent));
            cmd.AddConsoleCommand(NewPostPublishCmd, this, nameof(NewPostPublish));
            cmd.AddConsoleCommand(NewPostAddPictureCmd, this, nameof(NewPostAddPicture));
            cmd.AddConsoleCommand(NewPostAddCassetteCmd, this, nameof(NewPostAddCassette));
            cmd.AddConsoleCommand(NewPostUploadAudioCmd, this, nameof(NewPostUploadAudio));
            cmd.AddConsoleCommand(NewPostUploadAudioCloseCmd, this, nameof(NewPostUploadAudioClose));
            cmd.AddConsoleCommand(NewPostUploadAudioUploadCmd, this, nameof(NewPostUploadAudioUpload));
            cmd.AddConsoleCommand(NewPostUploadAudioTitleChangeCmd, this, nameof(NewPostUploadAudioTitleChange));
            cmd.AddConsoleCommand(NewPostUploadAudioStartTimeChangeCmd, this, nameof(NewPostUploadAudioStartTimeChange));
            cmd.AddConsoleCommand(NewPostUploadAudioUrlChangeCmd, this, nameof(NewPostUploadAudioUrlChange));
            cmd.AddConsoleCommand(NewPostLocationCmd, this, nameof(NewPostLocation));
            cmd.AddConsoleCommand(NewPostPollCmd, this, nameof(NewPostPoll));
            cmd.AddConsoleCommand(NewPostPollCloseCmd, this, nameof(NewPostPollClose));
            cmd.AddConsoleCommand(NewPostPollClearCmd, this, nameof(NewPostPollClear));
            cmd.AddConsoleCommand(NewPostPollDurationCmd, this, nameof(NewPostPollDuration));
            cmd.AddConsoleCommand(NewPostPollAddChoiceCmd, this, nameof(NewPostPollAddChoice));
            cmd.AddConsoleCommand(NewPostPollAddChoiceMoveUpCmd, this, nameof(NewPostPollAddChoiceMoveUp));
            cmd.AddConsoleCommand(NewPostPollAddChoiceMoveDownCmd, this, nameof(NewPostPollAddChoiceMoveDown));
            cmd.AddConsoleCommand(NewPostPollAddChoiceDeleteCmd, this, nameof(NewPostPollAddChoiceDelete));
            cmd.AddConsoleCommand(NewPostSoldWholeStackCmd, this, nameof(NewPostSoldWholeStack));
            cmd.AddConsoleCommand(NewPostSoldItemCmd, this, nameof(NewPostSoldItem));
            cmd.AddConsoleCommand(NewPostSoldRemoveCmd, this, nameof(NewPostSoldRemove));
            cmd.AddConsoleCommand(NewPostSoldPriceChangeCmd, this, nameof(NewPostSoldPriceChange));
            cmd.AddConsoleCommand(NewPostRecordVoiceCmd, this, nameof(NewPostRecordVoice));
            cmd.AddConsoleCommand(FullPostCmd, this, nameof(FullPost));
            cmd.AddConsoleCommand(CloseFullPostCmd, this, nameof(CloseFullPost));
            cmd.AddConsoleCommand(BuyPostCmd, this, nameof(BuyPost));
            cmd.AddConsoleCommand(RestockPostCmd, this, nameof(RestockPost));
            cmd.AddConsoleCommand(PinPostCmd, this, nameof(PinPost));
            cmd.AddConsoleCommand(DeleteCmd, this, nameof(Delete));
            cmd.AddConsoleCommand(NextPageCmd, this, nameof(NextPage));
            cmd.AddConsoleCommand(PrevPageCmd, this, nameof(PrevPage));
            cmd.AddConsoleCommand(StartPageCmd, this, nameof(StartPage));
            cmd.AddConsoleCommand(EndPageCmd, this, nameof(EndPage));
            cmd.AddConsoleCommand(SetPageCmd, this, nameof(SetPage));
            cmd.AddConsoleCommand(CloseNoticeCmd, this, nameof(CloseNotice));
            cmd.AddConsoleCommand(ReadNoticeCmd, this, nameof(ReadNotice));
            cmd.AddConsoleCommand(ProfileCmd, this, nameof(Profile));
            cmd.AddConsoleCommand(CloseProfileCmd, this, nameof(CloseProfile));
            cmd.AddConsoleCommand(CreateProfileCardCmd, this, nameof(CreateProfileCard));
            cmd.AddConsoleCommand(BlockCmd, this, nameof(Block));
            cmd.AddConsoleCommand(DMCmd, this, nameof(DM));
            cmd.AddConsoleCommand(TradeCmd, this, nameof(Trade));
            cmd.AddConsoleCommand(SkinPreviewCmd, this, nameof(SkinPreview));
            cmd.AddConsoleCommand(ReadNotificationCmd, this, nameof(ReadNotification));
            cmd.AddConsoleCommand(ReadAllNotificationsCmd, this, nameof(ReadAllNotifications));
            cmd.AddConsoleCommand(DeleteNotificationCmd, this, nameof(DeleteNotification));
            cmd.AddConsoleCommand(ChangeConversationCmd, this, nameof(ChangeConversation));
            cmd.AddConsoleCommand(ConversationMessageChangeCmd, this, nameof(ConversationMessageChange));
            cmd.AddConsoleCommand(ConversationSendCmd, this, nameof(ConversationSend));
            cmd.AddConsoleCommand(ConversationSendLocationCmd, this, nameof(ConversationSendLocation));
            cmd.AddConsoleCommand(ConversationMessageDeleteCmd, this, nameof(ConversationMessageDelete));
            cmd.AddConsoleCommand(ConversationDeleteCmd, this, nameof(ConversationDelete));
            cmd.AddConsoleCommand(ChangeMessageReactionCmd, this, nameof(ChangeMessageReaction));
            cmd.AddConsoleCommand(UpdateMessageReactionCmd, this, nameof(UpdateMessageReaction));
            cmd.AddConsoleCommand(CloseMessageReactionCmd, this, nameof(CloseMessageReaction));
            cmd.AddConsoleCommand(AcceptConfirmDialogCmd, this, nameof(AcceptConfirmDialog));
            cmd.AddConsoleCommand(CloseConfirmDialogCmd, this, nameof(CloseConfirmDialog));
            cmd.AddConsoleCommand(ConfigDMNotificationsCmd, this, nameof(ConfigDMNotifications));
            cmd.AddConsoleCommand(ConfigPushNotificationsCmd, this, nameof(ConfigPushNotifications));
            cmd.AddConsoleCommand(ConfigFriendsNotificationsCmd, this, nameof(ConfigFriendsNotifications));
            cmd.AddConsoleCommand(ConfigRustPlusNotificationsCmd, this, nameof(ConfigRustPlusNotifications));
            cmd.AddConsoleCommand(CurrentStackChangeCmd, this, nameof(CurrentStackChange));
            cmd.AddConsoleCommand(PlayPostCmd, this, nameof(PlayPost));
            cmd.AddConsoleCommand(PlayMessageCmd, this, nameof(PlayMessage));
            cmd.AddConsoleCommand(StopPostCmd, this, nameof(StopPost));
            cmd.AddConsoleCommand(PinToggleCmd, this, nameof(PinToggle));
            cmd.AddConsoleCommand(EditPostCmd, this, nameof(EditPost));
            cmd.AddConsoleCommand(PinNotificationTrayToggleCmd, this, nameof(PinNotificationTrayToggle));
            cmd.AddConsoleCommand(PostLikesDislikesCmd, this, nameof(PostLikesDislikes));
            cmd.AddConsoleCommand(ClosePostLikesDislikesCmd, this, nameof(ClosePostLikesDislikes));
            cmd.AddConsoleCommand(OpenServerViewerCmd, this, nameof(OpenServerViewer));
            cmd.AddConsoleCommand(CloseViewedServerCmd, this, nameof(CloseViewedServer));
            cmd.AddConsoleCommand(OpenViewedServerCmd, this, nameof(OpenViewedServer));
            cmd.AddConsoleCommand(CloseServerViewerCmd, this, nameof(CloseServerViewer));
            cmd.AddConsoleCommand(OpenStoryCmd, this, nameof(OpenStory));
            cmd.AddConsoleCommand(CloseStoryCmd, this, nameof(CloseStory));
            cmd.AddConsoleCommand(CreateStoryCmd, this, nameof(CreateStory));
            cmd.AddConsoleCommand(DeleteStoryCmd, this, nameof(DeleteStory));
            cmd.AddConsoleCommand(OpenPictureViewerCmd, this, nameof(OpenPictureViewer));
            cmd.AddConsoleCommand(ClosePictureViewerCmd, this, nameof(ClosePictureViewer));
            cmd.AddConsoleCommand(CloseTextEditorCmd, this, nameof(CloseTextEditor));
            cmd.AddConsoleCommand(TextEditorContentCmd, this, nameof(TextEditorContent));
            cmd.AddConsoleCommand(OpenContactsCmd, this, nameof(OpenContacts));
            cmd.AddConsoleCommand(CloseContactsCmd, this, nameof(CloseContacts));
            cmd.AddConsoleCommand(ChangeContactsFilterCmd, this, nameof(ChangeContactsFilter));
            cmd.AddConsoleCommand(NewGroupCmd, this, nameof(NewGroup));
            cmd.AddConsoleCommand(GroupAddCmd, this, nameof(GroupAdd));
            cmd.AddConsoleCommand(GroupPickCmd, this, nameof(GroupPick));
            cmd.AddConsoleCommand(GroupKickCmd, this, nameof(GroupKick));
            cmd.AddConsoleCommand(FleaMarketCmd, this, nameof(FleaMarket));
            cmd.AddConsoleCommand(OpenUserSettingsCmd, this, nameof(OpenUserSettings));
            cmd.AddConsoleCommand(CloseUserSettingsCmd, this, nameof(CloseUserSettings));
            cmd.AddConsoleCommand(UpdateUserSettingsCmd, this, nameof(UpdateUserSettings));
            cmd.AddConsoleCommand(CloseColorPickerCmd, this, nameof(CloseColorPicker));
            cmd.AddConsoleCommand(PickColorPickerCmd, this, nameof(PickColorPicker));
            cmd.AddConsoleCommand(ReportPostCmd, this, nameof(ReportPost));
            cmd.AddConsoleCommand(ReportUserCmd, this, nameof(ReportUser));
            cmd.AddConsoleCommand(OpenCouponEditorCmd, this, nameof(OpenCouponEditor));
            cmd.AddConsoleCommand(CloseCouponEditorCmd, this, nameof(CloseCouponEditor));
            cmd.AddConsoleCommand(SaveCouponEditorCmd, this, nameof(SaveCouponEditor));
            cmd.AddConsoleCommand(ClearCouponEditorCmd, this, nameof(ClearCouponEditor));
            cmd.AddConsoleCommand(SetOptionCouponEditorCmd, this, nameof(SetOptionCouponEditor));
            cmd.AddConsoleCommand(OpenCouponListCmd, this, nameof(OpenCouponList));
            cmd.AddConsoleCommand(CloseCouponListCmd, this, nameof(CloseCouponList));
            cmd.AddConsoleCommand(AddCouponListCmd, this, nameof(AddCouponList));
            cmd.AddConsoleCommand(RemoveCouponListCmd, this, nameof(RemoveCouponList));
            cmd.AddConsoleCommand(OpenTransactionListCmd, this, nameof(OpenTransactionList));
            cmd.AddConsoleCommand(CloseTransactionListCmd, this, nameof(CloseTransactionList));
            cmd.AddConsoleCommand(SwitchViewTransactionListCmd, this, nameof(SwitchViewTransactionList));
            cmd.AddConsoleCommand(RemoveTransactionListCmd, this, nameof(RemoveTransactionList));
            cmd.AddConsoleCommand(OpenPostGifPanelCmd, this, nameof(OpenPostGifPanel));
            cmd.AddConsoleCommand(CloseGifPanelCmd, this, nameof(CloseGifPanel));
            cmd.AddConsoleCommand(NewPostAddGIFCmd, this, nameof(NewPostAddGIF));
            cmd.AddConsoleCommand(UserAvatarCmd, this, nameof(UserAvatar));
            cmd.AddConsoleCommand(SelectUserPhotoListCmd, this, nameof(SelectAvatarList));
            cmd.AddConsoleCommand(CloseUserPhotoListCmd, this, nameof(CloseAvatarList));
            cmd.AddConsoleCommand(OpenBannerListCmd, this, nameof(OpenBannerList));
            cmd.AddConsoleCommand(OpenAvatarListCmd, this, nameof(OpenAvatarList));
            cmd.AddConsoleCommand(OpenFrameListCmd, this, nameof(OpenFrameList));
            cmd.AddConsoleCommand(EditAboutMeCmd, this, nameof(EditAboutMe));
            cmd.AddConsoleCommand(OpenStoreCmd, this, nameof(OpenStore));
            cmd.AddConsoleCommand(SelectUserUsersCmd, this, nameof(SelectUserUsers));
            cmd.AddConsoleCommand(CloseUsersCmd, this, nameof(CloseUsers));
            cmd.AddConsoleCommand(OpenGiftBasketCmd, this, nameof(OpenGiftBasket));
            cmd.AddConsoleCommand(ConversationTradeCmd, this, nameof(ConversationTrade));
            cmd.AddConsoleCommand(CloseModalCmd, this, nameof(CloseModal));
            cmd.AddConsoleCommand(SubmitModalCmd, this, nameof(SubmitModal));
            cmd.AddConsoleCommand(ValueModalCmd, this, nameof(ValueModal));
            cmd.AddConsoleCommand(ResetValueModalCmd, this, nameof(ResetValueModal));
        }
        public void InstallUserCommands() {
            Log($"Installing user commands...");
            cmd.AddConsoleCommand(Config.Commands.RusterCommand, this, nameof(Ruster));
            cmd.AddChatCommand(Config.Commands.RusterLoginCommand, this, nameof(RusterLogin));
            cmd.AddChatCommand(Config.Commands.LaunchRuster, this, nameof(LaunchRuster));
            cmd.AddConsoleCommand(Config.Commands.LaunchRuster, this, nameof(LaunchRuster));
            cmd.AddChatCommand(Config.Commands.CloseRuster, this, nameof(CloseRuster));
            cmd.AddChatCommand(Config.Commands.GetRuster, this, nameof(GetRuster));
            cmd.AddChatCommand(Config.Commands.Get24hAdvert, this, nameof(GetRuster24hAdvert));
            cmd.AddChatCommand(Config.Commands.Get1wAdvert, this, nameof(GetRuster1wAdvert));
            cmd.AddChatCommand(Config.Commands.RusterAllNotifications, this, nameof(RusterAllNotifications));
            cmd.AddChatCommand(Config.Commands.RusterPushNotifications, this, nameof(RusterPushNotifications));
            cmd.AddChatCommand(Config.Commands.RusterFriendsNotifications, this, nameof(RusterFriendsNotifications));
            cmd.AddChatCommand(Config.Commands.RusterRustPlusNotifications, this, nameof(RusterRustPlusNotifications));
            cmd.AddChatCommand(Config.Commands.RusterChatNotifications, this, nameof(RusterChatNotifications));
            cmd.AddChatCommand(Config.Commands.PinRusterFM, this, nameof(PinRusterFM));
            cmd.AddChatCommand(Config.Commands.RusterRatio, this, nameof(RusterRatio));
        }
        public void InitializeAdvertValidator(bool doTimer = true) {
            if (doTimer) Log($"Initializing advert validator...");
            var action = new Action(() => {
                foreach (var user in Data.Users) {
                    try {
                        foreach (var post in user.GetAdvertPosts()) {
                            try {
                                if (post.IsOverdue()) {
                                    var feed = post.GetFeed();
                                    var reason = "";
                                    if (Config.Marketplace.RefundOnExpiredAdvert) post.RefundListing();
                                    feed.Delete(user, post.Id, out reason);
                                }
                            }
                            catch {
                            }
                        }
                    }
                    catch {
                    }
                }
            }
            );
            action?.Invoke();
            if (doTimer) timer.Every(ConVar.Server.saveinterval, action);
        }
        public void InitializeStoryValidator(bool doTimer = true) {
            if (doTimer) Log($"Initializing Story validator...");
            var action = new Action(() => {
                foreach (var story in Data.Stories.ToArray()) {
                    try {
                        if (story.IsExpired(overHours : 24)) {
                            var author = story.GetUser();
                            author.CreateNotification($"Your story has expired.It has reached {story.Views.Count:n0} {story.Views.Count.Plural("view", "views")}.", RusterUserNotification.NotificationTypes.Story);
                            Data.DeleteStory(story.Id);
                        }
                    }
                    catch {
                    }
                }
            }
            );
            action?.Invoke();
            if (doTimer) timer.Every(ConVar.Server.saveinterval, action);
        }
        public void InitializeLotteryValidator(bool doTimer = true) {
            if (doTimer) Log($"Initializing Lottery validator...");
            var action = new Action(() => {
                if (LotteryEvent == null) return;
                var lottery = LotteryEvent;
                var timeLeft = Config.Lottery.EventDuration - lottery.TimeSinceStart;
                if (lottery.TimeSinceStart > Config.Lottery.EventDuration) {
                    lottery.EndEvent();
                    return;
                }
                if (timeLeft <= 0) return;
                if (timeLeft <= 10f) {
                    Print($"Lottery results in <color=orange>{Humanlights.Extensions.TimeEx.Format(timeLeft, false).ToLower()}</color>.");
                }
                else if (timeLeft <= 30f) {
                    Puts($"{(int)timeLeft % 5}");
                    if ((int)timeLeft % 5 == 0) Print($"Lottery results in <color=orange>{Humanlights.Extensions.TimeEx.Format(timeLeft, false).ToLower()}</color>.");
                }
            }
            );
            action?.Invoke();
            if (doTimer) timer.Every(1f, action);
        }
        public void InitializeNotificationValidator() {
            Log($"Initializing notification validator...");
            var action = new Action(() => {
                foreach (var user in Data.Users) {
                    foreach (var notification in user.Notifications.ToArray()) {
                        try {
                            if (notification.IsOverdue()) {
                                user.DeleteNotification(notification.Id);
                            }
                        }
                        catch {
                        }
                    }
                }
            }
            );
            action?.Invoke();
            timer.Every(ConVar.Server.saveinterval, action);
        }
        public void InitializeDefaultUsers() {
            Log($"Initializing default users...");
            Data.GetAdvertsAccount();
            Data.GetLotteryAccount();
        }
        public void InstallDefaultFeeds() {
            Log($"Initializing default feeds...");
            var marketplace = Data.GetMarketplaceFeed();
            {
                marketplace.Title = "{marketplace}";
                marketplace.BackgroundUrl = RusterBrowser.MarketplaceBackgroundUrl;
                marketplace.FeedType = RusterFeed.FeedTypes.Shop;
                marketplace.AllowAdverts = false;
            }
            var userItems = Data.GetUserStoreFeed();
            {
                userItems.Title = "Profile Store";
                userItems.BackgroundUrl = RusterBrowser.UserItemsBackgroundUrl;
                userItems.FeedType = RusterFeed.FeedTypes.Shop;
                userItems.AllowAdverts = false;
                userItems.IsLocked = true;
                userItems.ShowDate = false;
                userItems.AllowRatings = false;
                userItems.AllowDeleting = false;
                userItems.DisableFleaMarket = true;
                userItems.ShowHashtags = false;
                userItems.Posts.Clear();
                foreach (var avatar in Config.License.Items.Where(x => x.ItemType == RusterLicensedItem.ItemTypes.Avatar)) {
                    var post = RusterFeed.RusterPost.Create(Data.GetAdvertsAccount(), $"Have a look at this avatar! It might be the right one for you.");
                    post.PhotoUrl = avatar.Value;
                    post.EmbedPhoto = true;
                    post.CanRate = false;
                    post.MarketplaceListing = new RusterMarketplaceListing {
                        Shortname = "photo", CustomName = $"{avatar.DisplayName} Avatar", Amount = 1, AmountLeft = 1, WholeStack = true, IsPurchased = false, Price = avatar.Price
                    }
                    ;
                    post.Advert = new RusterFeed.RusterPost.RusterAdvert {
                        DurationHours = 24
                    }
                    ;
                    userItems.Posts.Add(post);
                }
                foreach (var banner in Config.License.Items.Where(x => x.ItemType == RusterLicensedItem.ItemTypes.Frame)) {
                    var post = RusterFeed.RusterPost.Create(Data.GetAdvertsAccount(), $"Have a look at this profile avatar frame! It might be the right one for you.");
                    post.PhotoUrl = banner.Value;
                    post.EmbedPhoto = true;
                    post.CanRate = false;
                    post.MarketplaceListing = new RusterMarketplaceListing {
                        Shortname = "photo", CustomName = $"{banner.DisplayName} Frame", Amount = 1, AmountLeft = 1, WholeStack = true, IsPurchased = false, Price = banner.Price
                    }
                    ;
                    post.Advert = new RusterFeed.RusterPost.RusterAdvert {
                        DurationHours = 24
                    }
                    ;
                    userItems.Posts.Add(post);
                }
                foreach (var banner in Config.License.Items.Where(x => x.ItemType == RusterLicensedItem.ItemTypes.Banner)) {
                    var post = RusterFeed.RusterPost.Create(Data.GetAdvertsAccount(), $"Have a look at this profile banner! It might be the right one for you.");
                    post.PhotoUrl = banner.Value;
                    post.EmbedPhoto = true;
                    post.EmbedPhotoRatio = 0.75f;
                    post.CanRate = false;
                    post.MarketplaceListing = new RusterMarketplaceListing {
                        Shortname = "photo", CustomName = $"{banner.DisplayName} Banner", Amount = 1, AmountLeft = 1, WholeStack = true, IsPurchased = false, Price = banner.Price
                    }
                    ;
                    post.Advert = new RusterFeed.RusterPost.RusterAdvert {
                        DurationHours = 24
                    }
                    ;
                    userItems.Posts.Add(post);
                }
            }
            var lotteryItems = Data.GetLotteryStoreFeed();
            {
                lotteryItems.Title = "Lottery Store";
                lotteryItems.BackgroundUrl = RusterBrowser.UserItemsBackgroundUrl;
                lotteryItems.FeedType = RusterFeed.FeedTypes.Shop;
                lotteryItems.AllowAdverts = false;
                lotteryItems.IsLocked =
// ... [Code preview truncated due to length. Full source in attached file] ...

Автор
15FPS
Скачиваний
0
Просмотры
1
Первый выпуск
Обновление
Оценка
0.00 звёзд 0 оценок
Сверху