Beispiel #1
0
 protected internal static void Answer(Network n, Irc.IrcEventArgs e, string s)
 {
     if (e.Data.Type == Irc.ReceiveType.QueryMessage)
         n.SendMessage(Murphy.Irc.SendType.Message, e.Data.Nick, s);
     else
         n.SendMessage(Murphy.Irc.SendType.Message, e.Data.Channel, s);
 }
Beispiel #2
0
 protected internal static void AnswerWithQuery(Network n, Irc.IrcEventArgs e, string s)
 {
     n.SendMessage(Murphy.Irc.SendType.Message, e.Data.Nick, s);
 }
Beispiel #3
0
 protected internal static string GetFullUser(Network n, string nick)
 {
     Irc.IrcUser u = n.GetIrcUser(nick);
     return u.Nick + "!" + u.Ident + "@" + u.Host;
 }
Beispiel #4
0
        void Bot_OnPrivateMessage(Network n, Murphy.Irc.IrcEventArgs e)
        {
            if (e.Data.Message.StartsWith(BOT_CONTROL_SEQ))
            {
                string mes = e.Data.Message.Substring(1).Split(' ')[0].ToLower();
                bool isadmin = false;

                //Process Admin Commands
                if (Bot.isAdmin(e.Data.Nick))
                {
                    switch (mes)
                    {
                        case "ping":

                            isadmin = true;
                            break;
                    }
                }

                //Process Normal Commands
                if (!isadmin)
                {
                    switch (mes)
                    {
                        case "set":
                            validate(n, e);
                            break;
                        default:
                            //Answer(n, e, "I do not know that command, " + e.Data.Nick);
                            break;
                    }
                }
            }
        }
Beispiel #5
0
 protected internal static void Answer(Network n, Irc.JoinEventArgs e, string s)
 {
     n.SendMessage(Murphy.Irc.SendType.Message, e.Data.Channel, s);
 }
Beispiel #6
0
 protected void validate(Network n, Murphy.Irc.IrcEventArgs e)
 {
     if (Bot.isLoggedIn(e.Data.Nick))
     {
         if (IsMatch("^set (?<infotype>.*?) (?<info>.*?)$", e.Data.Message.Substring(BOT_CONTROL_SEQ.Length)))
         {
             //TODO! Check the InfoType is valid - for now accept invalis ones
             DataRow user = getAccount(e.Data.Nick);
             string encdata=enc.Encrypt(Matches["info"].Value);
             Dictionary<String, String> account = new Dictionary<string, string>();
             account.Add("account_id", user["ID"].ToString());
             account.Add("validation_type", Matches["infotype"].Value);
             account.Add("validation", encdata);
             db.Insert("validation", account);
             AnswerWithNotice(n, e, String.Format("Your information for "+ FormatBold("{0}")+" was successfully set. A moderator will validate this information shortly. Your registered email will be used as a point of contact for the validation process.", Matches["infotype"].Value));
         }
         else
         {
             AnswerWithNotice(n, e, FormatBold(String.Format("Command Usage: {0}set <INFOTYPE> <VALUE>", BOT_CONTROL_SEQ)));
         }
     }
     else
     {
         AnswerWithNotice(n, e, FormatBold(String.Format("{0}set can only be performed by a logged user. Command Usage: {0}set <INFOTYPE> <VALUE>", BOT_CONTROL_SEQ)));
     }
 }
Beispiel #7
0
        void Bot_OnChannelMessage(Network n, Murphy.Irc.IrcEventArgs e)
        {
            if (e.Data.Message.StartsWith(BOT_CONTROL_SEQ))
            {
                string mes = e.Data.Message.Substring(1).Split(' ')[0].ToLower();
                bool isadmin = false;

                //Process Admin Commands
                if (Bot.isAdmin(e.Data.Nick))
                {
                    switch (mes)
                    {
                        case "ping":

                            isadmin = true;
                            break;
                    }
                }

                //Process Normal Commands
                if (!isadmin)
                {
                    switch (mes)
                    {
                        case "help":
                            help(n, e);
                            break;
                        case "infotypes":
                            infotypes(n, e);
                            break;
                        case "set":
                            Answer(n, e, "OOPS!, " + e.Data.Nick +" you really should do that in private! (try adding /msg to the beginning)");
                            break;
                        default:

                            //Answer(n, e, "I do not know that command, " + e.Data.Nick);
                            break;
                    }
                }
            }
        }
