Beispiel #1
0
        public TwitchBot(SQLiteConnection database, PluginManager pluginManager, ILogger logger, string botOwner)
        {
            Database = database;
            _logger = logger;
            _messageProcessor = new MessageProcessor(pluginManager, _logger);
            UserService = new UserService(database, _logger, botOwner);
            PluginDataService = new PluginDataService(database);

            IrcClient = new IrcClient(UserService, PluginDataService, _logger, botOwner);
        }
Beispiel #2
0
        public void ProcessMessage(ServerMessage serverMessage, IrcClient ircClient)
        {
            try
            {
                var messageWasHandled = false;

                foreach (var messageHandler in HandlerInstances.Where(messageHandler => messageHandler.Commands.Contains(serverMessage.Command)))
                {
                    messageHandler.Invoke(serverMessage, ircClient, _logger);
                    messageWasHandled = true;
                }

                if (!messageWasHandled)
                    _logger.Write($"No handler for command '{serverMessage.Command}' -> {serverMessage.OriginalMessage}");
            }
            catch (Exception e)
            {
                _logger.Write($"Exception: {e.Message}");
                _logger.WriteIndented($"Stacktrace: { e.StackTrace}");
                throw;
            }
        }