public void SendMessage(ChatRelayMessage message)
 {
     try
     {
         if (message.Source != SaySource.Zk)
         {
             server.GhostSay(message.ToSay());
         }
     }
     catch (Exception ex)
     {
         Trace.TraceWarning("Error relaying message to Zkls: {0}", ex);
     }
 }
Beispiel #2
0
        private void OnAnySourceMessage(IChatRelaySource source, ChatRelayMessage msg)
        {
            if (channels.Contains(msg.Channel))
            {
                if (msg.Message.StartsWith("!names"))
                {
                    var users = new List <string>();
                    foreach (var s in sources.Where(x => x != source))
                    {
                        users.AddRange(s.GetUsers(msg.Channel));
                    }
                    users = users.Distinct().OrderBy(x => x).ToList();

                    source.SendPm(msg.User, string.Join("\n", users));
                }
                else if (msg.Message.StartsWith("!games"))
                {
                    var sb = new StringBuilder();
                    sb.AppendFormat("MatchMaker queue {0}\n", string.Join(", ", server.MatchMaker.GetQueueCounts().Select(x => $"{x.Key}: {x.Value}")));
                    sb.Append(string.Join("\n",
                                          server.Battles.Values.Where(x => x != null)
                                          .OrderByDescending(x => x.NonSpectatorCount)
                                          .Select(x => $"{x.Mode.Description()} {x.NonSpectatorCount}+{x.SpectatorCount}/{x.MaxPlayers} {x.MapName} {x.Title}")));

                    source.SendPm(msg.User, sb.ToString());
                }
                else if (restrictedChannels.Contains(msg.Channel))
                {
                    foreach (var s in restrictedSources.Where(x => x != source))
                    {
                        s.SendMessage(msg);
                    }
                }
                else
                {
                    foreach (var s in sources.Where(x => x != source))
                    {
                        s.SendMessage(msg);
                    }
                }
            }
        }
Beispiel #3
0
 public void SendMessage(ChatRelayMessage msg)
 {
     try
     {
         if (msg.Source != SaySource.Spring)
         {
             if (msg.User != GlobalConst.NightwatchName)
             {
                 SpringTas.Say(TasClient.SayPlace.Channel, msg.Channel, string.Format("<{0}> {1}", msg.User, msg.Message), msg.IsEmote);
             }
             else
             {
                 SpringTas.Say(TasClient.SayPlace.Channel, msg.Channel, msg.Message, msg.IsEmote);
             }
         }
     }
     catch (Exception ex)
     {
         Trace.TraceWarning("Error sending chat message to spring: {0}", ex);
     }
 }
Beispiel #4
0
 public void SendMessage(ChatRelayMessage m)
 {
     try
     {
         if (m.Source != source)
         {
             if (m.User != GlobalConst.NightwatchName)
             {
                 GetChannel(m.Channel)?.SendMessage($"<{m.User}> {m.Message}");
             }
             // don't relay extra "nightwatch" if it is self relay
             else
             {
                 GetChannel(m.Channel)?.SendMessage(m.Message);
             }
         }
     }
     catch (Exception ex)
     {
         Trace.TraceWarning("Error sending discord message: {0}", ex);
     }
 }