/// <summary> /// Joins to the specified channels. /// </summary> /// <param name="channels"></param> /// <param name="connection"></param> public static void JoinToChannels(this IEnumerable<string> channels, Connection connection) { Parallel.ForEach(channels, chan => { if (chan.IsValidChannelName()) connection.Sender.Join(chan); Log.Debug("Joined channel: {0}", chan); }); }
/// <summary> /// Initializes a new instance of the <see cref="AlarisBase"/> class. /// </summary> /// <param name="configuration">The configuration object.</param> /// <param name="serverId"></param> /// <param name="parallelized">if set to <c>true</c> [parallelized].</param> /// <param name="additionalCommandAssemblies">The additional command assemblies.</param> protected AlarisBase(AlarisConfig configuration, byte serverId = 0, bool parallelized = true, params Assembly[] additionalCommandAssemblies) { if (_isInstantiated) return; _isInstantiated = true; IsParallelized = parallelized; Config = configuration.Config; _server = Config.Servers[serverId]; _serverId = serverId; ProcessConfiguration(); Instance = this; Log.Info("Initializing"); var sw = new Stopwatch(); sw.Start(); _crashHandler = new CrashHandler(); var addonInitializationTask = new Task(() => { if (AddonsEnabled) { Log.Info("Initializing AddonManager"); AddonManager = new AddonManager(); AddonManager.Initialize(); AddonManager.LoadPluginsFromDirectory(AddonDirectory); } }); var commandManagerInitializationTask = addonInitializationTask.ContinueWith(prev => { Log.Info("Setting up commands"); CommandManager = new CommandManager {CommandPrefix = "@"}; CommandManager.CreateMappings(); }); addonInitializationTask.Start(); Task.Factory.StartNew(() => { _scriptManager = new ScriptManager(_scriptsDir); _scriptManager.Run(); }); Log.Info("Starting Identd"); Identd.Start(_server.Nickname); var connectionArgs = new ConnectionArgs(_server.Nickname, _server.Address); _connection = new Connection(connectionArgs, true, false) { TextEncoding = Encoding.GetEncoding("Latin1") }; _connection.CtcpResponder = new CtcpResponder(_connection) { VersionResponse = "Alaris " + Utility.BotVersion, SourceResponse = "https://www.github.com/twl/alaris", UserInfoResponse = "Alaris multi-functional bot." }; Log.Info("Text encoding is {0}", _connection.TextEncoding.WebName); Log.Info("CTCP is enabled"); SetupHandlers(); Connect(); sw.Stop(); Log.Info("Startup time: {0} ms", sw.ElapsedMilliseconds); }
/// <summary> /// Create a new Sender for a specific connection. /// </summary> internal Sender(Connection connection) : base(connection) { }
internal CommandBuilder(Connection connection) { _connection = connection; _commandBuffer = new StringBuilder(MaxCommandSize); }