-3

I'm trying to make an IRC Admin system but I need to make custom commands.

For example:

if (e.PrivateMessage.Message == ".ban") // add Custom time and reason
{
    Console.WriteLine("Master Requested .ban (Ban)");
}

The question is: how do I add a custom reason and time so I can write ".ban Banada Spamchat"

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Yakou
  • 1

2 Answers2

1

You probably want something like this:

var commands = new Dictionary<string, Action<string[]>>
{
    ["ban"] = HandleBanCommand,
};

var args = e.PrivateMessage.Split(' ');
if (args[0].StartsWith("."))
{
    if (commands.TryGetValue(args[0].Substring(1), out var command))
    {
        command(args);
    }
    else
    {
        // command not found...
    }
}

// ...

void HandleBanCommand(string[] args)
{
    if (args.Length < 3)
    {
        // arguments missing...
        return;
    }

    var user = args[1];
    var reason = args[2];
    // add duration, and increment the length above by 1

    // ban the user...
}
Xiaoy312
  • 14,292
  • 1
  • 32
  • 44
0

Can you make a little tutorial for a message box exemple.. and thanks for the help !:

if (e.PrivateMessage.Message == ".msgbox")
            {
                Console.WriteLine("IRC Admin Sent Command .msgbox (Message Box)");
                MessageBox((IntPtr)0, message, title, 0);

                so if i type .msgbox Annoncements test
            }

so if i can type .msgbox Annoncements test

Yakou
  • 1