示例#1
0
        public static void Main(string[] args)
        {
            string version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
            Console.WriteLine("Prelude@# ("+version+") command line version, welcome user!");
            Console.WriteLine("if you want to stop chatting, enter: 'exit'");
            //initialize interface
            PreLudeInterface pi = new PreLudeInterface();

            //configure prelude
            //define path to mind file
            pi.loadedMind = "mind.mdu";
            //decide whether you want true randomness
            pi.quantumRandomness = false;
            pi.isSpeaking = true;
            pi.setProactiveMode(true);
            pi.avoidLearnByRepeating = true;

            pi.initializedAssociater = Mind.MatchingAlgorithm.Dice;

            //start your engine ...
            pi.initializeEngine();
            //here we go:
            while(!ind.StartsWith("exit"))
            {
                Console.Write("You say: ");
                ind = Console.ReadLine();
                logger.Trace("You say: " + ind);
                string answer = pi.chatWithPrelude(ind);
                Console.WriteLine("Prelude says: " + answer);
                logger.Trace("Prelude says: " + answer);
            }
            pi.stopPreludeEngine();
        }
示例#2
0
 public static void Main(string[] args)
 {
     Console.WriteLine("Prelude@# (0.5.0) command line version, welcome user!");
     Console.WriteLine("if you want to stop chatting, enter: 'exit'");
     //initialize interface
     pi = new PreLudeInterface();
     //auto speak handler (if bored...)
     pi.reportBoredom += new PreLudeInterface.AutoSpeakHandler(iamBored);
     //define path to mind file
     pi.loadedMind = "mind.mdu";
     //start your engine ...
     pi.initializeEngine();
     //here we go:
     while(!ind.StartsWith("exit"))
     {
         Console.Write("You say: ");
         ind = Console.ReadLine();
         Console.WriteLine("Prelude says: " + pi.chatWithPrelude(ind));
     }
     pi.stopPreludeEngine();
 }
        public Form1()
        {
            InitializeComponent();

            // Note: These use the Skype using reference
            skype.UserStatus += new _ISkypeEvents_UserStatusEventHandler(Skype_UserStatus);
            skype.CallStatus += new _ISkypeEvents_CallStatusEventHandler(Skype_CallStatus);
            skype.MessageStatus += new _ISkypeEvents_MessageStatusEventHandler(Skype_MessageStatus);

            // Note: These use the Skype class reference due to ambiguous reference issues
            cSkype = new SkypeClass();
            cSkype._ISkypeEvents_Event_AttachmentStatus += new _ISkypeEvents_AttachmentStatusEventHandler(OurAttachmentStatus);
            cSkype._ISkypeEvents_Event_ConnectionStatus += new _ISkypeEvents_ConnectionStatusEventHandler(OurConnectionStatus);

            // Used to catch our form closing so we can save checkbox information
            FormClosing += ByeBye;
            pi = new PreLudeInterface();
            pi.loadedMind = loadedMind;
            pi.isContributable = false;
            pi.isSpeaking = false;
            pi.proactiveMode = true;
            pi.initializeEngine();
        }
