Inheritance: MonoBehaviour
Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        if (AlwaysOn)
        {
            Power.Powered = true;
        }

        if (InArea)
        {
            if (Input.GetKeyDown("e"))
            {
                anim.SetTrigger("Interact");
                if (OrbHolder)
                {
                    if (Power.Powered)
                    {
                        Controller.source.clip = Controller.PowerUpfx;
                        Controller.source.Play();
                        Power.Powered      = false;
                        Controller.Powered = true;
                        Player_Orb.SetActive(true);
                        Object_Orb.SetActive(false);
                    }
                    else
                    {
                        Controller.source.clip = Controller.PowerDownfx;
                        Controller.source.Play();
                        Power.Powered      = true;
                        Controller.Powered = false;
                        Player_Orb.SetActive(false);
                        Object_Orb.SetActive(true);
                    }
                }
                else if (FuseBox)
                {
                    Controller.source.clip = Controller.Powerfx;
                    Controller.source.Play();
                    AlwaysOn = true;
                    BlackLight.SetActive(false);
                    YellowLight.SetActive(true);
                    spark.SetActive(true);
                }
                else if (Ballbutton)
                {
                    Controller.source.clip = Controller.Buttonfx;
                    Controller.source.Play();
                    ReleasePanel           = BallRelease.GetComponent <BoxCollider> ();
                    ReleasePanel.isTrigger = true;
                }
            }
        }
    }
Esempio n. 2
0
 public void TimerSaveDB(BlackLight.Services.Timers.Timer tTimer)
 {
     DataDriver.SaveDB("nickserv.db", NickDB);
     mNickServ.Send_Notice("#services", "Saving DataBase");
 }
 private void GetClient(string pattern, ScanCallBack action, BlackLight.Services.Nodes.Server Serv)
 {
     int tIndex;
     for (tIndex = 0; tIndex <= Serv.users.Count - 1; tIndex++)
     {
         action(pattern,((Client) Serv.users[tIndex]));
     }
     foreach (Server n in Serv.leafs)
     {
         GetClient(pattern, action, n);
     }
 }
Esempio n. 4
0
        private bool Channel_Part(BlackLight.Services.Nodes.IRCUser Source, string command, List<string> arguments)
        {
            //Viable String Options
                    //--NICKNAME
                    //--CHANNEL
                    try
                    {
                        if (Source != null&& Source is BlackLight.Services.Nodes.Client)
                        {
                            Command cmd = MyIRCd.Commands["PARTRECEIVE"];
                            if (arguments.Count == cmd.parameterCount())
                            {
                                int tChannelIndex = Channels.IndexOf(arguments[cmd.getParameterIndex("CHANNEL")]);
                                if (tChannelIndex < 0)
                                {
                                    SendLogMessage("Services", "Part", BlackLight.Services.Error.Errors.ERROR, "Channel does not exist", arguments[cmd.getParameterIndex("CHANNEL")], "", "");
                                    return false;
                                }
                                BlackLight.Services.Nodes.Client tUser = ((BlackLight.Services.Nodes.Client) Source);
                                if (Channels[tChannelIndex].channelMembers.Contains(tUser))
                                {
                                    Channels[tChannelIndex].channelMembers.Remove(Channels[tChannelIndex].channelMembers[tUser]);
                                    if (tUser.channels.Contains(Channels[tChannelIndex]))
                                    {
                                        tUser.channels.Remove(Channels[tChannelIndex]);
                                    }
                                    else
                                    {
                                        SendLogMessage("Services", "Part", BlackLight.Services.Error.Errors.ERROR, "Channel Lists Desync member has no record of channel, channel has record of member", "", "", "");
                                    }
                                }
                                else if (tUser.channels.Contains(Channels[tChannelIndex]))
                                {
                                    tUser.channels.Remove(Channels[tChannelIndex]);
                                    SendLogMessage("Services", "Part", BlackLight.Services.Error.Errors.ERROR, "Channel Lists Desync member has record of channel, channel has no record of member", "", "", "");
                                }
                                else
                                {
                                    SendLogMessage("Services", "Part", BlackLight.Services.Error.Errors.ERROR, "Recieved part for invalid channel member", "", "", "");
                                }

                                if (Channels[tChannelIndex].channelMembers.Count == 0)
                                {
                                    Channels.RemoveAt(tChannelIndex);
                                }
                                if (events.onPartEvent != null)
                                    events.onPartEvent(tUser.name, arguments[cmd.getParameterIndex("CHANNEL")]);
                            }
                            else
                            {
                                SendLogMessage("Services", "Part", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.ERROR, "Unable to match protocol with message received", "", "", "");
                            }
                            return true;
                        }
                        return false;
                    }
                    catch (Exception ex)
                    {
                        SendLogMessage("Services", "Part", BlackLight.Services.Error.Errors.ERROR, "Problem parsing", "", ex.Message, ex.StackTrace);
                        return false;
                    }
        }
Esempio n. 5
0
        private bool Channel_Join(BlackLight.Services.Nodes.IRCUser Source, string command, List<string> arguments)
        {
            //Viable String Options
                    //--NICKNAME
                    //--CHANNEL
                    try
                    {
                        if (Source != null && Source is BlackLight.Services.Nodes.Client)
                        {
                            Command cmd = MyIRCd.Commands["JOINRECEIVE"];
                            if (arguments.Count == cmd.parameterCount())
                            {
                                BlackLight.Services.Nodes.Client tUser = ((BlackLight.Services.Nodes.Client) Source);
                                if (arguments[cmd.getParameterIndex("CHANNEL")][0] == '#' || arguments[cmd.getParameterIndex("CHANNEL")][0] == '&')
                                {
                                    int tChannelIndex;

                                    if (Channels.Contains(arguments[cmd.getParameterIndex("CHANNEL")]) == false)
                                    {
                                        tChannelIndex = Channels.Add(new BlackLight.Services.Nodes.Channel(arguments[cmd.getParameterIndex("CHANNEL")], this));
                                    }
                                    else
                                    {
                                        tChannelIndex = Channels.IndexOf(arguments[cmd.getParameterIndex("CHANNEL")]);
                                    }
                                    //RaiseEvent onDebug("JOIN-Join Nick: " & tUser.Nick & " Channel: " & tMatch.Groups("CHANNEL").Value)
                                    Channels[tChannelIndex].channelMembers.Add(new BlackLight.Services.Nodes.ChanMember(tUser, this));
                                    tUser.channels.Add(Channels[tChannelIndex]);
                                    if (events.onJoinEvent != null)
                                        events.onJoinEvent(tUser.nick, Channels[tChannelIndex].name);
                                    tChannelIndex = 0;
                                }
                                else if (arguments[cmd.getParameterIndex("CHANNEL")][0] == '0')
                                {

                                    while (tUser.channels.Count > 0)
                                    {
                                        if (tUser.channels[0].channelMembers.Count == 1 && tUser.channels[0].channelMembers.Contains(tUser))
                                        {
                                            Channels.Remove(tUser.channels[0]);
                                        }
                                        else
                                        {
                                            tUser.channels[0].channelMembers.Remove(tUser.channels[0].channelMembers[tUser]);
                                            tUser.channels.RemoveAt(0);
                                        }
                                    }
                                }
                                tUser = null;

                            }
                            else
                            {
                                SendLogMessage("Services", "Channel_Join", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.ERROR, "Unable to match protocol with message received", "", "", "");
                                return false;
                            }
                            return true;
                        }
                        return false;
                    }
                    catch (Exception ex)
                    {
                        SendLogMessage("Services", "Channel_Join", BlackLight.Services.Error.Errors.ERROR, "Problem parsing", "", ex.Message, ex.StackTrace);
                        return false;
                    }
        }
