private void InitializeChatBots()
 {
     factory = new ChatterBotFactory();
     manualResetEvent = new ManualResetEvent(false);
     ChatterBot bot2 = factory.Create(ChatterBotType.PANDORABOTS, "b0dafd24ee35a477");
     bot2session = bot2.CreateSession();
 }
Exemple #2
0
        public List<ChatReply> RunGroupCommand(string[] args, SteamKit2.SteamFriends.ChatMsgCallback callback)
        {
            ChatterBotFactory factory = new ChatterBotFactory();

            ChatterBot bot1 = factory.Create(ChatterBotType.PANDORABOTS, "b0dafd24ee35a477");
            ChatterBotSession bot1session = bot1.CreateSession();
            if (args.Length == 1)
            {
                finalOutcome = args[1];
            }
            else
            {
                outcome.Append(args[1] + "3276b04755a7e48f50b9bf9db9a79932");
                if (args.Length >= 2)
                {
                    for (int i = 2; i <= args.Length - 1; i++)
                    {
                        outcome.Append(args[i]);
                        if (i != args.Length - 1)
                        {
                            outcome.Append("3276b04755a7e48f50b9bf9db9a79932");
                        }
                    }
                }
                finalOutcome = outcome.ToString();
                finalOutcome = finalOutcome.Replace("3276b04755a7e48f50b9bf9db9a79932", " ");
            }
            try
            {
                botsay = bot1session.Think(finalOutcome);
                if (finalOutcome.Contains("console"))
                {
                    botsay = "Consoles suck. Master race forever!";
                }
                if (finalOutcome.Contains("watch") && finalOutcome.Contains("dogs"))
                {
                    botsay = "Watch Dogs is a retarded abortion from Ubisoft inorder to make players 'choose' their shitty uPlay system which doesn't work half the time and is a complete waste and hog of system resources to do something another program (Steam) already does.";
                }
                if (finalOutcome.Contains("hl3") || finalOutcome.Contains("Half Life 3") || finalOutcome.Contains("Half-Life 3") )
                {
                    botsay = "Half Life 3 will always be there... In your heart... Oh! And in GabeN's beard!";
                }
            }
            catch (Exception e)
            {
                botsay = "Ugh, I can't think today. Talk to me later.";
            }

            botsay = botsay.Replace("Pandorabots.com", "https://github.com/JustHev/PCMR-Bot"); //teehee :p
                botsay = botsay.Replace("Pandora", Program.steamFriends.GetPersonaName().ToString());
                botsay = botsay.Replace("Chomsky", Program.steamFriends.GetPersonaName().ToString());

            List<ChatReply> chatreply = new List<ChatReply>();
            chatreply.Add(new ChatReply(callback.ChatRoomID, botsay));
            botsay = "";
            finalOutcome = "";
            outcome.Clear();
            return chatreply;
        }
Exemple #3
0
 public ChatForm()
 {
     InitializeComponent();
     factory = new ChatterBotFactory();
     //God
     //bot1 = factory.Create(ChatterBotType.PANDORABOTS, "923c98f3de35606b");
     //Chompsky
     //bot1 = factory.Create(ChatterBotType.PANDORABOTS, "b0dafd24ee35a477");
     ChatterBot bot1 = factory.Create(ChatterBotType.CLEVERBOT);
     bot1session = bot1.CreateSession();
 }
 public JKAChatSession()
 {
     try
     {
         ChatterBotFactory factory = new ChatterBotFactory();
         session = factory.Create(ChatterBotType.CLEVERBOT).CreateSession();
     }
     catch
     {
         session = null;
     }
 }
        public ChannelBot(IrcChannel channel)
        {
            Channel = channel;

            Channel.UsersListReceived += ChannelOnUsersListReceived;
            Channel.UserJoined += ChannelOnUserJoined;
            Channel.UserLeft += ChannelOnUserLeft;
            Channel.MessageReceived += ChannelOnMessageReceived;
            var b = new ChatterBotAPI.ChatterBotFactory().Create(ChatterBotType.CLEVERBOT);
            Bot = b.CreateSession();
            //HelloTimerOnElapsed(null, null);
        }
