Beispiel #1
0
        static void Main(string[] args)
        {
            //Load all Plugin
            string[] files = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.dll");

            //Remove Non plugin library
            foreach (string s in files)
            {
                try
                {
                    ObjectHandle hwnd = Activator.CreateInstanceFrom(s, "IrcbotPlugin.PluginInfo");
                    plugs.Add(hwnd.Unwrap() as IPluginInfo);
                }
                catch { }
            }



            //Starting....

            #region Credit

            defaults = Console.ForegroundColor;

            Message.Logo();
            Message.Notice("Plugin Detected: " + plugs.Count);
            Console.WriteLine("");
            Console.WriteLine("");

            ConsoleColor old = Console.ForegroundColor;
            for (int i = 0; i < plugs.Count; i++)
            {
                Console.Write("Loaded: ");
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.Write(plugs[i].name);
                Console.ForegroundColor = old;
                Console.Write("   Written by: ");
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.Write(plugs[i].author);
                Console.ForegroundColor = old;
                Console.Write("   Version: ");
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine(plugs[i].version);
                Console.ForegroundColor = old;
            }


            Console.WriteLine("");
            Console.WriteLine("");
            Console.WriteLine("Press any key to start");
            Console.ReadKey();

            #endregion


            Console.WriteLine("Checking Connection....");
            Ping      p  = new Ping();
            PingReply ps = p.Send("google.it");

            if (ps.Status == IPStatus.Success)
            {
                Console.WriteLine("Connection Success.");
            }

            //Try to read last configration
            try
            {
                StreamReader sr = new StreamReader("data.txt");
                string       line;
                while ((line = sr.ReadLine()) != null)
                {
                    if (line.StartsWith("ip"))
                    {
                        string[] t = line.Split(':');
                        host = t[1];
                    }

                    if (line.StartsWith("port"))
                    {
                        string[] t = line.Split(':');
                        port = t[1];
                    }
                }

                goto end;
            }
            catch
            { }



hostname:
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("");
            Console.WriteLine("Insert hostname or ip address");
            Console.ForegroundColor = defaults;
            Console.WriteLine("");
            Console.Write("Host/IP> ");
            host = Console.ReadLine();

            Console.WriteLine(host);

            try
            {
                p  = new Ping();
                ps = p.Send(host);

                if (ps.Status == IPStatus.Success)
                {
                    Message.Notice("Connection Success...");
                    Console.WriteLine("Plase insert Port of connection");
                    Console.Write("PORT:>");
                    port = Console.ReadLine();
                    Console.WriteLine("");
                    Console.WriteLine("");
                    Message.Notice("Want to save configuration to file?");
                    Message.Notice("Y = Yes, N = No, Start client");
                    Console.Write("<Y/N> ");


                    StreamWriter sw = new StreamWriter("data.txt");
                    sw.WriteLine("ip:" + host);
                    sw.WriteLine("port:" + port);
                    sw.Close();

                    goto end;
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Message.Error("Hostname wrong or Offline");
                    Console.WriteLine("");
                }
            }
            catch
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Message.Error("Hostname wrong or Offline");
                Console.WriteLine("");
                goto hostname;
            }


end:



            WindowManager.UpdateWindow(100, 48);
            WindowManager.SetWindowTitle("IRCBotter");
            IrcBot bot = new IrcBot(host, port, "#test", "IrcBotter");
            bot.plugs = plugs; //Assign plugin to IrcEngine
            new Client(host, port, bot);
        }
Beispiel #2
0
        public Client(string ip, string port, IrcBot bot) : base(0, 0, Console.WindowWidth, Console.WindowHeight, null)
        {
            bots = bot;
            var displayAlertBtn = new Button(2, 20, "Display Alert", "displayAlertBtn", this)
            {
                Action = delegate() { new Alert("This is an Alert!", this, ConsoleColor.White); }
            };

            List <string> opts = new List <string>()
            {
                "hello", "world", "yawww", "Yammmm"
            };
            var cb = new Dropdown(0, 0, opts, "1", this);

            cb.DropdownItems = new List <DropdownItem>(opts.Select(_ => new DropdownItem(_, 10, "2", this)).ToArray());
            cb.Selectable    = true;

            var displayConfirmBtn = new Button(1, 1, "Display Confirm", "displayConfirmBtn", this)
            {
                Action = delegate()
                {
                    IrcDraw(false);
                    var cf = new Confirm("Open System Menu?", this, ConsoleColor.White);
                    if (cf.ShowDialog() == ConsoleDraw.DialogResult.OK)
                    {
                        //Add Label
                        var lb  = new Label("Channel List", 1, 1, "chlist", this);
                        var lb2 = new Label("Registred User", 1, 25, "rgnicklabel", this);
                        var lb3 = new Label("Boot Controls", 10, 1, "botctrllbl", this);
                        var lb4 = new Label("Allow Public Commands", 13, 5, "cb1lb", this);
                        var lb5 = new Label("Enable Opers Commands", 15, 5, "cb2lb", this);
                        var lb6 = new Label("Allow User Registration", 17, 5, "cb3lb", this);
                        var lb7 = new Label("Auto Reconnection", 19, 5, "cb3lb", this);

                        //Channel List
                        opts = bots.engine.Channels;
                        cb   = new Dropdown(3, 1, opts, "1", this);

                        //Registred Nick
                        List <string> regnick = bots.engine.Nicks;
                        var           rgnick  = new Dropdown(3, 25, regnick, "regnick", this);
                        rgnick.DropdownItems = new List <DropdownItem>(regnick.Select(x => new DropdownItem(x, 10, "2", this)).ToArray());



                        //CheckBox
                        var cb1 = new CheckBox(13, 1, "cb1", this)
                        {
                            Checked = true
                        };
                        var cb2 = new CheckBox(15, 1, "cb2", this)
                        {
                            Checked = true
                        };
                        var cb3 = new CheckBox(17, 1, "cb3", this)
                        {
                            Checked = false
                        };
                        var cb4 = new CheckBox(19, 1, "cb4", this)
                        {
                            Checked = true
                        };



                        CurrentlySelected = cb;

                        //Add Controls
                        Inputs.Add(cb);
                        Inputs.Add(lb);
                        Inputs.Add(rgnick);
                        Inputs.Add(lb2);
                        Inputs.Add(lb3);
                        Inputs.Add(cb1);
                        Inputs.Add(lb4);
                        Inputs.Add(cb2);
                        Inputs.Add(lb5);
                        Inputs.Add(cb3);
                        Inputs.Add(lb6);
                        Inputs.Add(cb4);
                        Inputs.Add(lb7);

                        Draw();
                    }
                    else
                    {
                        IrcDraw(true);
                    }
                }
            };



            CurrentlySelected = displayConfirmBtn;
            var cc = FromColor(System.Drawing.Color.Gray);

            this.BackgroundColour = cc;

            Draw();
            MainLoop();
        }