Browse Source

Added command to get all valid arguments given a users input.

Fixed dependent arguments.
Removed uneccesary files.
tags/3.0.0
Teknikode 4 years ago
parent
commit
6e68050d7b

+ 11
- 36
Combot/Bot.cs View File

@@ -428,46 +428,20 @@ namespace Combot
newCommand.Location = location;
newCommand.MessageType = messageType;
newCommand.Command = command;
// Check arguments against required arguments
List<CommandArgument> typeArguments = cmd.Arguments.FindAll(arg => arg.MessageTypes.Contains(messageType));
List<CommandArgument> validArguments = new List<CommandArgument>();
List<string> usedArgs = new List<string>();
if (argsOnly.Any())
{
usedArgs.AddRange(argsOnly.First().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList());
}
List<CommandArgument> validArguments = cmd.GetValidArguments(usedArgs, messageType);
if (argsOnly.Count > 0)
{
string[] argSplit = argsOnly.First().Split(new[] { ' ' }, typeArguments.Count, StringSplitOptions.RemoveEmptyEntries);

for (int i = 0; i < typeArguments.Count; i++)
{
if (argsOnly.Count > i)
{
}
}
int argIndex = 0;
for (int i = 0; i < typeArguments.Count && argIndex <= argSplit.GetUpperBound(0); i++)
string[] argSplit = argsOnly.First().Split(new[] { ' ' }, validArguments.Count, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < validArguments.Count && i <= argSplit.GetUpperBound(0); i++)
{
bool allowedArg = true;
if (typeArguments[i].DependentArguments.Count > 0)
{
allowedArg = typeArguments[i].DependentArguments.Exists(arg =>
{
if (newCommand.Arguments.ContainsKey(arg.Name))
{
string argValue = newCommand.Arguments[arg.Name];
return arg.Values.Exists(val => val.ToLower() == argValue.ToLower());
}
return false;
});
}
if (allowedArg)
{
newCommand.Arguments.Add(typeArguments[i].Name, argSplit[i]);
CommandArgument newArgument = new CommandArgument();
newArgument.Copy(typeArguments[i]);
validArguments.Add(newArgument);
argIndex++;
}
newCommand.Arguments.Add(validArguments[i].Name, argSplit[i]);
}
}
bool invalidArgs = false;
@@ -517,6 +491,7 @@ namespace Combot
IRC.SendNotice(location, missingArgument);
}
}

}
}
}

+ 0
- 2
Combot/Combot.csproj View File

@@ -72,9 +72,7 @@
<Compile Include="Modules\CommandMessage.cs" />
<Compile Include="Modules\Option.cs" />
<Compile Include="Types.cs" />
<Compile Include="Methods.cs" />
<Compile Include="Modules\Module.cs" />
<Compile Include="Properties.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>

+ 0
- 12
Combot/Methods.cs View File

@@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Combot
{
public class Methods
{
}
}

+ 42
- 0
Combot/Modules/Command.cs View File

@@ -81,5 +81,47 @@ namespace Combot.Modules
ShowHelp = command.ShowHelp;
SpamCheck = command.SpamCheck;
}

public List<CommandArgument> GetValidArguments(List<string> passedArgs, MessageType messageType)
{
List<CommandArgument> validArguments = new List<CommandArgument>();
for (int i = 0; i < Arguments.Count; i++)
{
if (Arguments[i].MessageTypes.Contains(messageType))
{
if (Arguments[i].DependentArguments.Count > 0)
{
if (Arguments[i].DependentArguments.Exists(arg => Arguments.Exists(val => val.Name == arg.Name)))
{
CommandArgument.DependentArgumentInfo checkedArgument = Arguments[i].DependentArguments.Find(dep => Arguments.Exists(val => val.Name == dep.Name));
int argIndex = Arguments.FindIndex(arg => arg.Name == checkedArgument.Name);
if (passedArgs.Count > argIndex)
{
if (checkedArgument.Values.Exists(check => check.ToLower() == passedArgs[argIndex].ToLower()))
{
CommandArgument newArgument = new CommandArgument();
newArgument.Copy(Arguments[i]);
validArguments.Add(newArgument);
}
}
else
{
CommandArgument newArgument = new CommandArgument();
newArgument.Copy(Arguments[i]);
newArgument.Required = true;
validArguments.Add(newArgument);
}
}
}
else
{
CommandArgument newArgument = new CommandArgument();
newArgument.Copy(Arguments[i]);
validArguments.Add(newArgument);
}
}
}
return validArguments;
}
}
}

