Example #1
0
        private void Host_OnMessageRecieved(object sender, Meebey.SmartIrc4net.IrcEventArgs e)
        {
            if (e.Data.Message == null)
                return;

            string remark;
            if (e.Data.Channel != null)
            {
                if (e.Data.Message.Length <= Host.Config.Nick.Length || !e.Data.Message.StartsWith(Host.Config.Nick, StringComparison.CurrentCultureIgnoreCase))
                    return;
                remark = e.Data.Message.Substring(Host.Config.Nick.Length + 1).Trim();
            }
            else
                remark = e.Data.Message.Trim();

            if (remark.Length == 0)
                return;

            string user = e.Data.Nick;

            /*const string BOT_CHANGE_TRIGGER = "bot.change";
            if (remark.StartsWith(BOT_CHANGE_TRIGGER, StringComparison.CurrentCultureIgnoreCase) && remark.Length > BOT_CHANGE_TRIGGER.Length)
            {
                string bottype = remark.Substring(BOT_CHANGE_TRIGGER.Length).Trim();

                ChatterBotType type;
                if (TryConvert(bottype, out type))
                {
                    ChangeBot(user, type);
                    Host.Reply(e.Data, Meebey.SmartIrc4net.SendType.Message, "Your personal bot type changed to " + type.ToString());
                }
                else
                    Host.Reply(e.Data, Meebey.SmartIrc4net.SendType.Message, "Unsupported or unknown bot type");

                return;
            }*/

            const string HELP_TRIGGER = "bot.help";
            if (remark.StartsWith(HELP_TRIGGER, StringComparison.CurrentCultureIgnoreCase))
            {
                Host.Reply(e.Data, Meebey.SmartIrc4net.SendType.Message, "Talk to me by saying '" + Host.Config.Nick + ": text'");
                /*Host.Reply(e.Data, Meebey.SmartIrc4net.SendType.Message, "Change your personal bot type by typing '" + BOT_CHANGE_TRIGGER + " typename'");

                StringBuilder message = new StringBuilder("Potential bots - ");

                var bots = Enum.GetNames(typeof(ChatterBotType));

                for (int i = 0; i < bots.Length; i++)
                {
                    message.Append(bots[i]);
                    if (i + 1 < bots.Length)
                        message.Append(", ");
                }

                Host.Reply(e.Data, Meebey.SmartIrc4net.SendType.Message, message.ToString());*/
                return;
            }

            Chat(e.Data, user, remark);
        }
Example #2
0
        private void Chat(Meebey.SmartIrc4net.IrcMessageData data, string user, string remark)
        {
            user = user.ToLower();

            if (!conversations.ContainsKey(user))
                conversations.Add(user, new ConversationState(this, ChatterBotType.CLEVERBOT));

            conversations[user].GetResponse(data, remark);
        }
        private void Host_OnMessageRecieved(object sender, Meebey.SmartIrc4net.IrcEventArgs e)
        {
            if (e.Data.Message == null)
                return;

            const string LOOKUP = "!urban";
            if (!e.Data.Message.StartsWith(LOOKUP, StringComparison.CurrentCultureIgnoreCase))
                return;

            string word = e.Data.Message.Substring(LOOKUP.Length).Trim();
            if (word.Length > 0)
                Lookup(e.Data, word);
        }
Example #4
0
        private void Host_OnMessageRecieved(object sender, Meebey.SmartIrc4net.IrcEventArgs e)
        {
            if (e.Data.Message == null)
                return;

            const string INVITE = "bot.join";
            if (e.Data.Message.Length <= INVITE.Length || !e.Data.Message.StartsWith(INVITE, StringComparison.CurrentCultureIgnoreCase))
                return;

            string channel = e.Data.Message.Substring(INVITE.Length).Trim();
            if (!TryJoinChannel(channel))
                Host.Reply(e.Data, Meebey.SmartIrc4net.SendType.Message, "No such channel");
        }
Example #5
0
 static void irc_OnError(object sender, Meebey.SmartIrc4net.ErrorEventArgs e)
 {
     logger.Error("IRC: " + e.ErrorMessage);
     if (e.ErrorMessage.Contains("Excess Flood")) //Do not localize
     {
         //Oops, we were flooded off
         logger.Warn("Initiating restart sequence after Excess Flood");
         Restart();
     }
 }
Example #6
0
 public void GetResponse(Meebey.SmartIrc4net.IrcMessageData msg, string remark)
 {
     Reply reply = new Reply(bot.Host, msg, session, remark);
     System.Threading.ThreadPool.QueueUserWorkItem(Reply.Think, reply);
 }
Example #7
0
        private void Host_OnMessageRecieved(object sender, Meebey.SmartIrc4net.IrcEventArgs e)
        {
            string user = e.Data.Nick.ToLower();
            if (!accounts.ContainsKey(user))
            {
                if (accountGroups.ContainsKey(DEFAULT_USER_GROUP_NAME))
                    accounts.Add(user, DEFAULT_USER_GROUP_NAME);
                else
                    return;
            }
            if (!accountGroups.ContainsKey(accounts[user]))
            {
                Host.Reply(e.Data, Meebey.SmartIrc4net.SendType.Message, "Your account does not belong to a valid account group.");
                RemoveAccount(user);
                return;
            }

            Command[] commands = Command.AllCommands;
            int index = -1;

            int cmdEnd = e.Data.Message.IndexOf(' ');
            if (cmdEnd < 1)
            {
                cmdEnd = e.Data.Message.Length;
                if (cmdEnd < 1)
                    return;
            }
            string command = e.Data.Message.Substring(0, cmdEnd);

            for (int i = 0; i < commands.Length; i++)
            {
                if (commands[i].Name.Equals(command, StringComparison.CurrentCultureIgnoreCase))
                {
                    index = i;
                    break;
                }
            }

            if (index < 0)
                return;

            foreach (var cmd in accountGroups[accounts[user]])
            {
                if (cmd == commands[index])
                {
                    try
                    {
                        commands[index].Execute(e.Data);
                    }
                    catch
                    {
                        Host.Reply(e.Data, Meebey.SmartIrc4net.SendType.Message, "Command execution failed.");
                    }
                    return;
                }
            }

            Host.Reply(e.Data, Meebey.SmartIrc4net.SendType.Message, "Your account does not have access to this command.");
            return;
        }
