- Fixed multiple issues regarding Mono support. - Updated Readme with Linux instructions.tags/3.1.1
@@ -19,6 +19,7 @@ namespace Combot | |||
{ | |||
public event Action<CommandMessage> CommandReceivedEvent; | |||
public event Action<BotError> ErrorEvent; | |||
public event Action<string> LogEvent; | |||
public ServerConfig ServerConfig; | |||
public IRC IRC; | |||
public Database Database; | |||
@@ -185,6 +186,7 @@ namespace Combot | |||
public void LoadModules() | |||
{ | |||
Log("Loading Modules"); | |||
// Get all config files from Module directory | |||
string[] moduleLocations = Directory.GetDirectories(ServerConfig.ModuleLocation); | |||
foreach (string location in moduleLocations) | |||
@@ -195,17 +197,20 @@ namespace Combot | |||
public bool LoadModule(string module) | |||
{ | |||
Log(string.Format("Loading Module from: {0}", module)); | |||
Module newModule = new Module(); | |||
newModule.ConfigPath = module; | |||
newModule.LoadConfig(); | |||
if (newModule.Enabled && !Modules.Exists(mod => mod.ClassName == newModule.ClassName)) | |||
{ | |||
if (File.Exists(string.Format(@"{0}\{1}.dll", module, newModule.Name))) | |||
if (File.Exists(string.Format(Path.Combine(module, newModule.Name + ".dll")))) | |||
{ | |||
Log(string.Format("Creating instance of {0} module.", newModule.Name)); | |||
Module loadedModule = newModule.CreateInstance(this); | |||
if (loadedModule.Loaded) | |||
{ | |||
Log(string.Format("{0} module successfully loaded.", newModule.Name)); | |||
loadedModule.ModuleErrorEvent += HandleModuleErrorEvent; | |||
Modules.Add(loadedModule); | |||
return true; | |||
@@ -221,6 +226,7 @@ namespace Combot | |||
for (int i = 0; i < moduleList.Count; i++) | |||
{ | |||
UnloadModule(moduleList[i].Name); | |||
Log(string.Format("Unloaded {0} module.", moduleList[i].Name)); | |||
} | |||
} | |||
@@ -649,14 +655,18 @@ namespace Combot | |||
List<string> argsOnly = msgArgs.ToList(); | |||
argsOnly.RemoveAt(0); | |||
Log("Parsing Command " + command + " Now."); | |||
// Find the module that contains the command | |||
Module module = Modules.Find(mod => mod.Commands.Exists(c => c.Triggers.Contains(command)) && mod.Loaded && mod.Enabled); | |||
if (module != null) | |||
{ | |||
Log("Found Module " + module.Name); | |||
// Find the command | |||
Command cmd = module.Commands.Find(c => c.Triggers.Contains(command)); | |||
if (cmd != null) | |||
{ | |||
Log("Found Command " + cmd.Name); | |||
CommandMessage newCommand = new CommandMessage(); | |||
newCommand.Nick.Copy(sender); | |||
bool nickFound = false; | |||
@@ -827,5 +837,13 @@ namespace Combot | |||
ErrorEvent(error); | |||
} | |||
} | |||
public void Log(string message) | |||
{ | |||
if (LogEvent != null) | |||
{ | |||
LogEvent(message); | |||
} | |||
} | |||
} | |||
} |
@@ -68,6 +68,7 @@ namespace Combot.Modules | |||
) | |||
) | |||
{ | |||
Bot.Log("Checking Command " + command.Command); | |||
// Figure out access of the nick | |||
Command cmd = Commands.Find(c => c.Triggers.Contains(command.Command)); | |||
List<AccessType> nickAccessTypes = new List<AccessType>() { AccessType.User }; | |||
@@ -218,7 +219,7 @@ namespace Combot.Modules | |||
{ | |||
ConfigFileRWLock.EnterReadLock(); | |||
string path = Path.Combine(ConfigPath, "Module.json"); | |||
if (!File.Exists(path)) | |||
{ | |||
string defaultPath = Path.Combine(ConfigPath, "Module.Default.json"); |
@@ -28,6 +28,7 @@ namespace Console_Interface | |||
Bot Combot = new Bot(server); | |||
Combot.ErrorEvent += e => BotErrorHandler(e, Combot.ServerConfig.Name); | |||
Combot.LogEvent += e => LogEventHandler(e, Combot.ServerConfig.Name); | |||
// Incoming Messages | |||
Combot.IRC.Message.RawMessageEvent += (sender, e) => RawMessageHandler(sender, e, Combot.ServerConfig.Name); | |||
@@ -60,6 +61,12 @@ namespace Console_Interface | |||
} | |||
} | |||
private static void LogEventHandler(string message, string server) | |||
{ | |||
string msg = string.Format("[{0}] [{1}] [LOG] {2}", DateTime.Now.ToString("HH:mm:ss"), server, message); | |||
Console.WriteLine(msg); | |||
} | |||
private static void RawMessageHandler(object sender, string message, string server) | |||
{ | |||
string msg = string.Format("[{0}] [{1}] {2}", DateTime.Now.ToString("HH:mm:ss"), server, message); |
@@ -475,13 +475,15 @@ namespace Combot.IRCServices | |||
Nick changedNick = channel.GetNick(mode.Parameter); | |||
if (changedNick != null) | |||
{ | |||
PrivilegeMode priv; | |||
Enum.TryParse(mode.Mode.ToString(), out priv); | |||
if (mode.Set) | |||
{ | |||
changedNick.AddPrivilege((PrivilegeMode) Enum.Parse(typeof (PrivilegeMode), mode.Mode.ToString())); | |||
changedNick.AddPrivilege(priv); | |||
} | |||
else | |||
{ | |||
changedNick.RemovePrivilege((PrivilegeMode) Enum.Parse(typeof (PrivilegeMode), mode.Mode.ToString())); | |||
changedNick.RemovePrivilege(priv); | |||
} | |||
} | |||
break; |
@@ -52,7 +52,7 @@ namespace Combot.IRCServices.Messaging | |||
Regex errorRegex = new Regex(@"^ERROR :(?<Message>.+)", RegexOptions.None); | |||
Regex CTCPRegex = new Regex(@"^\u0001(?<Command>[^\s]+)\s?(?<Args>.*)\u0001", RegexOptions.None); | |||
string[] messages = tcpMessage.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); | |||
string[] messages = tcpMessage.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); | |||
foreach (string message in messages) | |||
{ | |||
@@ -244,10 +244,13 @@ namespace Combot.IRCServices.Messaging | |||
modeMsg.Channel = recipient; | |||
modeMsg.Nick = new Nick() { Nickname = senderNick, Realname = senderRealname, Host = senderHost }; | |||
string[] modeArgs = args.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); | |||
List<string> argList = modeArgs.ToList(); | |||
argList.RemoveAt(0); | |||
modeMsg.Modes.AddRange(_IRC.ParseChannelModeString(modeArgs[0].TrimStart(':'), string.Join(" ", argList))); | |||
if (!string.IsNullOrEmpty(args)) | |||
{ | |||
string[] modeArgs = args.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries); | |||
List<string> argList = modeArgs.ToList(); | |||
argList.RemoveAt(0); | |||
modeMsg.Modes.AddRange(_IRC.ParseChannelModeString(modeArgs[0].TrimStart(':'), string.Join(" ", argList))); | |||
} | |||
await Task.Run(() => | |||
{ | |||
@@ -263,25 +266,30 @@ namespace Combot.IRCServices.Messaging | |||
modeMsg.Modes = new List<UserModeInfo>(); | |||
modeMsg.Nick = new Nick() { Nickname = senderNick, Realname = senderRealname, Host = senderHost }; | |||
string[] modeArgs = args.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); | |||
char[] modeInfo = modeArgs[0].TrimStart(':').ToCharArray(); | |||
bool set = true; | |||
foreach (char mode in modeInfo) | |||
if (!string.IsNullOrEmpty(args)) | |||
{ | |||
if (mode.Equals('-')) | |||
{ | |||
set = false; | |||
} | |||
else if (mode.Equals('+')) | |||
{ | |||
set = true; | |||
} | |||
else if (mode.ToString() != string.Empty) | |||
string[] modeArgs = args.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries); | |||
char[] modeInfo = modeArgs[0].TrimStart(':').ToCharArray(); | |||
bool set = true; | |||
foreach (char mode in modeInfo) | |||
{ | |||
UserModeInfo newMode = new UserModeInfo(); | |||
newMode.Set = set; | |||
newMode.Mode = (UserMode)Enum.Parse(typeof(UserMode), mode.ToString()); | |||
modeMsg.Modes.Add(newMode); | |||
if (mode.Equals('-')) | |||
{ | |||
set = false; | |||
} | |||
else if (mode.Equals('+')) | |||
{ | |||
set = true; | |||
} | |||
else if (!string.IsNullOrEmpty(mode.ToString())) | |||
{ | |||
UserModeInfo newMode = new UserModeInfo(); | |||
newMode.Set = set; | |||
UserMode md; | |||
Enum.TryParse(mode.ToString(), out md); | |||
newMode.Mode = md; | |||
modeMsg.Modes.Add(newMode); | |||
} | |||
} | |||
} | |||
@@ -32,19 +32,21 @@ Combot is designed to provide an all-in-one solution for those who wish to run a | |||
## Requirements | |||
* MySQL v5.5 or greater | |||
* .NET Framework v4.5.1 | |||
* .NET Framework v4.5.1 or Mono Runtime >3.2.8 | |||
* Git (If using the GitVersionTask Nuget Package) | |||
## 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) Edit Combot.Servers.json to configure the bot for the correct servers, channels, owner information, and MySQL database.<br> | |||
3) If the database has not been created yet, import Database.sql from the master branch into the database.<br> | |||
4) Run Combot-Interface.exe | |||
1) Download the Release zip file from the latest release in https://git.teknik.io/Uncled1023/Combot/releases and extract the files to a directory of your choice.<br> | |||
2) Copy Combot.Servers.Default.json to Combot.Servers.json and configure the bot for the correct servers, channels, owner information, and MySQL database.<br> | |||
3) Run Combot-Interface.exe or Combot-CLI.exe | |||
## Installation - Linux | |||
## Installation - Linux (Ubuntu) | |||
This is currently untested and not supported. If you would like to venture into the realm of unreliability and errors, you can try running the Console Interface in Mono. | |||
1) Download the Release zip file from the latest release in https://git.teknik.io/Uncled1023/Combot/releases and extract the files to a directory of your choice.<br> | |||
2) Copy Combot.Servers.Default.json to Combot.Servers.json and configure the bot for the correct servers, channels, owner information, and MySQL database.<br> | |||
3) Install Mono-Complete: `sudo apt-get mono-complete` | |||
4) Run Combot-CLI.exe: `mono Combot-CLI.exe` | |||
## Building | |||
@@ -60,5 +62,5 @@ Please report all bugs you find to me so I can fix them as soon as possible. Al | |||
Email: admin@teknik.io<br> | |||
IRC: (irc.teknik.io)#Combot<br> | |||
IRC: (irc.rizon.net)#/g/technology<br> | |||
IRC: (irc.rizon.net)#Combot<br> | |||
Nick: Uncled1023 |