+ 0
- 12
Combot/Properties.cs View File

@@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Combot
{
public class Properties
{
}
}

+ 0
- 12
IRCServices/AccessControl/Access.cs View File

@@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Combot.IRCServices.AccessControl
{
class Access
{
}
}

+ 1
- 2
IRCServices/IRCServices.csproj View File

@@ -54,14 +54,13 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AccessControl\Access.cs" />
<Compile Include="Channel.cs" />
<Compile Include="IRC.cs" />
<Compile Include="Messaging\GetError.cs" />
<Compile Include="Messaging\GetReply.cs" />
<Compile Include="Messaging\Messages.cs" />
<Compile Include="Messaging\MessageTypes.cs" />
<Compile Include="IRCSend.cs" />
<Compile Include="SendCommand.cs" />
<Compile Include="Nick.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TCP\TCPInterface.cs" />

IRCServices/IRCSend.cs → IRCServices/SendCommand.cs View File


+ 8
- 1
Modules/Help/Help.cs View File

@@ -116,7 +116,14 @@ namespace Combot.Modules.Plugins
Bot.IRC.SendNotice(command.Nick.Nickname, string.Format("\t\t\u0002{0}\u000F{1}", arg.Name, commandDesc));
if (arg.AllowedValues.Count > 0)
{
Bot.IRC.SendNotice(command.Nick.Nickname, string.Format("\t\tAllowed Values: \u0002{0}\u000F", string.Join(", ", arg.AllowedValues)));
Bot.IRC.SendNotice(command.Nick.Nickname, string.Format("\t\t\t\tAllowed Values: \u0002{0}\u000F", string.Join(", ", arg.AllowedValues)));
}
if (arg.DependentArguments.Count > 0)
{
foreach (CommandArgument.DependentArgumentInfo dependentArgument in arg.DependentArguments)
{
Bot.IRC.SendNotice(command.Nick.Nickname, string.Format("\t\t\t\tOnly used when \u0002{0}\u000F is \u0002{1}\u000F.", dependentArgument.Name, string.Join(", or ", dependentArgument.Values)));
}
}
});
}

+ 1
- 1
Modules/Weather Information/Module.config View File

@@ -1,6 +1,6 @@
{
"Name": "Weather Information",
"ClassName": "Weather",
"ClassName": "Weather_Information",
"Enabled": true,
"ChannelBlacklist": [],
"NickBlacklist": [],

+ 5
- 20
readme.md View File

@@ -1,35 +1,20 @@
# About IRCBot
# About Combot

Created by: Chris Woodward

The IRCBot is designed to provide an all-in-one solution for those who wish to run an IRC bot easily. It includes many useful features as well as fun games. It can even be used as your personal client!
Combot is designed to provide an all-in-one solution for those who wish to run an IRC bot easily. It includes many useful features as well as fun games. It can even be used as your personal client!

# **Combot is currently under development. It can break at any time until Release**

## Feature Set

* Bot API for making custom interfaces
* Automatic nick registration
* Ghost on Nick in Use
* Flood Protection
* Ping Requests
* Version Checker
* To be determined

## Installation - Windows

1) Download the Release.zip from the latest release in https://github.com/uncled1023/Combot/releases and extract the files to a directory of your choice.<br>
2) Run Combot.exe

## Installation - Linux (Alpha)

1) Install mono and libgdiplus packages.<br>
2) Download the Release-Mono.zip from the latest release and extract the files to a directory of your choice.<br>
* config/servers.xml contains all the server settings for the bot. Edit the default server and add more <server></server> if you want.<br>
* config/modules.xml contains all the module config settings. It is usually a good idea to separate them into separate folders/files for each server. You specify the modules.xml file in the server config.<br>

4) Open a terminal emulator and cd it to the directory with the Combot.exe.<br>
5) Type: `mono Combot.exe`

* Current Limitations: Does not display any output, some functions may not work, buggy.

## Bugs/Feature Requests

Please report all bugs you find to me so I can fix them as soon as possible. Also if you have any feature requests, feel free to send them to me as well.

Loading…
Cancel
Save