Esempio n. 6
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Search for a client based on server
 /// </summary>
 /// <param name="name"></param>
 /// <param name="Serv"></param>
 /// <returns></returns>
 /// <remarks>
 /// </remarks>
 /// <history>
 /// 	[Caleb]	6/18/2005	Created
 /// </history>
 /// -----------------------------------------------------------------------------
 public BlackLight.Services.Nodes.Client GetClient(string name, BlackLight.Services.Nodes.Server Serv)
 {
     try
             {
                 short tIndex;
                 tIndex = Convert.ToInt16(Serv.users.IndexOf(name));
                 if (tIndex >= 0)
                 {
                     return ((BlackLight.Services.Nodes.Client) Serv.users[tIndex]);
                 }
                 BlackLight.Services.Nodes.Client tClient;
                 foreach (BlackLight.Services.Nodes.Server n in Serv.leafs)
                 {
                     tClient = GetClient(name, n);
                     if (tClient != null)
                     {
                         return tClient;
                     }
                 }
                 return null;
             }
             catch (Exception ex)
             {
                 SendLogMessage("Services", "GetClient(2)", BlackLight.Services.Error.Errors.ERROR, "Problem finding client", "", ex.Message, ex.StackTrace);
                 return null;
             }
 }
Esempio n. 7
0
 private bool UserQuit(BlackLight.Services.Nodes.IRCUser Source, string command, List<string> arguments)
 {
     //Viable String Options
             //--REASON
             try
             {
                 if (Source != null&& Source is BlackLight.Services.Nodes.Client)
                 {
                     Command cmd = MyIRCd.Commands["QUITRECEIVE"];
                     if (arguments.Count == cmd.parameterCount())
                     {
                         if (events.onQuitEvent != null)
                             events.onQuitEvent(Source.name, arguments[cmd.getParameterIndex("REASON")]);
                         Source.Dispose();
                     }
                     else
                     {
                         SendLogMessage("Services", "Quit", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.ERROR, "Unable to match protocol with message received", "", "", "");
                     }
                     return true;
                 }
                 return false;
             }
             catch (Exception ex)
             {
                 SendLogMessage("Services", "Quit", BlackLight.Services.Error.Errors.ERROR, "Problem parsing", "", ex.Message, ex.StackTrace);
                 return false;
             }
 }
Esempio n. 8
0
 private bool SVSKill(BlackLight.Services.Nodes.IRCUser Source, string command, List<string> arguments)
 {
     //Viable String Options
             //--NICKNAME
             //--REASON
             try
             {
                 if (Source != null)
                 {
                     Command cmd = MyIRCd.Commands["SVSKILLRECEIVE"];
                     if (arguments.Count == cmd.parameterCount())
                     {
                         BlackLight.Services.Nodes.IRCUser tUser = GetClientALL(arguments[cmd.getParameterIndex("NICKNAME")]);
                         if (tUser != null)
                         {
                             if (events.onSVSKillEvent != null)
                                 events.onSVSKillEvent(tUser.name, arguments[cmd.getParameterIndex("REASON")]);
                             tUser.Dispose();
                         }
                         tUser = null;
                     }
                     else
                     {
                         SendLogMessage("Services", "SVSKIll", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.ERROR, "Unable to match protocol with message received", "", "", "");
                     }
                     return true;
                 }
                 return false;
             }
             catch (Exception ex)
             {
                 SendLogMessage("Services", "SVSKILL", BlackLight.Services.Error.Errors.ERROR, "Problem parsing", "", ex.Message, ex.StackTrace);
                 return false;
             }
 }
Esempio n. 9
0
        private bool ModeChange(BlackLight.Services.Nodes.IRCUser Source, string command, List<string> arguments)
        {
            //Viable String Options
                    //--OBJECT
                    //--CHANNEL
                    try
                    {
                        if (Source != null)
                        {
                            Command cmd = MyIRCd.Commands["MODERECEIVE"];
                            if (arguments.Count == cmd.parameterCount())
                            {
                                if (arguments[cmd.getParameterIndex("OBJECT")][0] == '#' || arguments[cmd.getParameterIndex("OBJECT")][0] == '&')
                                {
                                    int tChannelIndex = Channels.IndexOf(arguments[cmd.getParameterIndex("OBJECT")]);
                                    if (tChannelIndex < 0)
                                    {
                                        SendLogMessage("Services", "ModeChange", BlackLight.Services.Error.Errors.ERROR, "Channel does not exist", arguments[cmd.getParameterIndex("OBJECT")], "", "");
                                        return false;
                                    }
                                    Channels[tChannelIndex].parseModeSet(arguments[cmd.getParameterIndex("MODESTRING")]);
                                    if (events.onModeEvent != null)
                                        events.onModeEvent();
                                }
                                else
                                {
                                    //Erm....
                                    //RaiseEvent onDebug("Mode Command matched channel protocol, but is not for a channel")
                                    SendLogMessage("Services", "ModeChange", BlackLight.Services.Error.Errors.WARNING, "Mode Command matched channel protocol, but is not for a channel", "", "", "");
                                }
                            }
                            else
                            {
                                SendLogMessage("Services", "ModeChange", BlackLight.Services.Error.Errors.DEBUG, "UMODE", "", "", "");
                                if (Source is BlackLight.Services.Nodes.Client)
                                {
                                    cmd = MyIRCd.Commands["UMODERECEIVE"];
                                    if (arguments.Count == cmd.parameterCount())
                                    {
                                        BlackLight.Services.Nodes.Client tUser;
                                        if (!cmd.hasParameter("OBJECT"))
                                        {
                                            tUser = GetClient(Source.name);
                                        }
                                        else
                                        {
                                            tUser = GetClient(arguments[cmd.getParameterIndex("OBJECT")]);
                                        }

                                        if (tUser != null)
                                        {
                                            tUser.ParseModeSet(arguments[cmd.getParameterIndex("MODESTRING")]);
                                        }
                                        else
                                        {
                                            SendLogMessage("Services", "ModeChange", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.ERROR, "Unable to match find client specified in mode change", "protocol error?", "", "");
                                        }
                                        tUser = null;
                                    }
                                    else
                                    {
                                        SendLogMessage("Services", "ModeChange", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.ERROR, "Unable to match protocol with message received", "", "", "");
                                    }
                                }
                                else
                                {
                                    SendLogMessage("Services", "ModeChange", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.ERROR, "Invalid Source", "", "", "");
                                }
                            }

                            return true;
                        }
                        return false;
                    }
                    catch (Exception ex)
                    {
                        SendLogMessage("Services", "Mode", BlackLight.Services.Error.Errors.ERROR, "Problem parsing", "", ex.Message, ex.StackTrace);
                        return false;
                    }
        }
