Пример #1
0
Файл: Bot.cs Проект: Gohla/Veda
        public Bot(IClient client, IStorageManager storage, ICommandManager command, IPluginManager plugin,
            IAuthenticationManager authentication, IPermissionManager permission)
        {
            _client = client;
            _storage = storage;
            _command = command;
            _plugin = plugin;
            _authentication = authentication;
            _permission = permission;

            _data = storage.Global().GetOrCreate<BotData>(_storageIdentifier);

            _replyHandler = new ReplyHandler(this, _data);
            _messsageHandler = new MessageHandler(this, _replyHandler, _data);
        }
Пример #2
0
        public BotClientConnection(IBot bot, IClientConnection connection, MessageHandler messageHandler, 
            ConnectionData data)
        {
            Bot = bot;
            Connection = connection;
            _messageHandler = messageHandler;
            _data = data;

            // Subscribe to received messages.
            _messageSubscription = Connection.ReceivedMessages
                .Where(m => !m.Sender.Equals(connection.Me))
                .Where(m => m.Type == ReceiveType.Message || m.Type == ReceiveType.Notice ||
                    m.Type == ReceiveType.Action)
                .Where(m => m.Sender.Type == MessageTargetType.User || m.Sender.Type == MessageTargetType.ChannelUser)
                .Subscribe(_messageHandler.ReceivedMessage);
        }