Example #8
0
 private static void MeebyIrc_OnReadLine(object sender, Meebey.SmartIrc4net.ReadLineEventArgs e)
 {
     //Console.WriteLine("onReadLine Event:" + e.Line);
 }
Example #9
0
 private static void MeebyIrc_OnErrorMessage(object sender, Meebey.SmartIrc4net.IrcEventArgs e)
 {
     Console.WriteLine("! " + e.Data.Message + " !");
 }
Example #10
0
 private static void MeebyIrc_OnChannelAction(object sender, Meebey.SmartIrc4net.ActionEventArgs e)
 {
     Console.WriteLine("OnChannelAction Event: " + e.Data);
 }
Example #11
0
 /// <summary>
 /// Handles errors sent from the server
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void irc_OnError(object sender, Meebey.SmartIrc4net.ErrorEventArgs e)
 {
 }
Example #12
0
 void c_OnChannelMessage(object sender, Meebey.SmartIrc4net.IrcEventArgs e)
 {
     SendKey(e.Data.Message);
 }
Example #13
0
 public AsyncLookup(DictionaryLookup plugin, Meebey.SmartIrc4net.IrcMessageData msg, string word)
 {
     this.plugin = plugin;
     this.msg = msg;
     this.word = word;
 }
Example #14
0
 private void Lookup(Meebey.SmartIrc4net.IrcMessageData msg, string word)
 {
     AsyncLookup lookup = new AsyncLookup(this, msg, word);
     System.Threading.ThreadPool.QueueUserWorkItem(AsyncLookup.Run, lookup);
 }
Example #15
0
 public Reply(IPluginHost host, Meebey.SmartIrc4net.IrcMessageData msg, ChatterBotSession session, string query)
 {
     this.host = host;
     this.msg = msg;
     this.session = session;
     this.query = query;
 }
Example #16
0
 public static void OnError(object sender, Meebey.SmartIrc4net.ErrorEventArgs e)
 {
     System.Console.WriteLine("Error: " + e.ErrorMessage);
     irc.Reconnect();
     Exit();
 }
Example #17
0
 //Todo: Fix userlist loading.
 public static void OnNames(string channel, string[] userlist, Meebey.SmartIrc4net.Data ircdata)
 {
     Array.Sort(userlist);
     foreach (string user in userlist)
     {
         Form1.GlobalAccess.Invoke(new Action(() =>
         {
             if (user.Length > 0)
             {
                 Form1.GlobalAccess.ChatUsersBox.Text += user + Environment.NewLine;
             }
         }));
     }
 }
Example #18
0
 private static void MeebyIrc_OnAutoConnectError(object sender, Meebey.SmartIrc4net.AutoConnectErrorEventArgs e)
 {
     Console.WriteLine("OnAutoConnectError Event: " + e.Exception);
 }
Example #19
0
 public static void OnError(object sender, Meebey.SmartIrc4net.ErrorEventArgs e)
 {
     System.Console.WriteLine("Error: " + e.ErrorMessage);
     pi.stopPreludeEngine();
     //Exit();
 }
Example #20
0
 private static void MeebyIrc_OnError(object sender, Meebey.SmartIrc4net.ErrorEventArgs e)
 {
     Console.WriteLine("OnError Event: " + e.Data.Message);
 }
Example #21
0
 void irc_OnError(object sender, Meebey.SmartIrc4net.ErrorEventArgs e)
 {
     Error.ShowError(new Exception("SmartIrc4Net error: " + e.ErrorMessage));
 }
Example #22
0
 private static void MeebyIrc_OnJoin(object sender, Meebey.SmartIrc4net.JoinEventArgs e)
 {
     Console.WriteLine("! JOINED: " + e.Data.Nick);
 }
Example #23
0
 static void irc_OnError(object sender, Meebey.SmartIrc4net.ErrorEventArgs e)
 {
     Console.WriteLine("ERROR: " + e.ErrorMessage);
 }
 private void Client_OnError(object sender, Meebey.SmartIrc4net.ErrorEventArgs e)
 {
     Console.WriteLine("Error: {0}", e.ErrorMessage);
 }
Example #25
0
 public void OnError(object sender, Meebey.SmartIrc4net.ErrorEventArgs e)
 {
 }
Example #26
0
 // this method handles when we receive "ERROR" from the IRC server
 public static void OnError(object sender, Meebey.SmartIrc4net.ErrorEventArgs e)
 {
     ExitWithMsg("OnError: " + e.ErrorMessage);
 }
Example #27
0
File: Bot.cs Project: pluraldj/Bot
 private void OnError(object sender, Meebey.SmartIrc4net.ErrorEventArgs e)
 {
     log.Error(e.ErrorMessage);
     Exit();
 }