Beispiel #1
0
        public static void SendMessage(MessageSourceType sourceType, List <BaseMessage> messages, long?qq = null,
                                       long?toGroupNo = null)
        {
            var message = new Message();

            switch (sourceType)
            {
            case MessageSourceType.Group:
                if (!toGroupNo.HasValue || toGroupNo <= 0)
                {
                    return;
                }
                message.Type    = MessageSourceType.Group;
                message.ToGroup = toGroupNo.Value;
                break;

            case MessageSourceType.Private:
                if (!qq.HasValue || qq <= 0)
                {
                    return;
                }
                message.Type = MessageSourceType.Private;
                message.ToQQ = qq.Value;
                break;

            case MessageSourceType.Friend:
                if (!qq.HasValue || qq <= 0)
                {
                    return;
                }
                message.Type = MessageSourceType.Friend;
                message.ToQQ = qq.Value;
                break;
            }

            message.Content.AddRange(messages);
            EventCenter.SendMessage(message);
        }