Esempio n. 10
0
 private BlackLight.Services.Nodes.Server GetServer(string name, BlackLight.Services.Nodes.Server Serv)
 {
     try
             {
                 short tIndex;
                 tIndex = Convert.ToInt16(Serv.leafs.IndexOf(name));
                 if (tIndex >= 0)
                 {
                     return ((BlackLight.Services.Nodes.Server) Serv.leafs[tIndex]);
                 }
                 BlackLight.Services.Nodes.Server tServer;
                 foreach (BlackLight.Services.Nodes.Server n in Serv.leafs)
                 {
                     tServer = GetServer(name, n);
                     if (tServer != null)
                     {
                         return tServer;
                     }
                 }
                 return null;
             }
             catch (Exception ex)
             {
                 SendLogMessage("Services", "GetServer(2)", BlackLight.Services.Error.Errors.ERROR, "Problem finding server", "", ex.Message, ex.StackTrace);
                 return null;
             }
 }
Esempio n. 11
0
 private bool EOS(BlackLight.Services.Nodes.IRCUser Source, string command, List<string> arguments)
 {
     TimeSpan x = new TimeSpan(System.DateTime.Now.Ticks-starttime.Ticks);
             //Console.WriteLine("Recieved EOS At:" + x.Seconds + " " + x.Milliseconds);
             SendLogMessage("Services", "EOS", BlackLight.Services.Error.Errors.DEBUG, "Recieved EOS At:" + x.Seconds + " " + x.Milliseconds, "", "", "");
             return true;;
 }
Esempio n. 12
0
 public ServiceResponses(string Name, BlackLight.Services.Modules.Help.Lists.ErrorList Errors, BlackLight.Services.Modules.Help.Lists.CommandList Commands)
 {
     this.Name = Name;
     this.Errors = Errors;
     this.Commands = Commands;
 }
Esempio n. 13
0
 public ServiceCommandResponse(string Name, string[] Value, BlackLight.Services.Modules.Help.Lists.CommandList Commands)
 {
     this.Name = Name;
     this.Value = Value;
     this.Commands = Commands;
 }
Esempio n. 14
0
 private void ListCommands(BlackLight.Services.Modules.Help.Lists.CommandList Commands)
 {
     foreach (BlackLight.Services.Modules.Help.ServiceCommandResponse tCommand in Commands)
     {
         Console.WriteLine(tCommand.Name);
         if (tCommand.Commands != null && tCommand.Commands.Count > 0)
         {
             ListCommands(tCommand.Commands);
         }
     }
 }
Esempio n. 15
0
                    private bool GetAllCommands(XmlNode tNode, BlackLight.Services.Modules.Help.Lists.CommandList TopList)
                    {
                        string tCmdName;
                        string tCmdValue = "";
                        string[] tCmdValues;
                        BlackLight.Services.Modules.Help.Lists.CommandList tCommands = new BlackLight.Services.Modules.Help.Lists.CommandList();
                        ServiceCommandResponse tCmd;
                        foreach (XmlNode tCommandNode in tNode)
                        {
                            if (tCommandNode.Attributes["name"] != null && tCommandNode.Attributes["name"].Value != "")
                            {
                                tCmdName = tCommandNode.Attributes["name"].Value;
                            }
                            else
                            {
                                MyBase.Core.SendLogMessage("Help", "GetAllCommands()", BlackLight.Services.Error.Errors.ERROR, "XML Data Corruption", "", "", "");
                                //MessageBox.Show("XML Data corruption");
                                return false;
                            }

                            if (tCommandNode["commands"] != null)
                            {
                                try
                                {
                                    GetAllCommands(tCommandNode["commands"], tCommands);
                                }
                                catch (Exception ex)
                                {
                                    MyBase.Core.SendLogMessage("Help", "GetAllCommands()", BlackLight.Services.Error.Errors.ERROR, "Exception", "", ex.Message, ex.StackTrace);
                                    //MessageBox.Show(ex.Message + " " + ex.StackTrace);
                                }
                            }
                            else
                            {
                                if (tCommandNode.InnerText != null&& tCommandNode.InnerText != "")
                                {
                                    tCmdValue = tCommandNode.InnerText.Trim();
                                }
                                else
                                {
                                    MyBase.Core.SendLogMessage("Help", "ModLoad", BlackLight.Services.Error.Errors.ERROR, "XML Data Corruption", "", "", "");
                                    //MessageBox.Show("XML Data corruption");
                                    return false;
                                }
                            }
                            tCmdValue = tCmdValue.Replace("  ", " ");
                            tCmdValue = tCmdValue.Replace("  ", " ");
                            tCmdValue = tCmdValue.Replace("`B", "");
                            tCmdValue = tCmdValue.Replace("`U", "");
                            tCmdValue = tCmdValue.Replace("\r\n", "\r");
                            tCmdValue = tCmdValue.Replace("\n", "\r");
                            tCmdValues = tCmdValue.Split('\r');
                            if (tCommands.Count == 0)
                            {
                                tCmd = new ServiceCommandResponse(tCmdName, tCmdValues, null);
                            }
                            else
                            {
                                tCmd = new ServiceCommandResponse(tCmdName, tCommands["help"].Value, tCommands);
                            }

                            TopList.Add(tCmd);
                        }
                        return true;
                    }
            private void Core_LogMessage(string Origin, string Method, BlackLight.Services.Error.Errors Type, string Message, string Extra, string Exception, string Trace)
            {
                //return;
                string tMessage;
                bool Terminate = false;
                //bool Debug = false;
                //Select Case Type
                //    Case Errors.LOG_NOTICE
                //        tMessage = "!NOTICE! "
                //    Case Errors.LOG_DEBUG
                //        tMessage = "!DEBUG! "
                //        Debug = True
                //    Case Errors.LOG_NOTICE_AND_DEBUG
                //        tMessage = "!NOTICE/DEBUG! "
                //        Debug = True
                //    Case Errors.LOG_WARNING
                //        tMessage = "!WARNING! "
                //    Case Errors.LOG_NOTICE_AND_WARNING
                //        tMessage = "!NOTICE/WARNING! "
                //    Case Errors.LOG_DEBUG_AND_WARNING
                //        tMessage = "!DEBUG/WARNING! "
                //        Debug = True
                //    Case Errors.LOG_ERROR
                //        tMessage = "!ERROR! "
                //    Case Errors.LOG_NOTICE_AND_ERROR
                //        tMessage = "!NOTICE/ERROR! "
                //    Case Errors.LOG_DEBUG_AND_ERROR
                //        tMessage = "!DEBUG/ERROR! "
                //        Debug = True
                //    Case Errors.LOG_WARNING_AND_ERROR
                //        tMessage = "!WARNING/ERROR! "
                //    Case Errors.LOG_FATAL
                //        tMessage = "!PANIC! "
                //        Terminate = True
                //    Case Errors.LOG_NOTICE_AND_FATAL
                //        tMessage = "!NOTICE/PANIC! "
                //        Terminate = True
                //    Case Errors.LOG_DEBUG_AND_FATAL
                //        tMessage = "!DEBUG/PANIC! "
                //        Debug = True
                //        Terminate = True
                //    Case Errors.LOG_WARNING_AND_FATAL
                //        tMessage = "!WARNING/PANIC! "
                //        Terminate = True
                //    Case Errors.LOG_ERROR_AND_FATAL
                //        tMessage = "!ERROR/PANIC! "
                //        Terminate = True
                //    Case Else
                //        tMessage = "!UNKNOWN ERROR! "
                //End Select
                if ((Type & BlackLight.Services.Error.Errors.FATAL) == BlackLight.Services.Error.Errors.FATAL)
                {
                    Terminate = true;
                    AddText("Terminating" + IRC.CRLF);
                }
                if ( Convert.ToBoolean((Type & LogType) & LogType) || ((Type & BlackLight.Services.Error.Errors.FATAL) == BlackLight.Services.Error.Errors.FATAL))
                {
                    tMessage = "!" + @Enum.Format(typeof(BlackLight.Services.Error.Errors), Type, "g").Replace(", ", "/") + ((char)(161)) + " ";

                    tMessage += Message + " (Path: ";
                    tMessage += Origin + "->" + Method + ") ";
                    if (Exception != "" && ((LogType & BlackLight.Services.Error.Errors.DEBUG) == BlackLight.Services.Error.Errors.DEBUG))
                    {
                        tMessage += Exception + " ";
                        if (Trace != "")
                        {
                            tMessage += "- " + Trace + " ";
                        }
                    }
                    if (Extra != "")
                    {
                        tMessage += "*" + Extra + "*";
                    }
                    tMessage = tMessage.Trim()+ "\r\n";
                    AddText(tMessage);
                    if (Terminate)
                    {
                        TerminateCore();
                    }

                }
            }
