public IrcMsg(IrcComm irc, IrcEventArgs msg, string triggerPrefix) { Irc = irc; type = msg.Data.Type; Channel = msg.Data.Channel; Nick = msg.Data.Nick; Ident = msg.Data.Ident; Host = msg.Data.Host; ReturnTo = Channel ?? Nick; if (msg is ActionEventArgs e) { Message = e.ActionMessage; DoParts(Message.Split(' ')); // Don't parse trigger if it's an action message. } else { Message = msg.Data.Message; DoParts(msg.Data.MessageArray); Trigger = ParseTrigger(triggerPrefix); } }
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 Dispatcher(IrcComm ircComm, Triggers triggers, IrcEventHandlers ircHandlers) { irc = ircComm; this.triggers = triggers; ircEvents = ircHandlers; Standard = new Queue <Action>(); StartConsumeThread(Standard); triggerQueues = new Dictionary <Trigger, Queue <Action> >(); eventQueues = new Dictionary <IIrcHandler, Queue <Action> >(); }