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

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

            if (msgId != null)
            {
                var result = WechatyInstance.Message.Load(msgId);
                await result.Ready;
                return(result);
            }
            return(null);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// send <paramref name="urlLink"/> to <see cref="Room"/> or <see cref="From"/>
        /// </summary>
        /// <param name="urlLink"></param>
        /// <returns></returns>
        public async Task <Message?> Say(UrlLink urlLink)
        {
            if (Logger.IsEnabled(LogLevel.Trace))
            {
                Logger.LogTrace($"say({urlLink})");
            }
            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.MessageSendUrl(conversationId, urlLink.Payload);

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