Esempio n. 17
0
 private bool SQuit(BlackLight.Services.Nodes.IRCUser Source, string command, List<string> arguments)
 {
     //Viable String Options
             //--SERVERNAME
             //--REASON
             try
             {
                 if (Source != null&& Source is BlackLight.Services.Nodes.Server)
                 {
                     Command cmd = MyIRCd.Commands["SQUITRECEIVE"];
                     if (arguments.Count == cmd.parameterCount())
                     {
                         if (events.onSQUITEvent != null)
                             events.onSQUITEvent(arguments[cmd.getParameterIndex("SERVERNAME")], arguments[cmd.getParameterIndex("REASON")]);
                         foreach (BlackLight.Services.Nodes.Server tServer in MyHost.GetAllServers())
                         {
                             if (tServer.name == arguments[cmd.getParameterIndex("SERVERNAME")])
                             {
                                 tServer.Dispose();
                                 break;
                             }
                         }
                     }
                     else
                     {
                         SendLogMessage("Services", "SQUIT", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.ERROR, "Unable to match protocol with message received", "", "", "");
                     }
                     return true;
                 }
                 return false;
             }
             catch (Exception ex)
             {
                 SendLogMessage("Services", "SQUIT", BlackLight.Services.Error.Errors.ERROR, "Problem parsing", "", ex.Message, ex.StackTrace);
                 return false;
             }
 }
Esempio n. 18
0
 private bool NetInfo(BlackLight.Services.Nodes.IRCUser Source, string command, List<string> arguments)
 {
     //Viable String Options
             //--NICKNAME
             //--REASON
             try
             {
                 if (Source != null&& Source is BlackLight.Services.Nodes.Server)
                 {
                     Command cmd = MyIRCd.Commands["NETINFORECEIVE"];
                     if (arguments.Count == cmd.parameterCount())
                     {
                         SendData(string.Format(MyIRCd.SendCommands["NETINFOSEND"].ToString(), MyName, Time.GetTS(DateTime.Now), arguments[cmd.getParameterIndex("PROTOCOL")], arguments[cmd.getParameterIndex("CLOAK")], arguments[cmd.getParameterIndex("NETWORKNAME")], Time.GetTS(DateTime.Now)));
                     }
                     else
                     {
                         SendLogMessage("Services", "NetInfo", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.ERROR, "Unable to match protocol with message received", "", "", "");
                     }
                     return true;
                 }
                 return false;
             }
             catch (Exception ex)
             {
                 //MsgBox("NetInfo: " & e.Message & vbCrLf & e.StackTrace)
                 SendLogMessage("Services", "NetInfo", BlackLight.Services.Error.Errors.ERROR, "Problem parsing", "", ex.Message, ex.StackTrace);
                 return false;
             }
 }
Esempio n. 19
0
        private bool SVSMode(BlackLight.Services.Nodes.IRCUser Source, string command, List<string> arguments)
        {
            //Viable String Options
                    //--OBJECT
                    //--MODESTRING
                    //--TIME
                    try
                    {
                        if (Source != null)
                        {
                            Command cmd = MyIRCd.Commands["SVSMODERECEIVE"];
                            if (command == cmd.name && arguments.Count == cmd.parameterCount())
                            {
                                BlackLight.Services.Nodes.Client tUser = GetClient(arguments[cmd.getParameterIndex("OBJECT")]);
                                if (tUser != null)
                                {
                                    tUser.ParseModeSet(arguments[cmd.getParameterIndex("MODESTRING")]);
                                }
                                tUser = null;
                            }
                            else
                            {
                                cmd = MyIRCd.Commands["SVS2MODERECEIVE"];
                                if (command == cmd.name && arguments.Count == cmd.parameterCount())
                                {
                                    BlackLight.Services.Nodes.Client tUser = GetClient(arguments[cmd.getParameterIndex("OBJECT")]);
                                    if (tUser != null)
                                    {
                                        tUser.ParseModeSet(arguments[cmd.getParameterIndex("MODESTRING")]);
                                    }
                                    tUser = null;
                                }
                                else
                                {

                                    SendLogMessage("Services", "SVSMODE", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.ERROR, "Unable to match protocol with message received", "", "", "");
                                }
                            }

                            return true;
                        }
                        return false;
                    }
                    catch (Exception ex)
                    {
                        SendLogMessage("Services", "SVSMode", BlackLight.Services.Error.Errors.ERROR, "Problem parsing", "", ex.Message, ex.StackTrace);
                        return false;
                    }
        }
