public async Task SendMessage(AnnouncementMessage message)
        {
            //additional business logic

            await this.hubContext.Clients.All.SendAsync("messageReceivedFromApi", message);

            //additional business logic
        }
Ejemplo n.º 2
0
    public static AnnouncementMessage SendToAll(string text)
    {
        AnnouncementMessage msg = new AnnouncementMessage {
            Text = text
        };

        msg.SendToAll();

        return(msg);
    }
        public override async Task PlaytestStartingInTask(RconService rconService, SrcdsLogService srcdsLogService,
                                                          AnnouncementMessage announcementMessage)
        {
            await base.PlaytestStartingInTask(rconService, srcdsLogService, announcementMessage);

            if (_dataService.RSettings.ProgramSettings.Debug)
            {
                _ = _log.LogMessage("TF2 class PlaytestStartingInTask", false, color: LOG_COLOR);
            }
        }
        private void WindowSize_Changed(object sender, SizeChangedEventArgs e)
        {
            DoubleAnimation doubleAnimation = new DoubleAnimation();

            doubleAnimation.From           = Marquee.ActualWidth;
            doubleAnimation.To             = -AnnouncementMessage.ActualWidth;
            doubleAnimation.RepeatBehavior = RepeatBehavior.Forever;
            doubleAnimation.Duration       = new Duration(TimeSpan.Parse("0:0:20"));
            AnnouncementMessage.BeginAnimation(Canvas.LeftProperty, doubleAnimation);
        }
Ejemplo n.º 5
0
    private static void AnnounceNewPlayer(ConnectedPlayer newPlayer)
    {
        if (newPlayer.Job == JobType.SYNDICATE)
        {
            return;
        }
        var chatEvent = new ChatEvent($"{newPlayer.Job.JobString()} {newPlayer.Name} has arrived at the station. " +
                                      $"Have a pleasant day! Try not to die...", ChatChannel.System, true);

        AnnouncementMessage.SendToAll(chatEvent.message);
        ChatRelay.Instance.AddToChatLogServer(chatEvent);
    }
Ejemplo n.º 6
0
    private static void AnnounceNewPlayer(ConnectedPlayer newPlayer)
    {
        if (newPlayer.Job == JobType.SYNDICATE)
        {
            return;
        }

        var msg = $"{newPlayer.Job.JobString()} {newPlayer.Name} has arrived at the station. " +
                  $"Have a pleasant day! Try not to die...";

        Chat.AddSystemMsgToChat($"<color=white>{msg}</color>", MatrixManager.MainStationMatrix);
        AnnouncementMessage.SendToAll(msg);
    }
        public virtual async Task PlaytestStartingTask(RconService rconService, SrcdsLogService srcdsLogService,
                                                       AnnouncementMessage announcementMessage)
        {
            if (_dataService.RSettings.ProgramSettings.Debug)
            {
                _ = _log.LogMessage("Base class PlaytestStartingTask", false, color: LOG_COLOR);
            }

            _ = rconService.WakeRconServer(ServerLocation);

            var mentionRole = TesterRole;

            //Handle comp or casual
            if (IsCasual)
            {
                await rconService.RconCommand(ServerLocation,
                                              $"sv_password {_dataService.RSettings.General.CasualPassword}");
            }
            else
            {
                mentionRole = _dataService.CompetitiveTesterRole;
            }


            //Skip the alert.
            if (!_dataService.GetStartAlertStatus())
            {
                _dataService.SetStartAlert(true);
                return;
            }


            var unsubInfo = Game.ToString();

            if (!IsCasual)
            {
                unsubInfo = "comp";
            }

            await TesterRole.ModifyAsync(x => { x.Mentionable = true; });

            await TestingChannel.SendMessageAsync($"Heads up {mentionRole.Mention}! " +
                                                  "There is a playtest starting __now__!" +
                                                  $"\nType `>playtester {unsubInfo}` to stop getting {unsubInfo} playtest notifications.",
                                                  embed : announcementMessage.CreatePlaytestEmbed(this, true, AnnouncementMessage.Id));

            await TesterRole.ModifyAsync(x => { x.Mentionable = false; });
        }
