Exemplo n.º 1
0
        public ServerListPageViewModel(Models.DiscordContext discordContext, INavigationService navService)
        {
            _DiscordContext    = discordContext;
            _NavigationService = navService;

            Guilds = _DiscordContext.Guilds;
        }
Exemplo n.º 2
0
        public LoggedInProcessPageViewModel(Models.DiscordContext dicordContext, INavigationService navService)
        {
            _NavigationService = navService;
            _DicordContext     = dicordContext;

            Token = _DicordContext.DiscordAccessToken;
            LoginProcessStatus = new ReactiveProperty <string>();
        }
Exemplo n.º 3
0
        public VoiceChannelStatusViewModel(Models.DiscordContext discordContext, Models.AudioPlaybackManager audioManager, INavigationService navService)
        {
            DiscordContext    = discordContext;
            AudioManager      = audioManager;
            NavigationService = navService;

            IsSpeakerMute_Internal = AudioManager.ToReactivePropertyAsSynchronized(x => x.IsSpeakerMute);
            IsMicMute_Internal     = AudioManager.ToReactivePropertyAsSynchronized(x => x.IsMicMute);

            IsSpeakerMute = IsSpeakerMute_Internal
                            .ToReadOnlyReactiveProperty();

            // リアルスピーカーミュートまたは内部マイクミュートの場合、
            // リアルマイクミュートがオンになる
            IsMicMute = Observable.CombineLatest(
                IsSpeakerMute,
                IsMicMute_Internal
                )
                        .Select(x => x.Any(y => y))
                        .ToReadOnlyReactiveProperty();

            IsConnectVoiceChannel = DiscordContext
                                    .ObserveProperty(x => x.CurrentVoiceChannel)
                                    .Select(x => x != null)
                                    .ToReadOnlyReactiveProperty();

            CurrentVoiceChannelName = DiscordContext
                                      .ObserveProperty(x => x.CurrentVoiceChannel)
                                      .Select(x => x?.Name ?? "")
                                      .ToReadOnlyReactiveProperty();

            CurrentServerName = DiscordContext
                                .ObserveProperty(x => x.CurrentVoiceChannel)
                                .Select(x => x?.Guild.Name ?? "")
                                .ToReadOnlyReactiveProperty();

            InputDeviceState = AudioManager.ObserveProperty(x => x.InputDeviceState)
                               .ToReadOnlyReactiveProperty();
            HasMicError = InputDeviceState
                          .Select(x => x != Models.InputDeviceState.Avairable)
                          .ToReadOnlyReactiveProperty();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Content"/> class.
        /// </summary>
        /// <param name="outcome">
        /// The outcome.
        /// </param>
        /// <param name="settings">
        /// The settings.
        /// </param>
        public Content(
            SlaveReportsExtension.Outcome outcome,
            Models.UserSettings settings, Models.DiscordContext context)
            : base(outcome, settings, context)
        {
            var denialtext = "please don't break the Bot";

            switch (outcome)
            {
            case SlaveReportsExtension.Outcome.Task:
                denialtext   = "then spin again";
                this.Outcome = SlaveReportsExtension.Outcome.Task;
                break;

            case SlaveReportsExtension.Outcome.Denial:
                denialtext      = "deny your o****m";
                this.DenialTime = new TimeSpan(8, 0, 0);
                this.Outcome    = SlaveReportsExtension.Outcome.Denial;
                break;

            case SlaveReportsExtension.Outcome.Ruin:
                denialtext   = "ruin your o****m";
                this.Outcome = SlaveReportsExtension.Outcome.Ruin;
                break;

            case SlaveReportsExtension.Outcome.O****m:
                denialtext   = "enjoy a full o****m";
                this.Outcome = SlaveReportsExtension.Outcome.O****m;
                break;

            case SlaveReportsExtension.Outcome.Denial | SlaveReportsExtension.Outcome.Task:
                var chance = Helpers.RandomGenerator.RandomInt(0, 9);
                if (chance < 5)
                {
                    denialtext      = "deny your o****m";
                    this.DenialTime = new TimeSpan(8, 0, 0);
                    this.Outcome    = SlaveReportsExtension.Outcome.Denial;
                }
                else
                {
                    denialtext   = "then spin again";
                    this.Outcome = SlaveReportsExtension.Outcome.Task;
                }

                break;
            }

            Link link;

            if (this.Outcome == SlaveReportsExtension.Outcome.Task)
            {
                link = this.GetLinkFromRandomTumblr(this.GetPostCount());
            }
            else
            {
                List <Link> links = Link.LoadAll().Result;

                var randomLinkNr = Helpers.RandomGenerator.RandomInt(0, links.Count);

                if (links.Count <= randomLinkNr)
                {
                    link = new Link()
                    {
                        CreatorName = "Exception",
                        FileName    = "An Exception Occured. Sorry.",
                        Type        = Link.ContentType.Picture,
                        Url         = "https://Exception.com"
                    };
                }
                else
                {
                    link = links[randomLinkNr];
                }
            }

            var fullSentence = string.Empty;

            switch (link.Type)
            {
            case Link.ContentType.Video:
                fullSentence = $"Watch {link.CreatorName}' JOI and {denialtext}";
                break;

            case Link.ContentType.Picture:
                fullSentence = $"Edge to {link.CreatorName}' Picture and {denialtext}";
                break;
            }

            var rerollIn = string.Empty;

            if (this.Outcome != SlaveReportsExtension.Outcome.Task)
            {
                rerollIn             = "You are not allowed to re-roll for now.";
                this.WheelLockedTime = new TimeSpan(8, 0, 0);
            }

            this.Text = $"{fullSentence}.{rerollIn}\n" + $"{link.Url}\n";

            var builder = new DiscordEmbedBuilder
            {
                Title       = "Click here.",
                Description = fullSentence,
                Footer      = new DiscordEmbedBuilder.EmbedFooter()
                {
                    Text = rerollIn
                },
                Url   = link.Url,
                Color = link.Type == Link.ContentType.Picture
                                                              ? new DiscordColor("#42f483")
                                                              : new DiscordColor("#acf441"),
                Author = new DiscordEmbedBuilder.EmbedAuthor()
                {
                    Name = link.CreatorName
                }
            };

            if (link.Type == Link.ContentType.Picture)
            {
                builder.ImageUrl = link.Url;
            }

            this.Embed = builder.Build();
        }