示例#1
0
        public void WriteMessage(string _nick, string _msg)
        {
            if (_msg.Contains(ContextCollection.Server.Client.Nickname))
            {
                _msg = RTF.ColourString(_msg, IrcColor.Black, IrcColor.Yellow);
            }

            if (_msg.Length > 5 && _msg.Substring(0, 7) == "\u0001ACTION")
            {
                content += DateTime.Now.ToString("[HH:mm:ss] ") + RTF.ColourString(" * " + _nick + _msg.Substring(7), IrcColor.LightRed) + @"\line";
            }
            else
            {
                IrcColor c = (_nick == ContextCollection.Server.Client.Nickname) ? IrcColor.LightRed : IrcColor.Blue;

                content += DateTime.Now.ToString("[HH:mm:ss] ") + "<" + RTF.ColourString(_nick, c) + "> " + _msg + @"\line";
            }

            if (ContextCollection.Current == this)
            {
                Program.MainWindow.UpdateContent();
            }
            else
            {
                ContextCollection.ActiveContexts.Add(this.name);
                Program.MainWindow.UpdateChannelsList();
            }
        }
示例#2
0
文件: RTF.cs 项目: dzakrzew/CSIrc
        public static string ColourString(string _text, IrcColor color, IrcColor back = IrcColor.White)
        {
            string text = _text;

            if (char.IsDigit(_text[0]))
            {
                text = " " + _text;
            }

            return("{" + RTF.Colors[(int)color] + RTF.BackgroundColors[(int)back] + text + "}");
        }
示例#3
0
 /// <summary>
 /// Outputs colored IRC-formatted text
 /// </summary>
 /// <param name="text">The text</param>
 /// <returns>IRC-formatted text</returns>
 /// <param name="foreground">The foreground color</param>
 /// <param name="background">The background color</param>
 public static string ColorText(string text, IrcColor foreground, IrcColor background = IrcColor.Reset)
 {
     return IRCColor
         + GetColorCode2Digits(foreground)
         + (background != IrcColor.Reset
             ? "," + GetColorCode2Digits(foreground)
             : ""
           )
         + text
         + IRCColor
         + GetColorCode2Digits(IrcColor.Reset);
 }
