@param \EasyWeChat\Kernel\Messages\Message|string|null $message

@return mixed

@throws \EasyWeChat\Kernel\Exceptions\RuntimeException
@throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
15749
public function send($message = null)
    {
        if ($message) {
            $this->message($message);
        }

        if (empty($this->message)) {
            throw new RuntimeException('No message to send.');
        }

        if (is_null($this->agentId)) {
            throw new RuntimeException('No agentid specified.');
        }

        $message = $this->message->transformForJsonRequest(array_merge([
            'agentid' => $this->agentId,
            'safe' => intval($this->secretive),
        ], $this->to));

        $this->secretive = false;

        return $this->client->send($message);
    }
813232
protected function askRequired($message) {
    $question = new Question($this->formatQuestion($message));
    $question->setValidator(function ($answer) {
      if (empty($answer)) {
        throw new \RuntimeException(
          'You must enter a value!'
        );
      }

      return $answer;
    });
    return $this->doAsk($question);
  }
695241
private function createMessage($message)
    {
        if ($message instanceof Message) {
            return $message;
        }

        if ($message instanceof Template) {
            $message = new Attachment(Attachment::TYPE_TEMPLATE, $message);
        }

        if (is_string($message) || $message instanceof Attachment) {
            return new Message($message);
        }

        throw new \InvalidArgumentException('$message should be a string, Message, Attachment or Template');
    }
850596
protected function parseMessage(\CharlotteDunois\Yasmin\Models\Message $message) {
        // Find the command to run by patterns
        foreach($this->client->registry->commands as $command) {
            if($command->patterns === null) {
                continue;
            }
            
            foreach($command->patterns as $ptrn) {
                \preg_match($ptrn, $message->content, $matches);
                if(!empty($matches)) {
                    return (new \CharlotteDunois\Livia\Commands\Context($this->client, $message, $command, null, $matches));
                }
            }
        }
        
        $prefix = $this->client->getGuildPrefix($message->guild);
        if(empty($this->commandPatterns[$prefix])) {
            $this->buildCommandPattern($prefix);
        }
        
        $cmdMessage = $this->matchDefault($message, $this->commandPatterns[$prefix], 2);
        if(!$cmdMessage && $message->guild === null) {
            $cmdMessage = $this->matchDefault($message, '/^([^\s]+)/i');
        }
        
        return $cmdMessage;
    }
817701
public function fromProducedMessage(AMQPMessage $message)
    {
        $currentSpan = $this->spanStack->current();

        return new Span(
            $this->identifierGenerator->generate(),
            $this->getMessageName($message),
            null !== $currentSpan ? $currentSpan->getTraceIdentifier() : $this->identifierGenerator->generate(),
            [
                new Annotation(Annotation::CLIENT_SEND, $this->clock->microseconds(), $this->endpointResolver->resolve()),
            ],
            [],
            $currentSpan !== null ? $currentSpan->getIdentifier() : null,
            $currentSpan !== null ? $currentSpan->getDebug() : null,
            $this->clock->microseconds()
        );
    }
612429
public function getMessage($message = "codeco")
    {
        $folder = $this->_path.SEPARATOR.$this->_directory.SEPARATOR."messages";
        return $folder.SEPARATOR.strtolower($message).".xml";
    }
1020276
private function getUserMessages(Message $message)
    {
        $currentUser = $this->tokenStorage->getToken()->getUser();

        return $this->om->getRepository(UserMessage::class)->findBy(['message' => $message, 'user' => $currentUser]);
    }
938466
private function getReplyTo(Swift_Mime_Message $message) {
        if (is_array($message->getReplyTo())) {
            return array('Email' => key($message->getReplyTo()), 'Name' => current($message->getReplyTo()));
        } elseif (is_string($message->getReplyTo())) {
            return array('Email' => $message->getReplyTo());
        } else {
            return null;
        }
    }
1315814
public static function createMessage(string $message): string
    {
        $lastErrorMessage = error_get_last();
        if ($lastErrorMessage !== null) {
            $message .= "; ".$lastErrorMessage["message"];
        }
        return $message;
    }
123919
public static function message($name, $message = null)
    {
        if (func_num_args() === 2) {
            return static::$_messages[$name] = $message;
        }
        return isset(static::$_messages[$name]) ? static::$_messages[$name] : static::$_messages['_default_'];
    }
808065
function toMessage($message, $request = null)
    {
        $implicit = $message->isOpenID1();
        $added = $message->namespaces->addAlias($this->ns_uri,
                                                $this->ns_alias,
                                                $implicit);

        if ($added === null) {
            if ($message->namespaces->getAlias($this->ns_uri) !=
                $this->ns_alias) {
                return null;
            }
        }

        if ($request !== null) {
            $message->updateArgs($this->ns_uri,
                                 $this->getExtensionArgs($request));
        } else {
            $message->updateArgs($this->ns_uri,
                                 $this->getExtensionArgs());
        }
        return $message;
    }
1359012
public function resolveCustomMessage($message)
    {
        preg_match_all('/\{[\w.| ]+\}/', $message, $segments);
        foreach (current($segments) as $segment) {
            $s    = str_replace(['{', '}'], '', $segment);
            $keys = explode('|', $s);

            if (empty($keys[1]) && isset($keys[2])) {
                $keys[1] = $this->callback($keys[2]);
            }

            $valueSegmented = $this->getValueSegmented($this, $keys[0], isset($keys[1]) ? $keys[1] : false);
            if (!$valueSegmented) {
                return false;
            }
            $message = str_replace($segment, $valueSegmented, $message);
        }

        return $message;
    }
950340
public function setMessage($message)
    {
        if ( ! is_null($message)) $message = (string) $message;

        $this->setAttribute('message', $message);

        return $this;
    }
586618
public function url($message = null)
    {
        $this->setRule(__FUNCTION__, function($val)
                       {
                           return (strlen(trim($val)) === 0 || filter_var($val, FILTER_VALIDATE_URL) !== FALSE);
                       }, $message);
        return $this;
    }
613966
public function encrypt($message)
    {

        $nonceSize = \openssl_cipher_iv_length($this->method);
        $nonce     = \openssl_random_pseudo_bytes($nonceSize, $cryptStrong);

        if (false === $cryptStrong || false === $nonce)
        {
            throw new Exceptions\Runtime('IV generation failed');
        }

        $cipherText = \openssl_encrypt(
            $message,
            $this->method,
            $this->password,
            OPENSSL_RAW_DATA,
            $nonce
        );

        return \base64_encode($nonce . $cipherText);
    }
63144
public function getFrom(Message $message = null) 
    {
        $from = $message === null ? null : $message->getFrom();
        if (!$from) {
            $from = $this->getOption(self::CONFIG_DEFAULT_SENDER);
        }
        return $from;
    }
1024931
protected function formatMessage( $message )
	{
		if ( is_array( $message ) )
			return var_export( $message, true );
		elseif ( $message instanceof Jsonable )
			return $message->toJson();
		elseif ( $message instanceof Arrayable )
			return var_export( $message->toArray(), true );

		return $message;
	}