Exemple #1
0
        public static void Update(DiscordStatus status, int rows = 0)
        {
            if (!UserSettings.Current.RichPresence)
            {
                return;
            }
            if (!initialized && status != DiscordStatus.Disabled)
            {
                Initialize();
            }
            switch (status)
            {
            case DiscordStatus.Idle:
                client.SetPresence(new RichPresence()
                {
                    State      = "Not breaking anything",
                    Timestamps = Timestamps.Now
                });
                break;

            case DiscordStatus.Breaking:
                client.SetPresence(new RichPresence()
                {
                    State   = UserSettings.Current.DebugMode ? "Debugging." : "Breaking.",
                    Details = UserSettings.Current.DebugMode ? null : "Broke " + rows.ToString() + " rows so far.",
                    Assets  = new Assets
                    {
                        //LargeImageKey = App.Sprites[UserSettings.Current.SelectedBlock].AssetName
                    },
                    Timestamps = Timestamps.Now
                });
                break;

            case DiscordStatus.Advancing:
                client.SetPresence(new RichPresence()
                {
                    State   = "Moving to the next row.",
                    Details = "Broke " + rows.ToString() + " rows so far.",
                    Assets  = new Assets
                    {
                        //LargeImageKey = App.Sprites[UserSettings.Current.SelectedBlock].AssetName
                    },
                    Timestamps = Timestamps.Now
                });
                break;

            case DiscordStatus.Debugging:
                client.SetPresence(new RichPresence()
                {
                    State      = "Testing detection.",
                    Timestamps = Timestamps.Now
                });
                break;
            }
        }
Exemple #2
0
        private void Reload()
        {
            timer?.Dispose();

            IConfigurationSection section = Config.GetSection("status");
            const string          format  = @"h\:mm";

            minInterval = TimeSpan.ParseExact(section["interval_min"], format, null);
            maxInterval = TimeSpan.ParseExact(section["interval_max"], format, null);
            if (minInterval <= TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException("status:interval_min", "Interval is too low!");
            }
            if (maxInterval < minInterval)
            {
                throw new ArgumentOutOfRangeException("status:interval_max", "Max interval is less than min interval!");
            }

            string[] statusArray = section.GetArray("release");
            if (Debugger.IsAttached)
            {
                string[] debugStatusArray = section.GetArray("debug");
                if (debugStatusArray.Length != 0)
                {
                    statusArray = debugStatusArray;
                }
            }

            ActivityType         activity = ActivityType.Playing;
            List <DiscordStatus> statuses = new List <DiscordStatus>();

            foreach (string status in statusArray)
            {
                if (status.StartsWith("$") && status.EndsWith("$"))
                {
                    activity = (ActivityType)Enum.Parse(typeof(ActivityType), status.Substring(1, status.Length - 2), true);
                }
                else
                {
                    statuses.Add(new DiscordStatus(activity, status));
                }
            }
            this.statuses = statuses.ToArray();

            DiscordStatus firstStatus = statuses[0];

            hasMultipleStatuses = statuses.Skip(1).Any(s => s != firstStatus);
            OnTimerEllapsed();
        }
Exemple #3
0
        /// <summary>
        /// Chooses a new *different* status to use.
        /// </summary>
        private void ChooseNewStatus()
        {
            if (!hasMultipleStatuses)
            {
                currentStatus = statuses[0];
                return;
            }
            DiscordStatus newStatus = currentStatus;

            do
            {
                newStatus = statuses[rng.Next(statuses.Length)];
            } while (newStatus == currentStatus);

            currentStatus = newStatus;
        }
Exemple #4
0
 internal UserNode(string json) : base(json)
 {
     Status = GetStatus(GetString("status"));
 }
 public virtual async Task SetGameAsync(int shardId, DiscordStatus status)
 {
     await Gateway.SendAsync(shardId, GatewayOpcode.StatusUpdate, status);
 }
Exemple #6
0
 /// <summary>
 /// Updates the current status.
 /// </summary>
 /// <returns></returns>
 private async Task SetStatus(DiscordStatus status)
 {
     await Client.SetGameAsync(status.Name, type : status.Activity).ConfigureAwait(false);
 }