Пример #1
0
        public void TestInitialize()
        {
            TestCleanup();

            _messageData = new MessageData("TestRunner", "testChannel", "!topic newTopic", new String[] { "!topic", "newTopic" });

            _messagingClientMock = new Mock<IMessagingClient>();

            _configurationMock = new Mock<IConfiguration>();
            _configurationMock.Setup(mock => mock.LoadClientConfiguration()).Returns(_clientConfiguration);

            _loggingMock = new Mock<ILogging>();

            _tryToGetOp = new TryToGetOp(new TimeSpan(1000), _messagingClientMock.Object, _configurationMock.Object, _loggingMock.Object);
        }
Пример #2
0
        public void ChannelMessageActionsTest_ChangeTopic_MessageWithoutCommand_NothingDone()
        {
            _messageData = new MessageData(String.Empty, "testChannel", "BANANAAAA!", new String[] { "BANANAAAA!" });

            _messagingClientMock.Setup(mock => mock.AmIChannelAdmin(It.Is<string>(a => a == _messageData.Channel))).Returns(false);

            _messagingClientMock.Verify(mock => mock.AmIChannelAdmin(It.Is<string>(a => a == _messageData.Channel)), Times.Never);
            _messagingClientMock.Verify(mock => mock.SendMessage(It.IsAny<string>(), It.IsAny<string>()), Times.Never);
            _messagingClientMock.Verify(mock => mock.ChangeTopic(It.IsAny<string>(), It.IsAny<string>()), Times.Never);

            _channelMessageActions.ChangeTopic(_messageData);

            _messagingClientMock.Verify(mock => mock.AmIChannelAdmin(It.IsAny<string>()), Times.Never);
            _messagingClientMock.Verify(mock => mock.SendMessage(It.IsAny<string>(), It.IsAny<string>()), Times.Never);
            _messagingClientMock.Verify(mock => mock.ChangeTopic(It.IsAny<string>(), It.IsAny<string>()), Times.Never);
        }
Пример #3
0
        /// <summary>
        /// Event-Handler, der bei dem Befehl !topic <neues Topic> im Channel das Topic setzt (sofern der Bot OP hat, und sonst einen Fehler ausgibt)
        /// </summary>
        /// <param name="messageData"></param>
        public void ChangeTopic(MessageData messageData)
        {
            string command = "!topic";

            if (messageData.MessageParts.Length == 0 || !messageData.MessageParts[0].StartsWith(command)) {
                return;
            }

            if (!_messagingClient.AmIChannelAdmin(messageData.Channel).Value)
            {
                _messagingClient.SendMessage(messageData.Channel, Texts.TopicChangeRequestedButIAmNotOperator);

                return;
            }

            string newTopic = PrepareTopic(messageData.Message, command, messageData.Nickname);

            _messagingClient.ChangeTopic(messageData.Channel, newTopic);
        }
Пример #4
0
        void IMessagingClient.RegisterEventHandler(EventType eventType, MessageReceivedEventHandler messageReceivedEventHandler)
        {
            switch (eventType)
            {
                case EventType.ChannelMessage:
                    Action<object, IrcEventArgs> handler = ((s, e) =>
                    {
                        var convertedData = new MessageData(e.Data.Nick, e.Data.Channel, e.Data.Message, e.Data.MessageArray);
                        messageReceivedEventHandler(convertedData);
                    });
                    _ircClient.OnChannelMessage += new IrcEventHandler(handler);
                    break;

                default:
                    throw new NotImplementedException($"EventType {eventType} not supported yet");

            }
        }
Пример #5
0
        public void TestInitialize()
        {
            TestCleanup();

            _messageData = new MessageData("TestRunner", "testChannel", "!topic newTopic", new String[] { "!topic", "newTopic" });

            _messagingClientMock = new Mock<IMessagingClient>();

            _channelMessageActions = new ChannelMessageActions(_messagingClientMock.Object);
        }