Example #1
0
        private void Eval_Nudge(User user, byte[] data, uint time)
        {
            if (data.Length == 4)
            {
                if (data.SequenceEqual(new byte[] { 78, 65, 61, 61 }))
                {
                    this.Panel.AnnounceText(GlobalSettings.GetDefaultColorString(GlobalSettings.DefaultColorType.Server, this.BlackBG) + "--- " + StringTemplate.Get(STType.Messages, 6).Replace("+x", user.Name));
                    return;
                }
            }

            if (Settings.GetReg <bool>("receive_nudge", true) && !user.Ignored)
            {
                if (time > this.last_nudge)
                {
                    this.last_nudge = time;
                }
                else
                {
                    return;
                }

                if (ScriptEvents.OnNudgeReceiving(this, user))
                {
                    this.Panel.AnnounceText(GlobalSettings.GetDefaultColorString(GlobalSettings.DefaultColorType.Server, this.BlackBG) + "--- " + StringTemplate.Get(STType.Messages, 5).Replace("+x", user.Name));
                    this.owner_frm.Nudge();
                    this.ShowPopup("cb0t :: " + StringTemplate.Get(STType.Messages, 3), StringTemplate.Get(STType.Messages, 5).Replace("+x", user.Name), PopupSound.None);
                }
                else
                {
                    this.sock.Send(TCPOutbound.NudgeReject(user.Name, this.crypto));
                }
            }
            else
            {
                this.sock.Send(TCPOutbound.NudgeReject(user.Name, this.crypto));
            }
        }
Example #2
0
        private void CustomProtoReceived(TCPPacketReader packet, uint time)
        {
            String command = packet.ReadString(this.crypto);
            String sender  = packet.ReadString(this.crypto);
            User   u       = this.users.Find(x => x.Name == sender);

            ulong lag;
            bool  b;

            switch (command)
            {
            case "cb0t_writing":
                if (u == null)
                {
                    return;
                }
                b = ((byte)packet) == 2;

                if (b != u.Writing)
                {
                    u.Writing = b;
                    this.Panel.UpdateWriter(u);
                    ScriptEvents.OnUserWritingStatusChanged(this, u);
                }
                break;

            case "cb0t_latency_check":
                lag = (Helpers.UnixTimeMS - ((ulong)packet));
                this.Panel.Userlist.UpdateLag(lag);
                break;

            case "cb0t_latency_mcheck":
                lag = (Helpers.UnixTimeMS - ((ulong)packet));
                this.sock.Send(TCPOutbound.Public(StringTemplate.Get(STType.Messages, 7) + ": " + lag + " milliseconds", this.crypto));
                break;

            case "cb0t_online_status":
                if (u == null)
                {
                    return;
                }
                b = ((byte)packet) != 1;

                if (u.IsAway != b)
                {
                    u.IsAway = b;
                    this.Panel.Userlist.UpdateUserAppearance(u);
                    ScriptEvents.OnUserOnlineStatusChanged(this, u);
                }

                break;

            case "cb0t_nudge":
                if (u == null)
                {
                    return;
                }
                this.Eval_Nudge(u, ((byte[])packet), time);
                break;

            case "cb0t_pm_msg":
                if (u == null)
                {
                    return;
                }
                this.Eval_cb0t_pm_msg(u, ((byte[])packet));
                break;

            case "cb0t_scribble_once":
                if (u != null)
                {
                    u.ScribbleBuffer = new List <byte>();
                    u.ScribbleBuffer.AddRange((byte[])packet);
                    this.Eval_Scribble(u);
                }
                else if (String.IsNullOrEmpty(sender))
                {
                    this.unknown_scribble_buffer = new List <byte>();
                    this.unknown_scribble_buffer.AddRange((byte[])packet);
                    this.Eval_Scribble_Unknown();
                }
                break;

            case "cb0t_scribble_first":
                if (u != null)
                {
                    u.ScribbleBuffer = new List <byte>();
                    u.ScribbleBuffer.AddRange((byte[])packet);
                }
                else if (String.IsNullOrEmpty(sender))
                {
                    this.unknown_scribble_buffer = new List <byte>();
                    this.unknown_scribble_buffer.AddRange((byte[])packet);
                }
                break;

            case "cb0t_scribble_chunk":
                if (u != null)
                {
                    u.ScribbleBuffer.AddRange((byte[])packet);
                }
                else if (String.IsNullOrEmpty(sender))
                {
                    this.unknown_scribble_buffer.AddRange((byte[])packet);
                }
                break;

            case "cb0t_scribble_last":
                if (u != null)
                {
                    u.ScribbleBuffer.AddRange((byte[])packet);
                    this.Eval_Scribble(u);
                }
                else if (String.IsNullOrEmpty(sender))
                {
                    this.unknown_scribble_buffer.AddRange((byte[])packet);
                    this.Eval_Scribble_Unknown();
                }
                break;

            default:
                if (command.StartsWith("cb3_custom_"))
                {
                    command = command.Substring(11);

                    if (u != null)
                    {
                        String c_text = Encoding.UTF8.GetString((byte[])packet);
                        ScriptEvents.OnCustomDataReceived(this, u, command, c_text);
                    }
                }
                break;
            }
        }