Beispiel #8
0
        protected void infotypes(Network n, Murphy.Irc.IrcEventArgs e)
        {
            DataTable types;
            String query = "SELECT id \"ID\", validation_type \"TYPE\", description \"DESCRIPTION\" FROM validation_type;";
            types = db.GetDataTable(query);

            AnswerWithNotice(n, e, FormatBold("____________________________ ACCEPTED INFORMATION TYPES ____________________________ "));
            AnswerWithNotice(n, e, String.Format("   <INFOTYPE>                  <DESCRIPTION>",BOT_CONTROL_SEQ));
            foreach (DataRow type in types.Rows)
            {
                AnswerWithNotice(n, e, String.Format("   " + FormatBold("{0}") + "                  {1}", type["TYPE"], type["DESCRIPTION"]));
            }
        }
Beispiel #9
0
 protected void help(Network n, Murphy.Irc.IrcEventArgs e)
 {
     AnswerWithNotice(n, e, FormatBold(String.Format("_______________________________________________________________________________________", BOT_CONTROL_SEQ)));
     AnswerWithNotice(n, e, FormatBold(String.Format("                    W3LCOME TO THE BITCOIN REPUTATION MANAGEMENT SYSTEM                ", BOT_CONTROL_SEQ)));
     //AnswerWithNotice(n, e, String.Format("          ", BOT_CONTROL_SEQ));
     AnswerWithNotice(n, e, String.Format("   After registering your Business and GpG key with the system, you may login and manage the information used to provide a trust rating for your business.", BOT_CONTROL_SEQ));
     //AnswerWithNotice(n, e, FormatBold(String.Format("          ", BOT_CONTROL_SEQ)));
     AnswerWithNotice(n, e, String.Format("   " + FormatUnderlined("WHY REGISTER YOUR INFORMATION?"), BOT_CONTROL_SEQ));
     AnswerWithNotice(n, e, String.Format("   Each piece of verifiable, identifying information that you provide is used by our system to generate an overall 'Trust Rating' for your business. The more information you provide, the more accurately the Trust Rating we calculate will represent you.", BOT_CONTROL_SEQ));
     //AnswerWithNotice(n, e, String.Format("   ", BOT_CONTROL_SEQ));
     AnswerWithNotice(n, e, String.Format("   Members of the Bitcoin community will be able to request your trust rating and view  a profile of your business that ONLY REVEALS which types of information you have or", BOT_CONTROL_SEQ));
     AnswerWithNotice(n, e, String.Format("   have not provided.  This, coupled with our Trust Rating (which also utilises infoavailable to the public such as Domain Registration) will allow users to decide their own trust ratings amongst businesses and peers.", BOT_CONTROL_SEQ));
     //AnswerWithNotice(n, e, String.Format("          ", BOT_CONTROL_SEQ));
     AnswerWithNotice(n, e, String.Format("   " + FormatBold(FormatUnderlined("Commands:")), BOT_CONTROL_SEQ));
     AnswerWithNotice(n, e, String.Format("    " + FormatBold("{0}help") + " - Shows this help screen", BOT_CONTROL_SEQ));
     AnswerWithNotice(n, e, String.Format("    " + FormatBold("{0}set <INFOTYPE> <VALUE>") + " - registers a piece of info to your account of the type <INFOTYPE> ***PRIVATE MESSAGE", BOT_CONTROL_SEQ));
     AnswerWithNotice(n, e, String.Format("    " + FormatBold("{0}del <INFOTYPE>") + " - deletes a piece of info from your account of the type <INFOTYPE>", BOT_CONTROL_SEQ));
     AnswerWithNotice(n, e, String.Format("    " + FormatBold("{0}infotypes") + " - Lists all of the available information types accepted", BOT_CONTROL_SEQ));
     AnswerWithNotice(n, e, String.Format("    " + FormatBold("{0}profile") + " - Shows your complete profile to you via Private notice", BOT_CONTROL_SEQ));
     AnswerWithNotice(n, e, String.Format("    " + FormatBold("{0}profile <name>") + " - Shows the public profile for <name>", BOT_CONTROL_SEQ));
     AnswerWithNotice(n, e, String.Format("    " + FormatBold("{0}rank <name>") + " - Calculates the Trust Ranking for <name>", BOT_CONTROL_SEQ));
     AnswerWithNotice(n, e, FormatBold(String.Format("_______________________________________________________________________________________", BOT_CONTROL_SEQ)));
 }