Exemple #6
0
		public static void Main(string[] args) {
			ChatterBotFactory factory = new ChatterBotFactory();
			
			ChatterBot bot1 = factory.Create(ChatterBotType.CLEVERBOT);
			ChatterBotSession bot1session = bot1.CreateSession();
			
			ChatterBot bot2 = factory.Create(ChatterBotType.PANDORABOTS, "b0dafd24ee35a477");
			ChatterBotSession bot2session = bot2.CreateSession();
			
			string s = "Hi";
			while (true) {
				
				Console.WriteLine("bot1> " + s);
				
				s = bot2session.Think(s);
				Console.WriteLine("bot2> " + s);
				
				s = bot1session.Think(s);
			}
		}
Exemple #7
0
        public List<ChatReply> RunPrivateCommand(string[] args, SteamKit2.SteamFriends.FriendMsgCallback callback)
        {
            ChatterBotFactory factory = new ChatterBotFactory();

            ChatterBot bot1 = factory.Create(ChatterBotType.PANDORABOTS, "b0dafd24ee35a477");
            ChatterBotSession bot1session = bot1.CreateSession();
            if (args.Length == 0)
            {
                finalOutcome = args[0];
            }
            else
            {
                outcome.Append(args[0] + "3276b04755a7e48f50b9bf9db9a79932");
                if (args.Length >= 1)
                {
                    for (int i = 1; i <= args.Length - 1; i++)
                    {
                        outcome.Append(args[i]);
                        if (i != args.Length - 1)
                        {
                            outcome.Append("3276b04755a7e48f50b9bf9db9a79932");
                        }
                    }
                }
                finalOutcome = outcome.ToString();
                finalOutcome = finalOutcome.Replace("3276b04755a7e48f50b9bf9db9a79932", " ");
            }
            try
            {
                botsay = bot1session.Think(finalOutcome);
                if (finalOutcome.Contains("console"))
                {
                    botsay = "Consoles suck. Master race forever!";
                }
                if (finalOutcome.Contains("watch_dogs") || finalOutcome.Contains("watch dogs"))
                {
                    botsay = "Watch Dogs is a retarded abortion from Ubisoft inorder to make players 'choose' their shitty uPlay system which doesn't work half the time and is a comeplete waste and hog of systen resources to do something another program (Steam) already does.";
                }
            }
            catch (Exception e)
            {
                botsay = "Ugh, I can't think today. Talk to me later.";
            }

            botsay = botsay.Replace("Pandorabots.com", "thewarpdimension.com");
            botsay = botsay.Replace("Pandora", Program.steamFriends.GetPersonaName().ToString());
            botsay = botsay.Replace("Chomsky", Program.steamFriends.GetPersonaName().ToString());

            List<ChatReply> chatreply = new List<ChatReply>();
            chatreply.Add(new ChatReply(callback.Sender, botsay));
            // Fix glitches via nullifying
            botsay = "";
            finalOutcome = "";
            outcome.Clear();
            return chatreply;
        }
