示例#1
0
        public static MessageToSend OptedIntoChannelAgain(this NewMessage incomingMessage, string channel)
        {
            var message = incomingMessage.CreateResponseMessage($"You have now opted in for any upcoming pizza plans in the channel `{channel}`.\n" +
                                                                $"I am really happy you have chosen to do so. Perhaps you will be selected soon to eat some delicious pizza.");

            return(message);
        }
示例#2
0
        public static MessageToSend ConfirmOptOutMessage(this NewMessage incomingMessage, string channel)
        {
            var message = incomingMessage.CreateResponseMessage($"You have now opted out of any and all upcoming pizza plans in the channel '{channel}'.\n" +
                                                                $"If you should change your mind you can allways opt in again by typing `opt in {channel}`.");

            return(message);
        }
示例#3
0
        public static MessageToSend ProvideChannelOptionToOptOut(this NewMessage incomingMessage, BotConfig config)
        {
            var channels = new[] { config.PizzaRoom.Room }.Select(s => $"`{s}`").ToArray();
            var channelList = string.Join(", ", channels) + " or `all`";

            var message = incomingMessage.CreateResponseMessage(
                $"To opt out of receiving invitations from me, plese specify which channel you want to me ignore you in. \n" +
                $"Use `opt out [Channel]`, " +
                $"where options for Channel include: {channelList}");

            return(message);
        }
示例#4
0
        public void OnMessageReceived(NewMessage message)
        {
            try
            {
                if (message.bot_id == SocketClient.MySelf.id)
                {
                    return;
                }
                if (!message.IsDirect())
                {
                    return;
                }
                if (message.IsByBot())
                {
                    return;
                }

                message.username = UserCache.SingleOrDefault(u => u.id == message.user).name ?? "[BLANK]";
                _logger.Information("[Message found from '{FromUser}/{FromUserName}']", message.user, message.username);
                _logger.Debug($"MSG: {message.text.SafeSubstring(0, 90)}");

                bool messageUnderstood = false;
                foreach (var resource in _messageHandlers)
                {
                    if (resource.HandleMessage(message).Result)
                    {
                        messageUnderstood = true;
                    }
                }
                if (messageUnderstood == false)
                {
                    SendMessage(message.CreateResponseMessage(
                                    $"I'm sorry, I didn't catch that. If you have any further questions please direct them to #{_botConfig.BotRoom}."))
                    .Wait(5000);
                }
            }
            catch (Exception e)
            {
                _logger.Error(e, "Failure handling incoming message from '{FromUser}/{FromUserName}'. [MSG: {UserMessage}]", message.user, message.username, message.text.SafeSubstring(0, 90));
                Environment.FailFast($"Failure handling incoming message from '{message.user}/{message.username}'. [MSG: {message.text.SafeSubstring(0, 90)}]", e);
            }
        }
 public static MessageToSend UserTurnsDownInvitation(this NewMessage incoming)
 {
     return(incoming.CreateResponseMessage("That is too bad, I will try to find someone else. \n" +
                                           "If you don't want to receive any more invitations from me try typing `opt out`"));
 }
示例#6
0
        public static MessageToSend ChannelUnrecogised(this NewMessage incomingMessage, string channel)
        {
            var message = incomingMessage.CreateResponseMessage($"I don't recognise that channel name: {channel}");

            return(message);
        }
示例#7
0
        public static MessageToSend RepeatOptOutMessageToConfirm(this NewMessage incomingMessage, string channel)
        {
            var message = incomingMessage.CreateResponseMessage($"Please confirm your choice by repeating `opt out {channel}`");

            return(message);
        }