SendChannelMessage() public static method

public static SendChannelMessage ( [ line ) : void
line [
return void
Example #1
0
        static void HandleClients(string userNick, string cmdArgs)
        {
            var visiblePlayers = Server.Players.Where(p => !p.Info.IsHidden)
                                 .OrderBy(p => p, PlayerListSorter.Instance).ToArray();

            Dictionary <string, List <Player> > clients = new Dictionary <string, List <Player> >();

            foreach (var p in visiblePlayers)
            {
                string appName = p.ClientName;
                if (string.IsNullOrEmpty(appName))
                {
                    appName = "(unknown)";
                }

                List <Player> usingClient;
                if (!clients.TryGetValue(appName, out usingClient))
                {
                    usingClient      = new List <Player>();
                    clients[appName] = usingClient;
                }
                usingClient.Add(p);
            }

            IRC.SendChannelMessage(Bold + "Players using:");
            foreach (var kvp in clients)
            {
                IRC.SendChannelMessage("  " + Bold + "{0}" + Reset + ": {1}",
                                       kvp.Key, kvp.Value.JoinToClassyString());
            }
        }
Example #2
0
        static void HandleTime(string userNick, string name)
        {
            if (name == null)
            {
                IRC.SendChannelMessage("Server has been up for: " + Bold + DateTime.UtcNow.Subtract(Server.StartTime).ToMiniString());
                return;
            }
            PlayerInfo info = PlayerDB.FindPlayerInfoExact(name);

            if (info == null)
            {
                IRC.SendChannelMessage("No player found with name \"" + Bold + name + Reset + "\"");
                return;
            }

            if (info.IsOnline)
            {
                TimeSpan idle = info.PlayerObject.IdleTime;
                IRC.SendChannelMessage("Player " + Bold + "{0}" + Reset + " has spent a total of: " + Bold + "{1:F1}" + Reset +
                                       " hours (" + Bold + "{2:F1}" + Reset + " hours this session{3}",
                                       info.ClassyName, (info.TotalTime + info.TimeSinceLastLogin).TotalHours,
                                       info.TimeSinceLastLogin.TotalHours,
                                       idle > TimeSpan.FromMinutes(1) ?  ", been idle for " + Bold +
                                       string.Format("{0:F2}", idle.TotalMinutes) + Reset + " minutes)" : ")");
            }
            else
            {
                IRC.SendChannelMessage("Player " + Bold + "{0}" + Reset + " has spent a total of: "
                                       + Bold + "{1:F1}" + Reset + " hours",
                                       info.ClassyName, info.TotalTime.TotalHours);
            }
        }
Example #3
0
 static void HandleStaff(string userNick, string msg)
 {
     if (msg == null)
     {
         IRC.SendChannelMessage("No message to send to staff.");
     }
     else
     {
         Chat.IRCSendStaff(userNick, msg);
     }
 }
Example #4
0
 void Announce(TimeSpan timeLeft)
 {
     if (String.IsNullOrEmpty(Message))
     {
         Server.Players.Message("&2[&7CountDown&2][&7{0}&2]", timeLeft.ToMiniString());
         IRC.SendChannelMessage("\u212C&S[&7CountDown&S][&7{0}&S]", timeLeft.ToMiniString());
     }
     else
     {
         Server.Players.Message("&2[&7Timer&2][&7{0}&2] &7{1} &2-&7{2}", timeLeft.ToMiniString(), Message, StartedBy);
         IRC.SendChannelMessage("\u212C&S[&7Timer&S][&7{2}&S][&7{0}&S]\u211C {1}", timeLeft.ToMiniString(), Message, StartedBy);
     }
 }
Example #5
0
        static void HandlePlayers(string userNick, string cmdArgs)
        {
            var visible = Server.Players.Where(p => !p.Info.IsHidden)
                          .OrderBy(p => p, PlayerListSorter.Instance).ToArray();

            if (visible.Any())
            {
                IRC.SendChannelMessage(Bold + "Players online: " + Reset +
                                       visible.JoinToString(Formatter));
            }
            else
            {
                IRC.SendChannelMessage(Bold + "There are no players online.");
            }
        }
Example #6
0
        static void HandleBlockDelete(string userNick, string name)
        {
            if (name == null)
            {
                IRC.SendChannelMessage("Please specify a player name");
                return;
            }
            PlayerInfo info = PlayerDB.FindPlayerInfoExact(name);

            if (info == null)
            {
                IRC.SendChannelMessage("No player found with name \"" + Bold + name + Reset + "\"");
                return;
            }

            IRC.SendChannelMessage("Player " + Bold + "{0}" + Reset +
                                   " has Built: " + Bold + "{1}" + Reset +
                                   " blocks Deleted: " + Bold + "{2}" + Reset + " blocks{3}",
                                   info.ClassyName, info.BlocksBuilt, info.BlocksDeleted,
                                   (info.Can(Permission.Draw) ? " Drawn: " + Bold + info.BlocksDrawnString + Reset + " blocks." : ""));
        }
Example #7
0
        internal static void Me(Player player, Command cmd)
        {
            if (player.Info.IsMuted)
            {
                player.MutedMessage();
                return;
            }

            string msg = cmd.NextAll().Trim();

            if (msg.Length > 0)
            {
                player.Info.LinesWritten++;
                if (player.Can(Permission.UseColorCodes) && msg.Contains("%"))
                {
                    msg = Color.ReplacePercentCodes(msg);
                }
                string message = String.Format("{0}*{1} {2}", Color.Me, player.Name, msg);
                Server.SendToAll(message);
                IRC.SendChannelMessage(message);
            }
        }
Example #8
0
        static void TimerCallback([NotNull] SchedulerTask task)
        {
            if (task == null)
            {
                throw new ArgumentNullException("task");
            }
            ChatTimer timer = (ChatTimer)task.UserState;

            if (task.MaxRepeats == 1)
            {
                if (String.IsNullOrEmpty(timer.Message))
                {
                    Server.Players.Message("&2[&7CountDown Finished&2]");
                    IRC.SendChannelMessage("\u212C&S[&7CountDown Finished&S]");
                }
                else
                {
                    Server.Players.Message("&2[&7Timer Finished&2] &7" + timer.Message);
                    IRC.SendChannelMessage("\u212C&S[&7Timer Finished&S]\u211C " + timer.Message);
                }
                //Timer Ends Here.
                timer.Stop(false);
            }
            else if (timer.announceIntervalIndex >= 0)
            {
                if (timer.lastHourAnnounced != (int)timer.TimeLeft.TotalHours)
                {
                    timer.lastHourAnnounced = (int)timer.TimeLeft.TotalHours;
                    timer.Announce(TimeSpan.FromHours(Math.Ceiling(timer.TimeLeft.TotalHours)));
                }
                if (timer.TimeLeft <= AnnounceIntervals[timer.announceIntervalIndex])
                {
                    timer.Announce(AnnounceIntervals[timer.announceIntervalIndex]);
                    timer.announceIntervalIndex--;
                }
            }
        }
Example #9
0
        static void HandleSeen(string userNick, string name)
        {
            if (name == null)
            {
                IRC.SendChannelMessage("Please specify a player name");
                return;
            }
            PlayerInfo info = PlayerDB.FindPlayerInfoExact(name);

            if (info == null)
            {
                IRC.SendChannelMessage("No player found with name \"" + Bold + name + Reset + "\"");
                return;
            }

            Player target = info.PlayerObject;

            if (target != null)
            {
                IRC.SendChannelMessage("Player " + Bold + "{0}" + Reset + " has been " +
                                       Bold + "&aOnline" + Reset + " for " + Bold + "{1}",
                                       target.Info.Rank.Color + target.Name, target.Info.TimeSinceLastLogin.ToMiniString());

                if (target.World != null)
                {
                    IRC.SendChannelMessage("They are currently on world " + Bold + "{0}",
                                           target.World.ClassyName);
                }
            }
            else
            {
                IRC.SendChannelMessage("Player " + Bold + "{0}" + Reset + " is " + Bold + "&cOffline", info.ClassyName);
                IRC.SendChannelMessage("They were last seen " + Bold + "{0}" + Reset + " ago on world " + Bold + "{1}",
                                       info.TimeSinceLastSeen.ToMiniString(), info.LastWorld);
            }
        }
Example #10
0
        public static bool HandlePM(string nick, string userNick, string rawMessage)
        {
            nick = nick.ToLower();
            if (!(rawMessage[0] == '@' || rawMessage.CaselessStarts(nick + " @")))
            {
                return(false);
            }
            if (DateTime.UtcNow.Subtract(lastIrcCommand).TotalSeconds <= 5)
            {
                return(true);
            }

            int start = rawMessage[0] == '@' ? 1 : nick.Length + 2;

            rawMessage = rawMessage.Substring(start);
            string[] parts = rawMessage.Split(trimChars, 2);
            if (parts.Length == 1)
            {
                IRC.SendChannelMessage("Please specify a message to send."); return(true);
            }
            string name = parts[0], contents = parts[1];

            // first, find ALL players (visible and hidden)
            Player[] matches = Server.FindPlayers(name, SearchOptions.IncludeHidden);

            // if there is more than 1 target player, exclude hidden players
            if (matches.Length > 1)
            {
                matches = Server.FindPlayers(name, SearchOptions.Default);
            }

            if (matches.Length == 1)
            {
                Player target = matches[0];
                if (target.Info.ReadIRC && !target.IsDeaf)
                {
                    Chat.IRCSendPM(userNick, target, contents);
                    lastIrcCommand = DateTime.UtcNow;
                }

                if (target.Info.IsHidden)
                {
                    // message was sent to a hidden player
                    IRC.SendChannelMessage("No players found matching \"" +
                                           Bold + name + Reset + "\"");
                    lastIrcCommand = DateTime.UtcNow;
                }
                else
                {
                    // message was sent normally
                    if (!target.Info.ReadIRC)
                    {
                        if (!target.Info.IsHidden)
                        {
                            IRC.SendChannelMessage("&WCannot PM " + Bold +
                                                   target.ClassyName + Reset +
                                                   "&W: they have IRC ignored.");
                        }
                    }
                    else if (target.IsDeaf)
                    {
                        IRC.SendChannelMessage("&WCannot PM " + Bold +
                                               target.ClassyName +
                                               Reset + "&W: they are currently deaf.");
                    }
                    else
                    {
                        IRC.SendChannelMessage("to " + Bold + target.Name + Reset + ": " +
                                               contents);
                    }
                    lastIrcCommand = DateTime.UtcNow;
                }
            }
            else if (matches.Length == 0)
            {
                IRC.SendChannelMessage("No players found matching \"" + Bold + name + Reset + "\"");
            }
            else
            {
                string list = matches.Take(15).JoinToString(", ", p => p.ClassyName);
                if (matches.Length > 15)
                {
                    IRC.SendChannelMessage("More than " + Bold + matches.Length + Reset +
                                           " players matched: " + list);
                }
                else
                {
                    IRC.SendChannelMessage("More than one player matched: " + list);
                }
                lastIrcCommand = DateTime.UtcNow;
            }
            return(true);
        }
Example #11
0
        static void HandleCommands(string userNick, string cmdArgs)
        {
            string cmds = commands.Keys.JoinToString(cmd => cmd.UppercaseFirst());

            IRC.SendChannelMessage(Bold + "List of commands: " + Reset + cmds);
        }