public static bool CheckPluginIO(MeidoConfig conf, Logger log) { return (VerifyDirectory(conf.ConfigurationDirectory, log) && VerifyDirectory(conf.DataDirectory, log) && RwTest(conf.DataDirectory, log)); }
static int ParsePort(XElement config) { var portStr = (string)config.Element("port"); // Allow port to have the default of 6667. if (string.IsNullOrEmpty(portStr)) { return(MeidoConfig.DefaultPort); } int port; if (int.TryParse(portStr, out port)) { if (MeidoConfig.IsValidPortNumber(port)) { return(port); } else { return(0); } } else { return(-1); } }
public Meido(MeidoConfig config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } // We need these parameters for events, store them. conf = config; currentChannels = new List <string>(config.Channels); // Initialize log factory for this server/instance. var logFac = new LogFactory(config.ServerAddress); // Set aside some logging for ourself. log = logFac.CreateLogger("Meido"); // Throttling for triggers and outgoing messages. var tManager = new ThrottleManager(log); // Setup chatlogger and underlying LogWriter. logWriter = new LogWriter(); var chatLog = SetupChatlog(); ircComm = new IrcComm(irc, tManager, chatLog); meidoComm = new MeidoComm(config, logFac, log); var triggers = new Triggers( config.TriggerPrefix, tManager, logFac.CreateLogger("Triggers") ); // This must be instantiated before loading plugins and their triggers. dispatch = new Dispatcher( ircComm, triggers, new IrcEventHandlers(log) ); // Setup autoloading of ignores. meidoComm.LoadAndWatchConfig("Ignore", LoadIgnores); // Setup non-plugin triggers and register them. help = new Help(triggers); admin = new Admin(this, irc, meidoComm); RegisterSpecialTriggers(triggers); // Load plugins and setup their triggers/help. LoadPlugins(triggers); // Setting some SmartIrc4Net properties and event handlers. SetProperties(); SetHandlers(); reconnect = new AutoReconnect(irc); }
public MeidoComm(MeidoConfig conf, LogFactory factory, Logger meidoLog) { ConfDir = conf.ConfigurationDirectory; DataDir = conf.DataDirectory; logFac = factory; Log = meidoLog; watcher = new WatchConfig(ConfDir, Log); userAuths = new UserAuthManager("Auth.xml", watcher, logFac.CreateLogger("Auth")); }
public static Result ParseConfig(XElement config, out MeidoConfig meidoconf) { meidoconf = null; // Load the settings into variables. var server = (string)config.Element("server"); if (string.IsNullOrWhiteSpace(server)) { return(Result.NoServer); } var nick = (string)config.Element("nick"); if (string.IsNullOrWhiteSpace(nick)) { return(Result.NoNickname); } var prefix = ParsePrefix(config); if (prefix == null) { return(Result.TriggerWhitespace); } var port = ParsePort(config); if (port < 1) { return(Result.InvalidPortNumber); } var channels = ParseChannels(config); // Construct meidoconf with previously loaded values. meidoconf = new MeidoConfig(nick, server, port, channels, prefix); // Set optional properties on meidoconfig. meidoconf.ConfigurationDirectory = (string)config.Element("conf-dir"); meidoconf.DataDirectory = (string)config.Element("data-dir"); meidoconf.ChatlogDirectory = (string)config.Element("chatlog-dir"); return(Result.Success); }
static string ParsePrefix(XElement config) { var triggerPrefix = (string)config.Element("trigger-prefix"); // Default prefix for triggers is "." if (string.IsNullOrEmpty(triggerPrefix)) { return("."); } if (MeidoConfig.IsValidTriggerPrefix(triggerPrefix)) { return(triggerPrefix); } else { return(null); } }