Exemplo n.º 1
0
 public KickEventArgs(IrcChannel channel, IrcUser kicker, IrcUser kicked, string reason)
 {
     Channel = channel;
     Kicker = kicker;
     Kicked = kicked;
     Reason = reason;
 }
Exemplo n.º 2
0
 /// <summary>
 /// True if this channel is equal to another (compares names).
 /// </summary>
 /// <returns></returns>
 public bool Equals(IrcChannel other)
 {
     return(other.Name == Name);
 }
Exemplo n.º 3
0
        private static void Client_ChannelMessageRecieved(object sender, PrivateMessageEventArgs e)
        {
            try
            {
                // Is the sender an admin?
                client.WhoIs(e.PrivateMessage.User.Nick, who =>
                {
                    // Get the response
                    admin = settings.admins.Contains(who.LoggedInAs);
                    whoIs = who.LoggedInAs;

                    // Set the private message
                    message = e.PrivateMessage;

                    // Find the current channel
                    channel = client.Channels[e.PrivateMessage.Source];

                    // Log-Spam
                    if (!admin)
                        BaseUtils.Log(e.PrivateMessage.User.Nick + " in " + e.PrivateMessage.Source + ": " + e.PrivateMessage.Message);
                    else
                        BaseUtils.LogAdmin(e.PrivateMessage.User.Nick + " in " + e.PrivateMessage.Source + ": " + e.PrivateMessage.Message);

                    // Get the message
                    string msg = e.PrivateMessage.Message.Trim();

                    // If it should be a command
                    if (msg.StartsWith(settings.startChar))
                    {
                        // Mute
                        if (settings.muted.Contains(channel.Name) && !BaseUtils.Is(msg, settings.startChar + "unmute"))
                            return;

                        // Get all the methods
                        MethodInfo[] methods = Assembly.GetAssembly(typeof(IRCBot)).GetTypes().SelectMany(t => t.GetMethods(BindingFlags.Public | BindingFlags.Static)).ToArray() as MethodInfo[];

                        string start = settings.startChar;

                        // Loop through them
                        foreach (MethodInfo method in methods)
                        {
                            // Check the Commands
                            foreach (Command c in method.GetCustomAttributes(typeof(Command), false))
                            {
                                // Check if the command is correct
                                if (BaseUtils.Is(msg, start + c.command))
                                {
                                    if (c.admin && !admin)
                                        break;
                                    method.Invoke(null, new[] { msg });
                                }
                            }

                            // Check the multipleCommands
                            foreach (MultipleCommand mc in method.GetCustomAttributes(typeof(MultipleCommand), false))
                            {
                                // Check if the command is correct
                                if (BaseUtils.Is(msg, start + mc.commandT) || BaseUtils.Is(msg, start + mc.commandF))
                                {
                                    if (mc.admin && !admin)
                                        break;
                                    method.Invoke(null, new object[] { msg, BaseUtils.Is(msg, start + mc.commandT) });
                                }
                            }
                        }
                    }
                    Logic.Run();
                });
            }
            catch { }
            whoIs = "";
        }