Exemple #8
0
        static void Main(string[] args)
        {
            try
            {
                Utils.loadPlugin();
                /*Console.WriteLine("try");
                Console.WriteLine(Commands.commands.Count);
                Console.ReadKey();
                Utils.loadPlugin();
                Console.WriteLine("loading again");
                Console.WriteLine(Commands.commands.Count);
                Console.ReadKey();*/
                NetworkStream stream;
                TcpClient irc;
                string inputLine;
                StreamReader reader;
                //   try
                //  {
                irc = new TcpClient(SERVER, PORT);
                stream = irc.GetStream();
                reader = new StreamReader(stream);
                writer = new StreamWriter(stream);
                writer.AutoFlush = true;
                writer.WriteLine(USER);
                writer.WriteLine("NICK " + NICK);
                //   Utils.join(CHANNEL);
                ChatterBotFactory factory = new ChatterBotFactory();
                ChatterBot clever = factory.Create(ChatterBotType.CLEVERBOT);
                ChatterBot jabber = factory.Create(ChatterBotType.JABBERWACKY);
                ChatterBot panda = factory.Create(ChatterBotType.PANDORABOTS, "d689f7b8de347251");
                jab = jabber.CreateSession();
                pan = panda.CreateSession();
                ses = clever.CreateSession();
                //Thread t = new Thread(new ThreadStart(oper));
                //   t.Start();
                Commands.init();
                opered = false;
                while (true)
                {
                    while ((inputLine = reader.ReadLine()) != null)
                    {

                        int numeric;
                        string noinit = inputLine.Substring(1);
                        string text = noinit.Substring(noinit.IndexOf(':') + 1);
                        string[] splitted = text.Split(' ');
                        string[] param = inputLine.Split(' ');
                        if (param.Length > 3 && (param[3].Equals("=") || param[3].Equals("@")))
                        {
                            parseUsers(param[4], inputLine);
                        }
                        // :[email protected] MODE #pulse +v Sync
                        else if (param.Length > 4 && param[1] == "MODE")
                        {
                            writer.WriteLine("WHOIS " + param[4]);
                        }
                        else if (param.Length > 1 && param[1] == "NICK")
                        {
                            string user = inputLine.Substring(1, inputLine.IndexOf('!') - 1);
                            if (users.ContainsKey(user))
                            {
                                var temp = users[user];
                                users.Remove(user);
                                users.Add(text, temp);
                                //  users.Add()
                            }
                        }
                        else if (param.Length > 3 && param[1] == "KICK")
                        {
                            string chan = param[2];
                            string user = param[3];
                            channels.Remove(chan);
                            if (user == NICK)
                            {
                                Utils.join(chan);
                            }
                            else
                            {
                                if (users.ContainsKey(user))
                                {
                                    if (users[user].ContainsKey(chan))
                                    {
                                        users[user].Remove(chan);
                                    }
                                }
                            }
                        }
                        else if (inputLine.ToLower().Contains("privmsg"))
                        {

                            string channel = inputLine.Split(' ')[2];
                            string user = inputLine.Substring(1, inputLine.IndexOf('!') - 1);
                            if (!Directory.Exists("chatlog"))
                            {
                                Directory.CreateDirectory("chatlog");
                            }
                            string date = DateTime.Now.Month + "-" + DateTime.Now.Day + "-" + DateTime.Now.Year;
                            File.AppendAllText("chatlog\\" + date + ";" + channel + ".txt", "[" + DateTime.Now.ToString() + "] <" + user + ">: " + text + "\r\n");
                            bool ispm = false;
                            if (inputLine.Split(' ')[2].Equals(NICK)) //private message
                            {
                                if (!splitted[0].StartsWith("!"))
                                {
                                    if (!pms.ContainsKey(user)) //cool bot mode but useless
                                    {
                                        pms.Add(user, panda.CreateSession());
                                    }
                                    //   writer.WriteLine("PRIVMSG " + user + " :" + pms[user].Think(text));
                                    Utils.initThink(pan, text, user);
                                }
                                ispm = true;
                            }
                            string command = splitted[0];
                            if (command.StartsWith("!"))
                            {

                                string rest = "";

                                if (command.Length > 1 && splitted.Length > 1)
                                {
                                    rest = text.Substring(command.Length + 1);
                                }
                                else
                                {
                                    rest = text;
                                }
                                command = command.ToLower();

                                //  else
                                {
                                    var cmds = Commands.commands;
                                    if (cmds.ContainsKey(command))
                                    {
                                        CommandPair cp = cmds[command];
                                        // if (users.ContainsKey(user))
                                        UserLevel lvl = Utils.getUserLevel(user, ispm ? "#pulse" : channel);
                                        if (lvl >= cp.ci.level)
                                        {
                                            if (splitted.Length >= cp.ci.args)
                                            {
                                                cp.exe(new CommandParams(ispm ? user : channel, user, rest, inputLine, splitted, writer, lvl));
                                                msg("#services", command + " executed by " + user + " on " + (ispm ? user : channel));
                                            }
                                            else
                                            {
                                                msg(ispm ? user : channel, "Not enough parameters! " + command + " requires " + cp.ci.args + " arguments");
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else if (inputLine.StartsWith("PING"))
                        {
                            writer.WriteLine("PONG " + inputLine.Split(' ')[1]);
                        }
                        else if (param.Length > 2 && (param[1] == "JOIN" || param[1] == "PART"))
                        {

                            if (inputLine.Split('!')[0].Substring(1).Equals(NICK))
                            {
                                string channel = param[2].Substring(1);
                                if (param[1] == "JOIN")
                                {

                                    Utils.admin(channel);
                                    channels.Add(channel.ToLower());
                                }
                                else
                                {
                                    channels.Remove("#" + channel.ToLower()); //for some reason no leading : when part
                                }
                            }
                        }
                        else if (param.Length > 3 && Int32.TryParse(param[1], out numeric))
                        {
                            if (numeric == 322) //channel listing
                            {
                                if (!noJoin.Contains(param[3].ToLower()))
                                {
                                    Utils.join(param[3]);
                                }
                            }
                            else if (numeric == 376) //end of motd
                            {
                                if (!opered)
                                {
                                    oper();
                                    opered = true;
                                }
                                //>> :exp.ulse.net 319 alex Sync :+#pulse #touhou ~#sync #minecraft
                            }
                            else if (numeric == 319) //whois channel list
                            {
                                string user = param[3];
                                string[] channels = text.Split(' ');
                                foreach (string s in from i in channels where !string.IsNullOrWhiteSpace(i) select i)
                                {
                                    UserLevel toAdd = UserLevel.NORMAL;
                                    switch (s[0])
                                    {
                                        case '+':
                                            toAdd = UserLevel.VOICE;
                                            break;
                                        case '%':
                                            toAdd = UserLevel.HOP;
                                            break;
                                        case '@':
                                            toAdd = UserLevel.OP;
                                            break;
                                        case '~':
                                            toAdd = UserLevel.OWNER;
                                            break;
                                        case '&':
                                            toAdd = UserLevel.ADMIN;
                                            break;
                                    }
                                    string channame = s;
                                    if (toAdd != UserLevel.NORMAL)
                                    {
                                        channame = channame.Substring(1); //getrid of symbol if  special status
                                        if (users.ContainsKey(user))
                                        {
                                            if (users[user].ContainsKey(channame))
                                            {
                                                users[user][channame] = toAdd;
                                            }
                                            else
                                            {
                                                users[user].Add(channame, toAdd);
                                            }
                                        }
                                        else
                                        {
                                            users.Add(user, new Dictionary<string, UserLevel>());
                                            users[user].Add(channame, toAdd);
                                        }
                                    }
                                    else
                                    {
                                        if (users.ContainsKey(user))
                                        {
                                            if (users[user].ContainsKey(channame))
                                            {
                                                users[user].Remove(channame);
                                                if (users[user].Count == 0)
                                                {
                                                    users.Remove(user);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        //if (!(inputLine.EndsWith("JOIN :" + CHANNEL) || inputLine.EndsWith("QUIT")))
                        {
                            Console.WriteLine(inputLine);
                        }
                    }
                    // Close all streams
                    writer.Close();
                    reader.Close();
                    irc.Close();
                }
            }
            catch (Exception e)
            {
                // Show the exception, sleep for a while and try to establish a new connection to irc server
                Console.WriteLine(e.StackTrace);
                Console.WriteLine(e.InnerException);
                Console.WriteLine(e);
                Thread.Sleep(5000);
                string[] argv = { };
                Console.WriteLine("restarting");
                Main(argv);
            }
        }
        private void ChannelOnMessageReceived(object sender, IrcMessageEventArgs ircMessageEventArgs)
        {
            if (ircMessageEventArgs.Source.Name == "GaryBot") return;
            //if (ircMessageEventArgs.Text.Trim().EndsWith("?"))
            //{
            //    this.Message("http://lmgtfy.com/?q=" + HttpUtility.UrlEncode(ircMessageEventArgs.Text));
            //}
            return;
            var from = ircMessageEventArgs.Source.Name.ToLower();
            var num = random.Next(0, 100);
            if (from.Contains(Who.ToLower()) || from.Contains("brine") || num > 55)
            {
                noDb0Counter = 0;
                dboResponded = true;
                var reply = "";

                while (String.IsNullOrWhiteSpace(reply))
                {
                    try
                    {
                        reply = Bot.Think(ircMessageEventArgs.Text);
                    }
                    catch (Exception)
                    {
                        try
                        {
                            Bot = new ChatterBotAPI.ChatterBotFactory().Create(ChatterBotType.CLEVERBOT).CreateSession();
                        }
                        catch
                        {

                        }
                    }
                }

                this.Message(reply);
            }
        }
Exemple #10
0
 public Chatbot()
 {
     factory = new ChatterBotFactory();
     bots = new Dictionary<ChatterBotType, ChatterBot>();
     conversations = new Dictionary<string,ConversationState>();
 }