示例#4
0
        public static void Main(string[] args)
        {
            //this method is just for some tests
            //TestConnectionStability();
            //return;

            int cycle_cnt = 0;
            while (true)
            {
                cycle_cnt++;
                //Console.Clear();
                Console.WriteLine("Cycle: " + cycle_cnt);
                Thread.CurrentThread.Name = "Main";

                #region Settings
                string startupPath = Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
                if (File.Exists(startupPath + "\\settings.ini"))
                    profile = new Ini(startupPath + "\\settings.ini");
                else
                {
                    logger.Trace("Did not find" + startupPath);

                }
                channel = (string)profile.GetValue("Main", "Channel");
                nick = (string)profile.GetValue("Main", "Nick");
                real = (string)profile.GetValue("Main", "Real");
                #endregion

                #region IRC Setup
                irc = new IrcClient();
                irc.SendDelay = 500;
                irc.ActiveChannelSyncing = true;
                irc.OnChannelMessage += new IrcEventHandler(OnChannelMessage);
                irc.OnQueryMessage += new IrcEventHandler(OnQueryMessage);
                irc.OnBan += new BanEventHandler(OnBanMessage);

                irc.OnError += new Meebey.SmartIrc4net.ErrorEventHandler(OnError);
                irc.OnPart += new PartEventHandler(irc_OnPart);
                irc.OnRawMessage += new IrcEventHandler(OnRawMessage);
                if (proactiveMode)
                {
                    timer = new System.Timers.Timer();
                    timer.Elapsed += new System.Timers.ElapsedEventHandler(autoAnswering);
                }
                #endregion

                sl = new SortedList();

                Console.WriteLine("**********************************************************");
                Console.WriteLine("These are my settings: ");
                Console.WriteLine("Trying to connect to " + serverlist[0] + " on port " + port + " - joining channel: " + channel);
                Console.WriteLine("My nickname is: " + nick + " and my real name is: " + real);
                Console.WriteLine("**********************************************************");
                try
                {
                    irc.AutoRetry = true;
                    irc.AutoReconnect = true;
                    irc.Connect(serverlist, port);
                }
                catch (ConnectionException e)
                {
                    logger.Trace("couldn't connect! Reason: " + e.Message);
                }

                try
                {
                    // here we logon and register our nickname and so on
                    irc.OnRawMessage += new IrcEventHandler(irc_OnRawMessage);
                    irc.Login(nick, real);

                    //load all channels
                    irc.RfcList("");

                    Dictionary<string, int> chann = new Dictionary<string, int>();

                    // join the channel
                    irc.RfcJoin(channel);
                    irc.OnChannelAction += new ActionEventHandler(irc_OnChannelAction);

                    #region Prelude Setup
                    //initialize interface
                    logger.Trace("Loading Prelude...");
                    pi = new PreLudeInterface();
                    //define path to mind file
                    pi.loadedMind = "mind.mdu";
                    pi.avoidLearnByRepeating = true;
                    pi.initializedAssociater = Mind.MatchingAlgorithm.Dice;
                    //start your engine ...
                    pi.initializeEngine();
                    logger.Trace("Prelude loaded and initialized...");
                    #endregion

                    // spawn a new thread to read the stdin of the console, this we use
                    // for reading IRC commands from the keyboard while the IRC connection
                    // stays in its own thread
                    new Thread(new ThreadStart(ReadCommands)).Start();
                    irc.Listen();
                    // when Listen() returns our IRC session is over, to be sure we call
                    // disconnect manually
                    irc.Disconnect();
                }
                catch (ConnectionException)
                {
                    logger.Trace("Connection exception");
                    pi.stopPreludeEngine();
                }
                catch (Exception e)
                {
                    logger.Trace("Error occurred! Message: " + e.Message);
                    logger.Trace("Exception: " + e.StackTrace);
                    pi.stopPreludeEngine();

                }

                logger.Trace("Going to sleep");
                System.Threading.Thread.Sleep(5 * 60000);
                logger.Trace("===========================================");
            }
        }