Beispiel #10
0
        public Bot()
        {
            #region " Header "
            Console.WriteLine("Murphy: The #bitcoin-police IRC Bot  - v" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " - [http://www.bitcoinpolice.org]");
            Console.WriteLine("(c) 2011 Murphy, The Bitcoin-Police IRC Bot - Bitcrafted By TIGGR");
            Console.WriteLine("===============================================================================");
            Console.WriteLine("Murphy: The #bitcoin-police IRC Bot comes with absolutely no warranty.");
            Console.WriteLine("This is free software, and you are welcome to redistribute it under certain");
            Console.WriteLine("conditions. See the enclosed copy of the General Public License for details.");
            Console.WriteLine("===============================================================================");
            #endregion

            #region " Load Configuration "
            configuration = new XmlDocument();

            try
            {
                configuration.Load("Configuration.xml");
            }
            catch (XmlException e)
            {
                Console.WriteLine(e.Message);
            }

            //Load the Admins from config file
            foreach (XmlElement elem in configuration["Murphy"]["Config"].GetElementsByTagName("admin"))
            {
                admins.Add(elem.InnerText);
            }

            BOT_CONTROL_SEQ = configuration["Murphy"]["Config"].Attributes["ControlSeq"].Value;

            foreach (XmlElement e in configuration.GetElementsByTagName("Network")) {
                Network n = new Network();
                networks.Add(n);
                n.Name = e.Attributes["Name"].Value;
                n.Nickname = e.Attributes["Nickname"].Value;
                n.Realname = e.Attributes["Realname"].Value;
                n.Username = e.Attributes["Username"].Value;
                if (e.HasAttribute("Password")) {
                    n.UsePassword = true;
                    n.Password = e.Attributes["Password"].Value;
                }
                else
                    n.UsePassword = false;
                n.Port = int.Parse(e.Attributes["Port"].Value);
                n.SendDelay = int.Parse(e.Attributes["SendDelay"].Value);

                foreach (XmlElement f in e.GetElementsByTagName("Server"))
                    n.Servers.Add(f.Attributes["Address"].Value);

                foreach (XmlElement f in e.GetElementsByTagName("Channel"))
                    n.Channels.Add(f.Attributes["Name"].Value);

                n.OnBan += new Irc.BanEventHandler(OnBanHandler);
                n.OnChannelAction += new Irc.ActionEventHandler(OnChannelActionHandler);
                n.OnChannelActiveSynced += new Irc.IrcEventHandler(OnChannelActiveSyncedHandler);
                n.OnChannelMessage += new Irc.IrcEventHandler(OnChannelMessageHandler);
                n.OnChannelModeChange += new Irc.IrcEventHandler(OnChannelModeChangeHandler);
                n.OnChannelNotice += new Irc.IrcEventHandler(OnChannelNoticeHandler);
                n.OnChannelPassiveSynced += new Irc.IrcEventHandler(OnChannelPassiveSyncedHandler);
                n.OnConnected += new EventHandler(OnConnectedHandler);
                n.OnConnecting += new EventHandler(OnConnectingHandler);
                n.OnConnectionError += new EventHandler(OnConnectionErrorHandler);
                n.OnCtcpReply += new Irc.IrcEventHandler(OnCtcpReplyHandler);
                n.OnCtcpRequest += new Irc.IrcEventHandler(OnCtcpRequestHandler);
                n.OnDehalfop += new Irc.DehalfopEventHandler(OnDehalfopHandler);
                n.OnDeop += new Irc.DeopEventHandler(OnDeopHandler);
                n.OnDevoice += new Irc.DevoiceEventHandler(OnDevoiceHandler);
                n.OnDisconnected += new EventHandler(OnDisconnectedHandler);
                n.OnDisconnecting += new EventHandler(OnDisconnectingHandler);
                n.OnError += new Irc.ErrorEventHandler(OnErrorHandler);
                n.OnErrorMessage += new Irc.IrcEventHandler(OnErrorMessageHandler);
                n.OnHalfop += new Irc.HalfopEventHandler(OnHalfopHandler);
                n.OnInvite += new Irc.InviteEventHandler(OnInviteHandler);
                n.OnJoin += new Irc.JoinEventHandler(OnJoinHandler);
                n.OnKick += new Irc.KickEventHandler(OnKickHandler);
                n.OnModeChange += new Irc.IrcEventHandler(OnModeChangeHandler);
                n.OnMotd += new Irc.MotdEventHandler(OnMotdHandler);
                n.OnNames += new Irc.NamesEventHandler(OnNamesHandler);
                n.OnNickChange += new Irc.NickChangeEventHandler(OnNickChangeHandler);
                n.OnOp += new Irc.OpEventHandler(OnOpHandler);
                n.OnPart += new Irc.PartEventHandler(OnPartHandler);
                n.OnPing += new Irc.PingEventHandler(OnPingHandler);
                n.OnQueryAction += new Irc.ActionEventHandler(OnQueryActionHandler);
                n.OnQueryMessage += new Irc.IrcEventHandler(OnQueryMessageHandler);
                n.OnQueryNotice += new Irc.IrcEventHandler(OnQueryNoticeHandler);
                n.OnQuit += new Irc.QuitEventHandler(OnQuitHandler);
                n.OnRawMessage += new Irc.IrcEventHandler(OnRawMessageHandler);
                n.OnReadLine += new Irc.ReadLineEventHandler(OnReadLineHandler);
                n.OnRegistered += new EventHandler(OnRegisteredHandler);
                n.OnTopic += new Irc.TopicEventHandler(OnTopicHandler);
                n.OnTopicChange += new Irc.TopicChangeEventHandler(OnTopicChangeHandler);
                n.OnUnban += new Irc.UnbanEventHandler(OnUnbanHandler);
                n.OnUserModeChange += new Irc.IrcEventHandler(OnUserModeChangeHandler);
                n.OnVoice += new Irc.VoiceEventHandler(OnVoiceHandler);
                n.OnWho += new Irc.WhoEventHandler(OnWhoHandler);
                n.OnWriteLine += new Irc.WriteLineEventHandler(OnWriteLineHandler);
            }
            #endregion

            #region " Load Plugins "
            object[] o ={ this };
            foreach (System.IO.FileInfo f in new System.IO.DirectoryInfo("Plugins").GetFiles())
                if (f.Extension == ".dll") {
                    Console.WriteLine("Loading Plugins from Assembly '" + f.Name + "' ...");
                    Assembly a = System.Reflection.Assembly.LoadFile(f.FullName);
                    foreach (Type t in a.GetTypes())
                        if (t.BaseType == typeof(Plugin)) {
                            Plugin p = (Plugin)Activator.CreateInstance(t, o);
                            plugins.Add(p);
                        }
                }
            Console.WriteLine("===============================================================================");
            #endregion
        }
Beispiel #11
0
 static void bot_OnRawMessage(Network sender, IrcEventArgs e)
 {
     Console.WriteLine(e.Data.Nick + ": " + e.Data.Message);
 }
Beispiel #12
0
 void Bot_OnRawMessage(Network network, Irc.IrcEventArgs e)
 {
     Console.WriteLine(e.Data.RawMessage);
 }