Beispiel #1
0
 /// <summary>
 /// Executes a remote command
 /// </summary>
 /// <param name="command"></param>
 public static void ExecuteRemoteCommand(Connection source, RemoteCommand command)
 {
     Irc.InjectConsoleMessage(ControlCharacter.Deserialize(command.Command));
     RemoteCommandResponse response = new RemoteCommandResponse();
     response.ID = command.ID;
     source.Send(response);
 }
Beispiel #2
0
        static void Main()
        {
            //set up environment
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //ask for token
            Token token;
            using (ConnectDialog dialog = new ConnectDialog(Token.LocalHostToken()))
            {
                DialogResult result = dialog.ShowDialog();
                if (result != DialogResult.OK)
                {
                    return;
                }
                token = dialog.ConnectToken;
            }

            //reset handling
            State.OnReset += new OnStateReset(OnReset);

            //init watcher
            Watcher.Init();

            //create form
            Form = new MainForm();

            //set up connection
            Bot = new Connection(new Listener.LogDelegate(Program.Log), token);
            Bot.OnReceive += new Connection.OnReceiveEventHandler(Fetcher.OnBotObject);

            //run application
            Form.Run();

            //kill bot
            try
            {
                Thread.Sleep(100);
                Bot.Stop();
                Thread.Sleep(100);
            }
            catch (Exception ex)
            {
                Log("Exception during connection shutdown: " + ex.Message);
            }

            //display messagebox on error
            if (Bot.State == ConnectionState.Error)
            {
                MessageBox.Show("The connection to desBot failed:\n" + Bot.GetError(), "Connection failed");
            }
        }