Esempio n. 1
0
        /// <summary>
        /// send <paramref name="mini"/> to this <see cref="Room"/>
        /// </summary>
        /// <param name="mini"></param>
        /// <returns></returns>
        public async Task <Message?> Say(MiniProgram mini)
        {
            if (Logger.IsEnabled(LogLevel.Trace))
            {
                Logger.LogTrace($"say({mini})");
            }
            var msgId = await Puppet.MessageSendMiniProgram(Id, mini.Payload);

            return(await TryLoad(msgId));
        }
Esempio n. 2
0
        public async Task <Message?> Say(MiniProgram miniProgram)
        {
            if (Logger.IsEnabled(LogLevel.Trace))
            {
                Logger.LogTrace($"say({miniProgram})");
            }
            var msgId = await Puppet.MessageSendMiniProgram(Id, miniProgram.Payload);

            if (msgId != null)
            {
                var result = WechatyInstance.Message.Load(msgId);
                await result.Ready;
                return(result);
            }
            return(null);
        }
Esempio n. 3
0
        /// <summary>
        /// send <paramref name="miniProgram"/> to <see cref="Room"/> or <see cref="From"/>
        /// </summary>
        /// <param name="miniProgram"></param>
        /// <returns></returns>
        public async Task <Message?> Say(MiniProgram miniProgram)
        {
            if (Logger.IsEnabled(LogLevel.Trace))
            {
                Logger.LogTrace($"say({miniProgram})");
            }
            var room           = Room;
            var from           = From;
            var conversationId = room?.Id ?? from?.Id;

            if (conversationId == null)
            {
                throw new InvalidOperationException("neither room nor from?");
            }
            var msgId = await Puppet.MessageSendMiniProgram(conversationId, miniProgram.Payload);

            if (msgId != null)
            {
                var result = WechatyInstance.Message.Load(msgId);
                await result.Ready;
                return(result);
            }
            return(null);
        }