Esempio n. 20
0
        private bool NewServer(BlackLight.Services.Nodes.IRCUser Source, string command, List<string> arguments)
        {
            //Viable String Options
                    //--SERVERNAME
                    //--SERVERNUMERIC
                    //--HOPS
                    //--SERVERDESCRIPTION
                    try
                    {
                        if (MyIRCd.Commands.ContainsKey("SERVERRECEIVE") == false)
                        {
                            SendLogMessage("Services", "NewServer", BlackLight.Services.Error.Errors.FATAL, "SERVERRECEIVE missing from protocol", "", "", "");
                            return false;
                        }
                        Command cmd = MyIRCd.Commands["SERVERRECEIVE"];
                        Command cmdAlt = MyIRCd.Commands["SERVERALTRECEIVE"];
                        if (Source != null)
                        {

                            if (Source is BlackLight.Services.Nodes.Server)
                            {
                                    BlackLight.Services.Nodes.Server tHostServer = ((BlackLight.Services.Nodes.Server) Source);
                                    BlackLight.Services.Nodes.Server tServer = GetServer(arguments[cmd.getParameterIndex("SERVERNAME")]);
                                    if (tServer != null)
                                    {
                                        SendLogMessage("Services", "NewServer", BlackLight.Services.Error.Errors.FATAL, "Collision, received message for a server that already exists", "", "", "");
                                        //NOTE TO SELF MAKE THIS HAWT
                                        Disconnect();
                                        return false;
                                    }
                                    tServer = new BlackLight.Services.Nodes.Server(arguments[cmd.getParameterIndex("SERVERNAME")], this);
                                    if (cmd.hasParameter("SERVERNUMERIC"))
                                    {
                                        if (cmd.parameterCount() == 4 && arguments.Count < 4)
                                        {
                                            if (arguments[arguments.Count - 1].ToUpper().StartsWith("U"))
                                            {
                                                string[] unrealData = arguments[arguments.Count - 1].Split(new char[] { ' ' });
                                                if (unrealData[0].Contains("-"))
                                                {
                                                    if (unrealData.Length > 1)
                                                    {
                                                        for (int x = 1; x < unrealData.Length - 1; x++)
                                                        {
                                                            MyHost.description += unrealData[x] + " ";
                                                        }
                                                    }
                                                    tServer.description += unrealData[unrealData.Length - 1];
                                                    tServer.numeric = int.Parse(unrealData[0].Substring(unrealData[0].LastIndexOf("-") + 1));
                                                    SendLogMessage("Services", "NewServer", BlackLight.Services.Error.Errors.ERROR, "Word", MyHost.numeric.ToString(), "", "");
                                                }
                                                else
                                                {
                                                    if (cmdAlt.hasParameter("SERVERDESCRIPTION"))
                                                    {
                                                        if (cmdAlt.getParameterIndex("SERVERDESCRIPTION") < arguments.Count - 1)
                                                        {
                                                            MyHost.description = arguments[cmdAlt.getParameterIndex("SERVERDESCRIPTION")];
                                                        }
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                if (cmdAlt.hasParameter("SERVERDESCRIPTION"))
                                                {
                                                    if (cmdAlt.getParameterIndex("SERVERDESCRIPTION") < arguments.Count - 1)
                                                    {
                                                        tServer.description = arguments[cmdAlt.getParameterIndex("SERVERDESCRIPTION")];
                                                    }
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (cmd.hasParameter("SERVERDESCRIPTION"))
                                                tServer.description = arguments[cmd.getParameterIndex("SERVERDESCRIPTION")];
                                            tServer.numeric = Convert.ToInt16(arguments[cmd.getParameterIndex("SERVERNUMERIC")]);
                                        }
                                    }
                                    else
                                    {
                                        if (cmd.hasParameter("SERVERDESCRIPTION"))
                                            tServer.description = arguments[cmd.getParameterIndex("SERVERDESCRIPTION")];
                                        tServer.numeric = tServer.id;
                                    }
                                    tServer.hostServer = tHostServer;
                                    tHostServer.leafs.Add(tServer);
                                    if (events.onServerEvent != null)
                                        events.onServerEvent(tServer.name, tServer);
                                    tServer = null;
                                }
                            }
                        else
                        {
                            MyHost = new BlackLight.Services.Nodes.Server(arguments[cmd.getParameterIndex("SERVERNAME")], this);

                            if (cmd.hasParameter("SERVERNUMERIC"))
                            {
                                if (cmd.parameterCount() == 4 && arguments.Count < 4)
                                {
                                    if (arguments[arguments.Count - 1].ToUpper().StartsWith("U"))
                                    {
                                        string[] unrealData = arguments[arguments.Count - 1].Split(new char[] { ' ' });
                                        if (unrealData[0].Contains("-"))
                                        {
                                            if (unrealData.Length > 1)
                                            {
                                                for (int x = 1; x < unrealData.Length - 1; x++)
                                                {
                                                    MyHost.description += unrealData[x] + " ";
                                                }
                                            }
                                            MyHost.description += unrealData[unrealData.Length - 1];
                                            MyHost.numeric = int.Parse(unrealData[0].Substring(unrealData[0].LastIndexOf("-")+1));
                                            SendLogMessage("Services", "NewServer", BlackLight.Services.Error.Errors.ERROR, "Word", MyHost.numeric.ToString(), "", "");
                                        }
                                        else
                                        {
                                            if (cmdAlt.hasParameter("SERVERDESCRIPTION"))
                                            {
                                                if (cmdAlt.getParameterIndex("SERVERDESCRIPTION") < arguments.Count - 1)
                                                {
                                                    MyHost.description = arguments[cmdAlt.getParameterIndex("SERVERDESCRIPTION")];
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (cmdAlt.hasParameter("SERVERDESCRIPTION"))
                                        {
                                            if (cmdAlt.getParameterIndex("SERVERDESCRIPTION") < arguments.Count - 1)
                                            {
                                                MyHost.description = arguments[cmdAlt.getParameterIndex("SERVERDESCRIPTION")];
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    if (cmd.hasParameter("SERVERDESCRIPTION"))
                                        MyHost.description = arguments[cmd.getParameterIndex("SERVERDESCRIPTION")];
                                    MyHost.numeric = Convert.ToInt16(arguments[cmd.getParameterIndex("SERVERNUMERIC")]);
                                }
                            }
                            else
                            {
                                if (cmd.hasParameter("SERVERDESCRIPTION"))
                                    MyHost.description = arguments[cmd.getParameterIndex("SERVERDESCRIPTION")];
                                MyHost.numeric = MyHost.id;
                            }
                            if (events.onServerEvent != null)
                                events.onServerEvent(MyHost.name, MyHost);
                        }
                        return true;
                    }
                    catch (Exception ex)
                    {
                        SendLogMessage("Services", "NewServer", BlackLight.Services.Error.Errors.ERROR, "Problem parsing", "", ex.Message, ex.StackTrace);
                        return false;
                    }
        }
Esempio n. 21
0
 public LogEvent(string Origin, string Method, BlackLight.Services.Error.Errors Type, string Message, string Extra, string Exception, string Trace)
 {
     this.Origin = Origin;
             this.Method = Method;
             this.Type = Type;
             this.Message = Message;
             this.Extra = Extra;
             this.Exception = Exception;
             this.Trace = Trace;
 }
Esempio n. 22
0
        private bool Nick(BlackLight.Services.Nodes.IRCUser Source, string command, List<string> arguments)
        {
            //Viable String Options
                    //--NICKNAME
                    //--HOPS
                    //--SERVERNAME
                    //---OR-SERVERNUMERIC
                    //--USERNAME
                    //--REALNAME
                    //--TIME
                    //--MODES
                    //--HOST
                    //--VHOST (OPTIONAL)
                    try
                    {
                        if (Source != null)
                        {
                            Command cmd = MyIRCd.Commands["CONNECTRECEIVE"];
                            if (arguments.Count == cmd.parameterCount())
                            {
                                /*
                                 * What?
                                // Here is the issue with the invention of timestamp its possible that the
                                // Remote server may think its up to us to resolve the collision
                                // In which case we should...
                                // The problem is when servers don't trust us enough to deal with it
                                // If thats the case we will deal with it, and then we will receive kill
                                // messages and other such rubbish later on...that sadly will
                                // Cause the services to think its desynced and spit out a log message
                                // Until I find another way to deal with this (add info in protocol file?)
                                // we are just going to have to live with it
                                if (LocalClients.Contains(tMatch.Groups["NICKNAME"].Value))
                                {
                                    LocalClient tClient = LocalClients[tMatch.Groups["NICKNAME"].Value];
                                    SendLogMessage("Services", "Nick", BlackLight.Services.Error.Errors.DEBUG, "New user collided with local client", "", "", "");
                                    if (tClient != null)
                                    {
                                        if (tClient.Time >= Base64.B64ToInt(tMatch.Groups["TIME"].Value))
                                        {
                                            SendLogMessage("Services", "Nick", BlackLight.Services.Error.Errors.DEBUG, "New user is older, passivly kill our client", "", "", "");
                                            tClient.Quit("Nick collision");
                                        }
                                    }
                                }
                                 */
                                if (LocalClients.Contains(arguments[cmd.getParameterIndex("NICKNAME")]))
                                {

                                    LocalClient tClient = LocalClients[arguments[cmd.getParameterIndex("NICKNAME")]];
                                    Commands.Send_Kill(this.MyName, arguments[cmd.getParameterIndex("NICKNAME")], "Nick Collision");
                                    SendLogMessage("Services", "Nick", BlackLight.Services.Error.Errors.DEBUG, "New user collided with local client", "", "", "");
                                }
                                if (GetClient(arguments[cmd.getParameterIndex("NICKNAME")]) == null)
                                {
                                    BlackLight.Services.Nodes.Client tUser = new BlackLight.Services.Nodes.Client(arguments[cmd.getParameterIndex("NICKNAME")], this);
                                    //tMatch.Groups("REALNAME")
                                    tUser.username = arguments[cmd.getParameterIndex("USERNAME")];
                                    tUser.host = arguments[cmd.getParameterIndex("HOST")];
                                    short tNumeric;
                                    if (cmd.hasParameter("SERVERNUMERIC"))
                                    {
                                        tNumeric = Convert.ToInt16(arguments[cmd.getParameterIndex("SERVERNUMERIC")]);
                                    }
                                    else
                                    {
                                        tNumeric = - 1;
                                    }

                                    if (arguments[cmd.getParameterIndex("SERVERNAME")] == MyHost.name || tNumeric == MyHost.numeric)
                                    {
                                        tUser.hostServer = MyHost;
                                    }
                                    else
                                    {
                                        BlackLight.Services.Nodes.ServiceList tServList;
                                        tServList = MyHost.GetAllServers();
                                        foreach (BlackLight.Services.Nodes.Server srv in tServList)
                                        {
                                            if (arguments[cmd.getParameterIndex("SERVERNAME")] == srv.name || tNumeric == srv.numeric)
                                            {
                                                tUser.hostServer = srv;
                                            }
                                        }
                                    }
                                    if (cmd.hasParameter("VHOST"))
                                        tUser.vHost = arguments[cmd.getParameterIndex("VHOST")];
                                    tUser.realname = arguments[cmd.getParameterIndex("REALNAME")];
                                    tUser.hostServer.users.Add(tUser);
                                    tUser.ParseModeSet(arguments[cmd.getParameterIndex("MODES")]);
                                    tUser.time = Base64.B64ToInt(arguments[cmd.getParameterIndex("TIME")]);
                                    if (events.onClientConnectEvent != null)
                                        events.onClientConnectEvent(tUser.name, tUser);
                                    tUser = null;
                                }
                                else
                                {
                                    SendLogMessage("Services", "Nick", BlackLight.Services.Error.Errors.ERROR, "New user nick collison", arguments[cmd.getParameterIndex("NICKNAME")], "", "");
                                }
                            }
                            else
                            {
                                if (Source is BlackLight.Services.Nodes.Client)
                                {
                                    cmd = MyIRCd.Commands["NICKRECEIVE"];
                                    if (arguments.Count == cmd.parameterCount())
                                    {
                                        if (GetClient(arguments[cmd.getParameterIndex("NEWNICK")]) == null)
                                        {
                                            BlackLight.Services.Nodes.Client tUser;
                                            tUser = ((BlackLight.Services.Nodes.Client) Source);
                                            string tOldNick = tUser.nick;
                                            tUser.nick = arguments[cmd.getParameterIndex("NEWNICK")];
                                            if (events.onNickEvent != null)
                                                events.onNickEvent(tOldNick, tUser.nick);
                                            tUser = null;
                                            tOldNick = null;
                                        }
                                        else
                                        {
                                            SendLogMessage("Services", "Nick", BlackLight.Services.Error.Errors.ERROR, "Nickname collision", "", "", "");
                                        }
                                    }
                                    else
                                    {
                                        SendLogMessage("Services", "Nick", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.ERROR, "Unable to match protocol with message received", "", "", "");
                                    }
                                }
                            }
                        }
                        return true;
                    }
                    catch (Exception ex)
                    {
                        SendLogMessage("Services", "Nick", BlackLight.Services.Error.Errors.ERROR, "Problem parsing", "", ex.Message, ex.StackTrace);
                        return false;
                    }
        }
Esempio n. 23
0
        public override void SendLogMessage(string Origin, string Method, BlackLight.Services.Error.Errors Type, string Message, string Extra, string Exception, string Trace)
        {
            try
                    {
                        if (events.LogMessageEvent != null)
                        {
                            if (log_buffer != null && log_buffer.Count > 0)
                            {
                                LogEvent tEvent;
                                while (log_buffer.Count > 0)
                                {
                                    tEvent = (LogEvent)log_buffer[0];
                                    events.LogMessageEvent(tEvent.Origin, tEvent.Method, tEvent.Type, tEvent.Message, tEvent.Extra, tEvent.Exception, tEvent.Trace);
                                    log_buffer.RemoveAt(0);
                                }
                            }
                            else
                                events.LogMessageEvent(Origin, Method, Type, Message, Extra, Exception, Trace);
                        }
                        else
                        {
                            Console.WriteLine("Adding to buffer");
                            if (log_buffer == null)
                                log_buffer = new ArrayList();

                            log_buffer.Add(new LogEvent(Origin,Method,Type,Message,Extra,Exception,Trace));

                        }
                    }
                    catch (Exception ex)
                    {
                        //throw ex;
                        Console.WriteLine(ex.Message + " " + ex.StackTrace);
                        //MessageBox.Show("hrm");
                    }
        }
Esempio n. 24
0
 private bool Notice(BlackLight.Services.Nodes.IRCUser Source, string command, List<string> arguments)
 {
     //TODO Make comply with all parameters in RFC, and receiver types
             //Viable String Options
             //--RECEIVER
             //--MESSAGE
             try
             {
                 if (Source != null&& Source is BlackLight.Services.Nodes.Client)
                 {
                     Command cmd = MyIRCd.Commands["NOTICERECEIVE"];
                     if (arguments.Count == cmd.parameterCount())
                     {
                         BlackLight.Services.Nodes.Client tUser = ((BlackLight.Services.Nodes.Client) Source);
                         string[] tMsgArray = arguments[cmd.getParameterIndex("MESSAGE")].Split(' ');
                         if (events.onNoticeEvent != null)
                             events.onNoticeEvent(tUser, arguments[cmd.getParameterIndex("RECEIVER")], tMsgArray);
                         tUser = null;
                     }
                     else
                     {
                         SendLogMessage("Services", "Notice", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.ERROR, "Unable to match protocol with message received", "", "", "");
                     }
                 }
                 return true;
             }
             catch (Exception ex)
             {
                 SendLogMessage("Services", "Notice", BlackLight.Services.Error.Errors.ERROR, "Problem parsing", "", ex.Message, ex.StackTrace);
                 return false;
             }
 }
Esempio n. 25
0
        private bool Channel_Kick(BlackLight.Services.Nodes.IRCUser Source, string command, List<string> arguments)
        {
            //Viable String Options
                    //--NICKNAME
                    //--CHANNEL
                    //--REASON
                    try
                    {
                        if (Source != null)
                        {
                            Command cmd = MyIRCd.Commands["KICKRECEIVE"];
                            if (arguments.Count == cmd.parameterCount())
                            {
                                int tChannelIndex = Channels.IndexOf(arguments[cmd.getParameterIndex("CHANNEL")]);
                                if (tChannelIndex < 0)
                                {
                                    SendLogMessage("Services", "Kick", BlackLight.Services.Error.Errors.ERROR, "Recived kick for channel that does not exist", arguments[cmd.getParameterIndex("CHANNEL")], "", "");
                                    return false;
                                }

                                // Dim tUser As Client = Source
                                BlackLight.Services.Nodes.Client tKicked = GetClient(arguments[cmd.getParameterIndex("NICKNAME")]);
                                if (Channels[tChannelIndex].channelMembers.Contains(tKicked))
                                {
                                    Channels[tChannelIndex].channelMembers.Remove(Channels[tChannelIndex].channelMembers[tKicked]);
                                    if (tKicked.channels.Contains(Channels[tChannelIndex]))
                                    {
                                        tKicked.channels.Remove(Channels[tChannelIndex]);
                                    }
                                    else
                                    {
                                        SendLogMessage("Services", "Kick", BlackLight.Services.Error.Errors.ERROR, "Channel Lists Desync: member has no record of channel", "", "", "");
                                    }
                                }
                                else if (tKicked.channels.Contains(Channels[tChannelIndex]))
                                {
                                    tKicked.channels.Remove(Channels[tChannelIndex]);
                                    SendLogMessage("Services", "Kick", BlackLight.Services.Error.Errors.ERROR, "Channel Lists Desync: channel has no record of member", "", "", "");
                                }
                                else
                                {
                                    SendLogMessage("Services", "Kick", BlackLight.Services.Error.Errors.ERROR, "Recieved kick for invalid channel member", "", "", "");
                                }

                                if (Channels[tChannelIndex].channelMembers.Count == 0)
                                {
                                    Channels.RemoveAt(tChannelIndex);
                                }
                                if (events.onKickEvent != null)
                                    events.onKickEvent(Source.name, tKicked.nick, arguments[cmd.getParameterIndex("REASON")]);
                            }
                            else
                            {
                                SendLogMessage("Services", "Kick", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.ERROR, "Unable to match protocol with message received", "", "", "");
                            }
                            return true;
                        }
                        return false;
                    }
                    catch (Exception ex)
                    {
                        SendLogMessage("Services", "Kick", BlackLight.Services.Error.Errors.ERROR, "Problem parsing", "", ex.Message, ex.StackTrace);
                        return false;
                    }
        }
Esempio n. 26
0
 private bool NullFunction(BlackLight.Services.Nodes.IRCUser Source, string command, List<string> arguments)
 {
     return false;
 }
Esempio n. 27
0
        private bool Channel_Topic(BlackLight.Services.Nodes.IRCUser Source, string command, List<string> arguments)
        {
            //Viable String Options
                    //--WHOSET
                    //--TIME
                    //--CHANNEL
                    //--TOPIC
                    try
                    {
                        if (Source != null)
                        {
                            Command cmd = MyIRCd.Commands["TOPICRECEIVE"];
                            if (arguments.Count == cmd.parameterCount())
                            {
                                int tChannelIndex = Channels.IndexOf(arguments[cmd.getParameterIndex("CHANNEL")]);
                                if (tChannelIndex < 0)
                                {
                                    SendLogMessage("Services", "Topic", BlackLight.Services.Error.Errors.ERROR, "Channel does not exist", arguments[cmd.getParameterIndex("CHANNEL")], "", "");
                                    return false;
                                }

                                Channels[tChannelIndex].topic.text = arguments[cmd.getParameterIndex("TOPIC")];
                                Channels[tChannelIndex].topic.setBy = arguments[cmd.getParameterIndex("WHOSET")];
                                if (arguments[cmd.getParameterIndex("TIME")].StartsWith("!"))
                                {
                                    Channels[tChannelIndex].topic.time = Base64.B64ToInt(arguments[cmd.getParameterIndex("TIME")]);
                                }
                                else
                                {
                                    Channels[tChannelIndex].topic.time = int.Parse(arguments[cmd.getParameterIndex("TIME")]);
                                }
                            }
                            else
                            {
                                SendLogMessage("Services", "Topic", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.ERROR, "Unable to match protocol with message received", "", "", "");
                            }
                            return true;
                        }
                        return false;
                    }
                    catch (Exception ex)
                    {
                        SendLogMessage("Services", "Topic", BlackLight.Services.Error.Errors.ERROR, "Problem parsing", "", ex.Message, ex.StackTrace);
                        return false;
                    }
        }
Esempio n. 28
0
 private bool Ping(BlackLight.Services.Nodes.IRCUser Source, string command, List<string> arguments)
 {
     //Viable String Options
             //--REMOTESERVERNAME
             //--SERVERNAME
             try
             {
                 Command cmd = MyIRCd.Commands["PINGLOCALRECEIVE"];
                 if (arguments.Count == cmd.parameterCount())
                 {
                     Commands.Send_Ping(MyName, arguments[cmd.getParameterIndex("REMOTESERVERNAME")]);
                     SendLogMessage("Services", "Ping", BlackLight.Services.Error.Errors.DEBUG, "PoooING PooooONG", "", "", "");
                     if (events.onPingEvent != null)
                         events.onPingEvent();
                 }
                 else
                 {
                     cmd = MyIRCd.Commands["PINGREMOTERECEIVE"];
                     if (arguments.Count == cmd.parameterCount())
                     {
                         Commands.Send_Ping(MyName, arguments[cmd.getParameterIndex("REMOTESERVERNAME")]);
                         SendLogMessage("Services", "Ping", BlackLight.Services.Error.Errors.DEBUG, "PoooING PooooONG", "", "", "");
                         if (events.onPingEvent != null)
                             events.onPingEvent();
                     }
                     else
                     {
                         SendLogMessage("Services", "Ping", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.ERROR, "Unable to match protocol with message received", "", "", "");
                     }
                 }
                 return true;
             }
             catch (Exception ex)
             {
                 SendLogMessage("Services", "Ping", BlackLight.Services.Error.Errors.ERROR, "Problem parsing", "", ex.Message, ex.StackTrace);
                 return false;
             }
 }
Esempio n. 29
0
 public abstract void SendLogMessage(string Origin, string Method, BlackLight.Services.Error.Errors Type, string Message, string Extra, string Exception, string Trace);
Esempio n. 30
0
        private bool PrivMsg(BlackLight.Services.Nodes.IRCUser Source, string command, List<string> arguments)
        {
            // Make comply with RFC and all receiver types
                    //Viable String Options
                    //--RECEIVER
                    //--MESSAGE
                    try
                    {
                        if (Source != null&& Source is BlackLight.Services.Nodes.Client)
                        {
                            Command cmd = MyIRCd.Commands["PRIVMSGRECEIVE"];
                            if (arguments.Count == cmd.parameterCount())
                            {
                                BlackLight.Services.Nodes.Client tUser = ((BlackLight.Services.Nodes.Client) Source);
                                short LocalIndex;
                                LocalClient tDest;
                                string tReciever;
                                if (arguments[cmd.getParameterIndex("RECEIVER")].IndexOf("@") >= 1)
                                {
                                    tReciever = arguments[cmd.getParameterIndex("RECEIVER")].Substring(0, arguments[cmd.getParameterIndex("RECEIVER")].IndexOf("@"));
                                }
                                else
                                {
                                    tReciever = arguments[cmd.getParameterIndex("RECEIVER")];
                                }
                                LocalIndex = Convert.ToInt16(LocalClients.IndexOf(tReciever));
                                string[] tMsgArray = arguments[cmd.getParameterIndex("MESSAGE")].Split(' ');
                                if (LocalIndex >= 0)
                                {
                                    tDest = LocalClients[LocalIndex];
                                    tDest.OnMsg(tUser, tMsgArray);
                                }

                                if (events.onPrivMsgEvent != null)
                                    events.onPrivMsgEvent(tUser, tReciever, tMsgArray);

                            }
                            else
                            {
                                SendLogMessage("Services", "PrivMSG", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.ERROR, "Unable to match protocol with message received", "", "", "");
                            }
                        }
                        return true;
                    }
                    catch (Exception ex)
                    {
                        SendLogMessage("Services", "PrivMSG", BlackLight.Services.Error.Errors.ERROR, "Problem parsing", "", ex.Message, ex.StackTrace);
                        return false;
                    }
        }
Esempio n. 31
0
        private bool Server_Channel_Join(BlackLight.Services.Nodes.IRCUser Source, string command, List<string> arguments)
        {
            //Viable String Options
                    //--USERLIST
                    //--CHANNEL
                    //--TIME
                    //--MODESTRING
                    try
                    {
                        if (Source != null && Source is BlackLight.Services.Nodes.Server)
                        {
                            Command cmd = MyIRCd.Commands["SJOINRECEIVE"];
                            if (arguments.Count == cmd.parameterCount())
                            {
                                int tChannelIndex;
                                if (Channels.Contains(arguments[cmd.getParameterIndex("CHANNEL")]) == false)
                                {
                                    tChannelIndex = Channels.Add(new BlackLight.Services.Nodes.Channel(arguments[cmd.getParameterIndex("CHANNEL")], this));
                                }
                                else
                                {
                                    tChannelIndex = Channels.IndexOf(arguments[cmd.getParameterIndex("CHANNEL")]);
                                }
                                Channels[tChannelIndex].parseModeSet(arguments[cmd.getParameterIndex("MODESTRING")]);
                                string[] tUserList = arguments[cmd.getParameterIndex("USERLIST")].Split(' ');
                                BlackLight.Services.Nodes.Client tUser;
                                short tInt = 0;
                                short sType = -1;
                                string tModes = "";
                                foreach (string TNick in tUserList)
                                {
                                    // RaiseEvent onDebug("SJOIN-Join Nick: " & TNick & " Channel: " & tMatch.Groups("CHANNEL").Value)
                                    sType = MyIRCd.SJOINType(TNick);
                                    if (sType > 0)
                                    {
                                        // for later support of channel access lists
                                        switch (sType)
                                        {
                                                //Ban
                                            case 1:
                                                break;
                                                //Except
                                            case 2:
                                                break;
                                                //Invite
                                            case 3:
                                                break;
                                        }
                                    }
                                    else
                                    {
                                        if (sType == 0)
                                        {
                                            tModes = MyIRCd.ReadySJOINModes(TNick);
                                            tUser = GetClient(MyIRCd.ReadySJOINNick(TNick));
                                        }
                                        else
                                            tUser = GetClient(TNick);

                                        if (tUser != null)
                                        {
                                            int tMemberIndex = Channels[tChannelIndex].channelMembers.Add(new BlackLight.Services.Nodes.ChanMember(tUser, this));
                                            tUser.channels.Add(Channels[tChannelIndex]);
                                            foreach (char tChar in tModes)
                                            {
                                                if (MyIRCd.StatusModes.IndexOf(tModes[tInt]) < 0)
                                                {
                                                    tModes.Replace(tChar.ToString(), "");
                                                    //RaiseEvent onIRCError("Invalid mode received")
                                                    SendLogMessage("Services", "SJOIN", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.ERROR, "Invalid mode received", "Bad protocol?", "", "");
                                                }
                                                else
                                                {
                                                    Channels[tChannelIndex].channelMembers[tMemberIndex].addMode(tChar);
                                                }
                                            }
                                            if (events.onJoinEvent != null)
                                                events.onJoinEvent(MyIRCd.ReadySJOINNick(TNick), arguments[cmd.getParameterIndex("CHANNEL")]);
                                        }
                                        else
                                        {
                                            SendLogMessage("Services", "SJOIN", BlackLight.Services.Error.Errors.ERROR, "Recieved SJOIN for a client that does not exist", MyIRCd.ReadySJOINNick(TNick), "", "");
                                        }
                                    }
                                }

                            }
                            else
                            {
                                SendLogMessage("Services", "SJOIN", BlackLight.Services.Error.Errors.DEBUG | BlackLight.Services.Error.Errors.ERROR, "Unable to match protocol with message received", "", "", "");
                            }
                            return true;
                        }
                        return false;
                    }
                    catch (Exception ex)
                    {
                        SendLogMessage("Services", "SJOIN", BlackLight.Services.Error.Errors.ERROR, "Problem parsing", "", ex.Message, ex.StackTrace);
                        return false;
                    }
        }
Esempio n. 32
0
        public virtual Drawing GetBlackLight(BlackLight blackLight)
        {
            const double BigRange = 0.43;
            const double SmallRange = 0.34;
            double       rotateReal = Math.Cos(Math.PI * 2 / 3), rotateImag = Math.Sin(Math.PI * 2 / 3);

            var drawingVisual = new DrawingVisual();

            using (var dc = drawingVisual.RenderOpen()) {
                var geometry = new StreamGeometry {
                };
                using (var sgc = geometry.Open()) {
                    double x = 0, y = 1;
                    sgc.BeginFigure(new Point(0.5 + SmallRange * x, 0.5 + SmallRange * y), false, true);
                    ComplexMultiply(ref x, ref y, rotateReal, rotateImag);
                    sgc.LineTo(new Point(0.5 + SmallRange * x, 0.5 + SmallRange * y), true, false);
                    ComplexMultiply(ref x, ref y, rotateReal, rotateImag);
                    sgc.LineTo(new Point(0.5 + SmallRange * x, 0.5 + SmallRange * y), true, false);

                    x = 0; y = -1;
                    sgc.BeginFigure(new Point(0.5 + SmallRange * x, 0.5 + SmallRange * y), false, true);
                    ComplexMultiply(ref x, ref y, rotateReal, rotateImag);
                    sgc.LineTo(new Point(0.5 + SmallRange * x, 0.5 + SmallRange * y), true, false);
                    ComplexMultiply(ref x, ref y, rotateReal, rotateImag);
                    sgc.LineTo(new Point(0.5 + SmallRange * x, 0.5 + SmallRange * y), true, false);
                }
                geometry.Transform = DefaultScaleTransform;
                geometry.Freeze();

                var defaultColor = Color.FromRgb(0x40, 0x40, 0x40);
                var brush        = new SolidColorBrush(defaultColor);
                var pen          = new Pen()
                {
                    Thickness = 1,
                    Brush     = brush
                };
                blackLight.ActivatedChanged += delegate {
                    if (blackLight.Activated)
                    {
                        brush.Color = Colors.Black;
                    }
                    else
                    {
                        brush.Color = defaultColor;
                    }
                };
                dc.DrawGeometry(null, pen, geometry);

                var ellipse = Freeze(new EllipseGeometry(new Point(0.5, 0.5), SmallRange, SmallRange)
                {
                    Transform = DefaultScaleTransform
                });
                dc.DrawGeometry(null, pen, ellipse);
                ellipse = Freeze(new EllipseGeometry(new Point(0.5, 0.5), BigRange, BigRange)
                {
                    Transform = DefaultScaleTransform
                });
                dc.DrawGeometry(null, Freeze(new Pen(Brushes.Black, 1)), ellipse);
            }
            return(drawingVisual.Drawing);
        }