Ejemplo n.º 8
0
    public static AnnouncementMessage SendToAll(string text)
    {
        AnnouncementMessage msg = new AnnouncementMessage {
            Text = text
        };

//		AnnouncementMessage msg = new AnnouncementMessage();
//		MaryTTS.Instance.Synthesize( text, bytes => {
//			msg.Sound = bytes;
//			msg.SendToAll();
//		} );

        msg.SendToAll();

        return(msg);
    }
        public override async Task PlaytestStartingInTask(RconService rconService, SrcdsLogService srcdsLogService
                                                          , AnnouncementMessage announcementMessage)
        {
            await base.PlaytestStartingInTask(rconService, srcdsLogService, announcementMessage);

            if (_dataService.RSettings.ProgramSettings.Debug)
            {
                _ = _log.LogMessage("CSGO class PlaytestStartingInTask", false, color: LOG_COLOR);
            }

            var embed = new EmbedBuilder().WithAuthor(CleanedTitle)
                        .AddField("Connect Information", $"`connect {ServerLocation}; password {CompPassword}`")
                        .WithColor(new Color(55, 55, 165));

            if (!IsCasual)
            {
                foreach (var creator in Creators)
                {
                    try
                    {
                        var user = _dataService.GetSocketGuildUser(creator.Id);
                        await user.AddRoleAsync(_dataService.ComptesterPlaytestCreator);
                    }
                    catch
                    {
                    }

                    //Try to DM them connect information
                    try
                    {
                        await creator.SendMessageAsync(embed : embed.Build());
                    }
                    catch
                    {
                    }
                }

                await _dataService.CompetitiveTestingChannel.SendMessageAsync(embed : embed.Build());

                await rconService.RconCommand(ServerLocation, $"sv_password {CompPassword}");
            }
        }
        public virtual async Task PlaytestStartingInTask(RconService rconService, SrcdsLogService srcdsLogService,
                                                         AnnouncementMessage announcementMessage)
        {
            if (_dataService.RSettings.ProgramSettings.Debug)
            {
                _ = _log.LogMessage("Base class PlaytestStartingInTask", false, color: LOG_COLOR);
            }

            //Ensure server is awake and RCON connection is established. Run other things while waking server
            _ = rconService.WakeRconServer(ServerLocation);

            //Start asking the server for player counts.
            _dataService.SetIncludePlayerCount(true);
            //Start asking for player counts
            JobManager.AddJob(
                async() => await rconService.GetPlayCountFromServer(ServerLocation),
                s => s.WithName("[QueryPlayerCount]").ToRunEvery(60).Seconds());

            //Figure out how far away from start we are
            string countdownString = null;
            var    countdown       = StartDateTime.GetValueOrDefault().Subtract(DateTime.Now);

            if (StartDateTime.GetValueOrDefault().CompareTo(DateTime.Now) < 0)
            {
                countdownString = $"Started: {countdown:h\'H \'m\'M\'} ago!";
            }
            else
            {
                countdownString = countdown.ToString("d'D 'h'H 'm'M'").TrimStart(' ', 'D', 'H', '0');
            }

            await rconService.RconCommand(ServerLocation, "sv_cheats 0");

            var mentionRole = TesterRole;

            //Handle comp or casual
            if (IsCasual)
            {
                await rconService.RconCommand(ServerLocation,
                                              $"sv_password {_dataService.RSettings.General.CasualPassword}");
            }
            else
            {
                mentionRole = _dataService.CompetitiveTesterRole;
            }

            //Skip the alert.
            if (!_dataService.GetStartAlertStatus())
            {
                _dataService.SetStartAlert(true);
                return;
            }

            var unsubInfo = Game.ToString();

            if (!IsCasual)
            {
                unsubInfo = "comp";
            }

            await TesterRole.ModifyAsync(x => { x.Mentionable = true; });

            await TestingChannel.SendMessageAsync($"Heads up {mentionRole.Mention}! " +
                                                  $"There is a playtest starting in {countdownString}." +
                                                  $"\nType `>playtester {unsubInfo}` to manage {unsubInfo} playtest notifications.",
                                                  embed : announcementMessage.CreatePlaytestEmbed(this, true, AnnouncementMessage.Id));

            await TesterRole.ModifyAsync(x => { x.Mentionable = false; });

            //DM users about their test
            foreach (var creator in Creators)
            {
                try
                {
                    await creator.SendMessageAsync(
                        $"Don't forget that you have a playtest for __**{CleanedTitle}**__ in __**{countdownString}**__");
                }
                catch
                {
                    //Could not DM creator about their test.
                }
            }
        }
        public override async Task PlaytestStartingTask(RconService rconService,
                                                        SrcdsLogService srcdsLogService, AnnouncementMessage announcementMessage)
        {
            await base.PlaytestStartingTask(rconService, srcdsLogService, announcementMessage);

            if (_dataService.RSettings.ProgramSettings.Debug)
            {
                _ = _log.LogMessage("CSGO class PlaytestStartingTask", false, color: LOG_COLOR);
            }

            if (!IsCasual)
            {
                await rconService.RconCommand(ServerLocation,
                                              $"sv_password {CompPassword}");
            }
        }
Ejemplo n.º 12
0
 public async Task SendMessageToGroup(string groupName, AnnouncementMessage message)
 {
     await Clients.Group(groupName).SendAsync("groupMessage", message);
 }
Ejemplo n.º 13
0
 public async Task BroadcastAsync(AnnouncementMessage message)
 {
     await Clients.All.SendAsync("messageReceivedFromHub", message);
 }