示例#1
0
        public override async Task Send(Envelope envelope, params string[] messages)
        {
            await base.Send(envelope, messages);

            if (messages == null || !messages.Any())
            {
                return;
            }

            int roomId;

            if (!_roomMap.TryGetValue(envelope.User.Room, out roomId))
            {
                // There's no public room with the envelopes key, so send this
                // as a private message to the user instead.
                await Reply(envelope, messages);

                return;
            }

            foreach (var message in messages)
            {
                _api.SendRoomNotification(roomId, message);
            }
        }
示例#2
0
        public override Task Send(Envelope envelope, AdapterArguments adapterArgs, params string[] messages)
        {
            if (messages == null || !messages.Any())
            {
                return(Task.FromResult(0));
            }

            int roomId;

            if (!_roomMap.TryGetValue(envelope.User.Room, out roomId))
            {
                // There's no public room with the envelopes key, so send this
                // as a private message to the user instead.
                return(Reply(envelope, adapterArgs, messages));
            }

            var color = adapterArgs.Color ?? "";

            color = color.ToLowerInvariant();

            if (color != "yellow" &&
                color != "green" &&
                color != "red" &&
                color != "purple" &&
                color != "gray" &&
                color != "random")
            {
                color = "yellow";
            }

            foreach (var message in messages)
            {
                _api.SendRoomNotification(roomId, color, message);
            }

            return(Task.FromResult(0));
        }