示例#5
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Alternatively start program with parameters: ");
            Console.WriteLine("preludeIrc.exe server port #channelname");
            Console.WriteLine("");
            Thread.CurrentThread.Name = "Main";

            irc.SendDelay = 500;
            irc.ActiveChannelSyncing = true;
            irc.OnChannelMessage += new IrcEventHandler(OnChannelMessage);
            irc.OnQueryMessage += new IrcEventHandler(OnQueryMessage);
            irc.OnBan += new BanEventHandler(OnBanMessage);

            irc.OnError += new ErrorEventHandler(OnError);
            irc.OnRawMessage += new IrcEventHandler(OnRawMessage);
            if(proactiveMode)
            {
                timer = new System.Timers.Timer();
                timer.Elapsed += new System.Timers.ElapsedEventHandler(autoAnswering);
            }
            sl = new SortedList();
            string[] serverlist;
            serverlist = new string[] {"irc.dal.net"};
            int port = 6667;
            string channel = "#cybejaya";
            string nick = "preludini";
            string real = "PLEIRC";
            if(args.Length > 2)
            {
                serverlist[0] = args[0];
                port = Convert.ToInt32(args[1]);
                channel = args[2];
            }
            else
            {
                Console.WriteLine("Missing parameters on program start. Start this program with params 'server' 'port' '#channelname'");
            }
            Console.WriteLine("**********************************************************");
            Console.WriteLine("These are my settings: ");
            Console.WriteLine("Trying to connect to " + serverlist[0] + " on port " +
                              port + " - joining channel: " + channel);
            Console.WriteLine("My nickname is: " + nick + " and my real name is: " + real);
            Console.WriteLine("**********************************************************");
            try {
                // here we try to connect to the server and exceptions get handled
                irc.Connect(serverlist, port);
            } catch (ConnectionException e) {
                // something went wrong, the reason will be shown
                System.Console.WriteLine("couldn't connect! Reason: "+e.Message);
                Exit();
            }

            try {
                // here we logon and register our nickname and so on
                irc.Login(nick, real);
                // join the channel
                irc.RfcJoin(channel);

                // here we send just 3 different types of messages, 3 times for
                // testing the delay and flood protection (messagebuffer work)
                irc.SendMessage(SendType.Message, channel, "hi @ all");
                //irc.SendMessage(SendType.Action, channel, "thinks this is cool "+i.ToString());
                //irc.SendMessage(SendType.Notice, channel, "SmartIrc4net rocks "+i.ToString());

                //initialize interface
                pi = new PreLudeInterface();
                //define path to mind file
                pi.loadedMind = "mind.mdu";
                //start your engine ...
                pi.initializeEngine();

                // spawn a new thread to read the stdin of the console, this we use
                // for reading IRC commands from the keyboard while the IRC connection
                // stays in its own thread
                new Thread(new ThreadStart(ReadCommands)).Start();

                // here we tell the IRC API to go into a receive mode, all events
                // will be triggered by _this_ thread (main thread in this case)
                // Listen() blocks by default, you can also use ListenOnce() if you
                // need that does one IRC operation and then returns, so you need then
                // an own loop
                irc.Listen();

                // when Listen() returns our IRC session is over, to be sure we call
                // disconnect manually
                irc.Disconnect();
            } catch (ConnectionException) {
                // this exception is handled becaused Disconnect() can throw a not
                // connected exception
                Exit();
            } catch (Exception e) {
                // this should not happen by just in case we handle it nicely
                System.Console.WriteLine("Error occurred! Message: "+e.Message);
                System.Console.WriteLine("Exception: "+e.StackTrace);
                Exit();
            }
        }
示例#6
0
 void MenuFileOpenClick(object sender, System.EventArgs e)
 {
     openFileDialog1.Filter = strFilter;
     openFileDialog1.ShowDialog();
     if(openFileDialog1.FileName != "")
     {
         pi = new PreLudeInterface();
         loadedMind = openFileDialog1.FileName;
         pi.initializeEngine();
     }
 }
示例#7
0
        /// <summary>
        /// TODO: wenn eingabe in animationsliste, play animation - wenn nicht, random
        /// TODO: save last agent in registry
        /// TODO: if found melissa, start melissa, else merlin
        /// </summary>
        public MainForm()
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            StartPosition = FormStartPosition.CenterScreen;

            InitializeComponent();

            this.Text = "Prelude@# " +  System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();

            pi = new PreLudeInterface();
            pi.loadedMind = loadedMind;
            pi.isContributable = false;
            pi.isSpeaking = false;
            pi.proactiveMode = true;
            pi.reportBoredom += new PreLudeInterface.AutoSpeakHandler(iamBored);
            pi.initializeEngine();
            menuSettingsContribute.Checked = false;
            axAgent1.Hide();
            lastAgent = LoadLastAgent();
            inputBox.Focus();
            inputBox.Clear();
            if(lastAgent != "")
            {
                LoadAgent(lastAgent);
            }
            idleControl.Start();
            agentSpeakingChecker.Start();
        }