示例#4
0
文件: Data.cs 项目: guy489/runuot2a
        public static void LoadGlobalOptions()
        {
            if (!File.Exists(Path.Combine(General.SavePath, "GlobalOptions.bin")))
                return;

            using (FileStream bin = new FileStream(Path.Combine(General.SavePath, "GlobalOptions.bin"), FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                GenericReader reader = new BinaryFileReader(new BinaryReader(bin));

                int version = reader.ReadInt();

                if (version >= 2) s_MultiPort = reader.ReadInt();
                if (version >= 2) s_MultiServer = reader.ReadString();

                int count = 0;
                if (version >= 1)
                {
                    count = reader.ReadInt();
                    Notification not = null;
                    for (int i = 0; i < count; ++i)
                    {
                        not = new Notification();
                        not.Load(reader);
                    }
                }

                count = reader.ReadInt();
                string txt = "";
                for (int i = 0; i < count; ++i)
                {
                    txt = reader.ReadString();
                    if(!s_Filters.Contains(txt))
                        s_Filters.Add(txt);
                }

                s_FilterPenalty = (FilterPenalty)reader.ReadInt();
                if(version >= 1) s_MacroPenalty = (MacroPenalty)reader.ReadInt();
                s_MaxMsgs = reader.ReadInt();
                s_ChatSpam = reader.ReadInt();
                s_MsgSpam = reader.ReadInt();
                s_RequestSpam = reader.ReadInt();
                s_FilterBanLength = reader.ReadInt();
                s_FilterWarnings = reader.ReadInt();
                if (version >= 1) s_AntiMacroDelay = reader.ReadInt();
                s_IrcPort = reader.ReadInt();
                s_IrcMaxAttempts = reader.ReadInt();
                s_IrcEnabled = reader.ReadBool();
                s_IrcAutoConnect = reader.ReadBool();
                s_IrcAutoReconnect = reader.ReadBool();
                s_FilterSpeech = reader.ReadBool();
                s_FilterMsg = reader.ReadBool();
                s_Debug = reader.ReadBool();
                s_LogChat = reader.ReadBool();
                s_LogPms = reader.ReadBool();
                s_IrcStaffColor = (IrcColor)reader.ReadInt();
                s_IrcServer = reader.ReadString();
                s_IrcRoom = reader.ReadString();
                s_IrcNick = reader.ReadString();
                s_TotalChats = reader.ReadULong() - 1;
            }
        }
示例#5
0
 /// <summary>
 /// Control character for settings the foreground and background color
 /// </summary>
 /// <param name="foreground">The color to set as foreground color</param>
 /// <param name="background">The color to set as background color</param>
 /// <returns>A string representing ^CM,N where M and N are color IDs</returns>
 public static string Color(IrcColor foreground, IrcColor background)
 {
     if (!Enabled) return "";
     return Color(foreground) + "," + ((int)background).ToString();
 }
示例#6
0
 /// <summary>
 /// Control character for setting the foreground color
 /// </summary>
 /// <param name="foreground">The color to set as foreground color</param>
 /// <returns>A string representing ^CM, where M is a color ID</returns>
 public static string Color(IrcColor foreground)
 {
     if (!Enabled) return "";
     return ColorRestore() + ((int)foreground).ToString();
 }
示例#7
0
文件: Plugin.cs 项目: MrTiggr/Murphy
 protected internal static string FormatColor(string s, IrcColor foreground, IrcColor background)
 {
     return "\u0003" + ((int)foreground).ToString() + "," + ((int)background).ToString() + s + "\u0003" + ((int)foreground).ToString() + "," + ((int)background).ToString();
 }
示例#8
0
 protected internal static string FormatColor(string s, IrcColor foreground, IrcColor background)
 {
     return("\u0003" + ((int)foreground).ToString() + "," + ((int)background).ToString() + s + "\u0003" + ((int)foreground).ToString() + "," + ((int)background).ToString());
 }
示例#9
0
        private static void OnLoad()
        {
            try{
                if (!File.Exists(Path.Combine("Saves/Chat/", "Chat.bin")))
                {
                    return;
                }

                using (FileStream bin = new FileStream(Path.Combine("Saves/Chat/", "Chat.bin"), FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    GenericReader reader = new BinaryFileReader(new BinaryReader(bin));

                    int version = reader.ReadInt();

                    if (version >= 12)
                    {
                        s_PublicPlusIRC = reader.ReadBool();
                    }

                    if (version >= 11)
                    {
                        s_FilterPenalty = (FilterPenalty)reader.ReadInt();
                    }

                    if (version >= 10)
                    {
                        s_AllianceChat = reader.ReadBool();
                    }

                    if (version >= 9)
                    {
                        s_AllowFaction = reader.ReadBool();
                    }

                    if (version >= 8)
                    {
                        s_GuildMenuAccess = reader.ReadBool();
                    }

                    if (version >= 7)
                    {
                        s_MaxPmHistory = reader.ReadInt();
                    }

                    if (version >= 6)
                    {
                        s_IrcAutoReconnect = reader.ReadBool();
                    }

                    if (version >= 5)
                    {
                        s_IrcMaxAttempts = reader.ReadInt();
                    }

                    if (version >= 4)
                    {
                        s_IrcAutoConnect = reader.ReadBool();
                    }

                    if (version >= 3)
                    {
                        s_IrcStaffColor = (IrcColor)reader.ReadInt();
                    }

                    if (version >= 2)
                    {
                        s_IrcNick = reader.ReadString();
                    }

                    if (version >= 1)
                    {
                        s_IrcEnabled = reader.ReadBool();
                        s_IrcServer  = reader.ReadString();
                        s_IrcRoom    = reader.ReadString();
                        s_IrcPort    = reader.ReadInt();
                    }

                    if (version >= 0)
                    {
                        int count = reader.ReadInt();

                        for (int i = 0; i < count; ++i)
                        {
                            s_Filters.Add(reader.ReadString());
                        }

                        s_SpamLimiter     = reader.ReadDouble();
                        s_FilterBanLength = reader.ReadDouble();

                        if (version < 11)
                        {
                            reader.ReadBool();                     // FilterBan removed
                        }
                        s_ShowLocation = reader.ReadBool();
                        s_ShowStaff    = reader.ReadBool();
                        s_PublicStyle  = (PublicStyle)reader.ReadInt();

                        count = reader.ReadInt();
                        ChatInfo info;

                        for (int i = 0; i < count; ++i)
                        {
                            info = new ChatInfo(reader.ReadMobile());
                            if (!info.Load(reader))
                            {
                                return;
                            }
                        }
                    }

                    reader.End();
                }

                if (s_IrcAutoConnect)
                {
                    IrcConnection.Connection.Connect();
                }
            }catch { Errors.Report("ChatInfo-> OnLoad"); }
        }
示例#10
0
 private static string GetColorCodeName(IrcColor color)
 {
     return color.ToString();
 }
示例#11
0
 private static int GetColorCodeInt(IrcColor color)
 {
     return (int)color;
 }
示例#12
0
 /// <summary>
 /// Returns the 2-digit code of the color
 /// </summary>
 /// <param name="color"></param>
 /// <returns></returns>
 private static string GetColorCode2Digits(IrcColor color)
 {
     string n = GetColorCodeInt(color).ToString(); while (n.Length < 2) n = "0" + n; return n;
 }
示例#13
0
        private static void OnLoad()
        {
            try{

            if ( !File.Exists( Path.Combine( "Saves/Chat/", "Chat.bin" ) ) )
                return;

            using ( FileStream bin = new FileStream( Path.Combine( "Saves/Chat/", "Chat.bin" ), FileMode.Open, FileAccess.Read, FileShare.Read ) )
            {
                GenericReader reader = new BinaryFileReader( new BinaryReader( bin ) );

                int version = reader.ReadInt();

                if ( version >= 12 )
                    s_PublicPlusIRC = reader.ReadBool();

                if ( version >= 11 )
                    s_FilterPenalty = (FilterPenalty)reader.ReadInt();

                if ( version >= 10 )
                    s_AllianceChat = reader.ReadBool();

                if ( version >= 9 )
                    s_AllowFaction = reader.ReadBool();

                if ( version >= 8 )
                    s_GuildMenuAccess = reader.ReadBool();

                if ( version >= 7 )
                    s_MaxPmHistory = reader.ReadInt();

                if ( version >= 6 )
                    s_IrcAutoReconnect = reader.ReadBool();

                if ( version >= 5 )
                    s_IrcMaxAttempts = reader.ReadInt();

                if ( version >= 4 )
                    s_IrcAutoConnect = reader.ReadBool();

                if ( version >= 3 )
                    s_IrcStaffColor = (IrcColor)reader.ReadInt();

                if ( version >= 2 )
                    s_IrcNick = reader.ReadString();

                if ( version >= 1 )
                {
                    s_IrcEnabled = reader.ReadBool();
                    s_IrcServer = reader.ReadString();
                    s_IrcRoom = reader.ReadString();
                    s_IrcPort = reader.ReadInt();
                }

                if ( version >= 0 )
                {
                    int count = reader.ReadInt();

                    for( int i = 0; i < count; ++i )
                        s_Filters.Add( reader.ReadString() );

                    s_SpamLimiter = reader.ReadDouble();
                    s_FilterBanLength = reader.ReadDouble();

                    if ( version < 11 )
                        reader.ReadBool(); // FilterBan removed

                    s_ShowLocation = reader.ReadBool();
                    s_ShowStaff = reader.ReadBool();
                    s_PublicStyle = (PublicStyle)reader.ReadInt();

                    count = reader.ReadInt();
                    ChatInfo info;

                    for( int i = 0; i < count; ++i )
                    {
                        info = new ChatInfo( reader.ReadMobile() );
                        if ( !info.Load( reader ) )
                            return;
                    }
                }

                reader.End();
            }

            if ( s_IrcAutoConnect )
                IrcConnection.Connection.Connect();

            }catch{ Errors.Report( "ChatInfo-> OnLoad" ); }
        }