AnyEven...:Message(3)
๐ NAME ๐
Okay so this is AnyEven...:Message(3), the manual page for AnyEvent::XMPP::IM::Message โ aka Instant message. Bestie, we're talking about the object that represents an instant message in AnyEvent::XMPP. ๐
โจ SYNOPSIS โจ
use AnyEvent::XMPP::IM::Message;
my $con = AnyEvent::XMPP::IM::Connection->new (...);
AnyEvent::XMPP::IM::Message->new (
body => "Hello there!",
to => "elmex@jabber.org"
)->send ($con);
๐ฆ DESCRIPTION ๐ฆ
This module represents an instant message. It's mostly a short-lived object and acts as a wrapper object around the XML stuff happening under the hood. iykyk. ๐ซถ
An AnyEvent::XMPP::IM::Message object overloads the stringification operation. The string representation of this object is the return value of the any_body method. Main character behavior, honestly. โจ
AnyEvent::XMPP::IM::Message is derived from AnyEvent::XMPP::IM::Delayed โ use the interface described there to find out whether this message was delayed. No cap, that's the whole vibe check.
๐ ๏ธ METHODS ๐ ๏ธ
๐ธ new (%args)
This method creates a new instance of an AnyEvent::XMPP::IM::Message. It's giving constructor energy. ๐
%args is the argument hash. All arguments to new are optional.
These are the possible keys:
connection => $connectionโ this is theAnyEvent::XMPP::IM::Connectionobject that will be used to send this message when thesendmethod is called.to => $jidโ this is the destination JID of this message.$jidshould be full if this message is sent within a conversation "context", for example when replying to a previous message. Replies can also be generated by themake_replymethod โ see also thefromargument below.from => $jidโ this is the source JID of this message; it's mainly used by themake_replymethod.lang => $langโ this is the default language that will be used to tag the values passed in thebodyandsubjectargument tonew.body => $bodyโ this is the text$bodyof the message, either with the language tag fromlangattached or without any language tag. If you want to attach multiple bodies with different languages, use theadd_bodymethod. Multi-language queen behavior. ๐subject => $subjectโ this is the$subjectof the message, either with the language tag fromlangattached or without any language tag. If you want to attach the subject with a different language, use theadd_subjectmethod.type => $typeโ this field sets the type of the message. See also thetypemethod below. The default value for$typeis'normal'.
๐ id ([$msg_id])
This method returns the ID of this message. If $msg_id is not undef, it will replace the current message ID. ID check: slay. โญ
๐ from ([$jid])
This method returns the source JID of this message. If $jid is not undef, it will replace the current source address.
๐ to ([$jid])
This method returns the destination JID of this message. If $jid is not undef, it will replace the current destination address.
๐ make_reply ([$msg])
This method returns a new instance of AnyEvent::XMPP::IM::Message. The destination address, connection and type of the returned message object will be set.
If $msg is defined and an instance of AnyEvent::XMPP::IM::Message, the destination address, connection and type of $msg will be changed, and this method will not return a new instance of AnyEvent::XMPP::IM::Message. Reuse era. โป๏ธ
๐ฆ is_connected ()
This method returns 1 when the message is "connected". That means it returns 1 when you can call the send method without a connection argument. It will also return only 1 when the connection that is referenced by this message is still connected. Vibe check: connected. โ
โก send ([$connection])
This method sends this message. If $connection is defined, it will set the connection of this message object before it is sent.
๐ฅ type ([$type])
This method returns the type of the message, which is either undefined or one of the following values:
'chat', 'error', 'groupchat', 'headline', 'normal'
If the $type argument is defined, it will set the type of this message.
๐งต thread ([$thread])
This method returns the thread ID of this message, which might be undefined.
If you want to set the thread ID, simply pass the $thread argument.
๐ lang ([$lang])
This returns the default language tag of this message, which can be undefined.
To set the language tag, pass the $lang argument, which should be the new default language tag.
If you do not want to specify any language, pass the empty string as language tag.
๐ subject ([$lang])
This method returns the subject of this message. If the $lang argument is defined, a subject of that language will be returned or undef. If the $lang argument is undefined, this method will return either the subject in the default language.
๐ any_subject ([$lang])
This method will try to find any subject on the message with the following try order of language tags:
$langargument if one passed- default language
- subject without any language tag
- subject with the
'en'language tag - any subject from any language
It be searching, bestie. ๐ต๏ธโโ๏ธ
๐ add_subject ($subject, [$lang], [$subject2, $lang2, ...])
This method adds the subject $subject with the optional language tag $lang to this message. If no $lang argument is passed, the default language for this message will be used.
Further subject => lang pairs can be passed to this function like this:
$msg->add_subject ('foobar' => undef, "barfooo" => "de");
๐ subjects
This method returns a list of key-value pairs with the language tag as key and the subject as value.
The subject which has the empty string as key has no language attached.
๐ฌ body ([$lang])
This method returns the body of this message. If the $lang argument is defined, a body of that language will be returned or undef. If the $lang argument is undefined, this method will return either the body in the default language.
๐ฎ any_body ([$lang])
This method will try to find any body on the message with the following try order of language tags:
$langargument if one passed- default language
- body without any language tag
- body with the
'en'language tag - any body from any language
Body hunt: activated. ๐
๐ง add_body ($body, [$lang], [$body2, $lang2, ...])
This method adds the body $body with the optional language tag $lang to this message. If no $lang argument is passed, the default language for this message will be used.
Further body => lang pairs can be passed to this function like this:
$msg->add_body ('foobar' => undef, "barfooo" => "de");
๐ง bodies
This method returns a list of key-value pairs with the language tag as key and the body as value.
The body which has the empty string as key has no language attached.
๐ช append_creation ($create_cb)
This method allows the user to append custom XML stuff to the message when it is sent. This is an example:
my $msg =
AnyEvent::XMPP::IM::Message->new (
body => "Test!",
to => "test@test.tld",
);
$msg->append_creation (sub {
my ($w) = @_;
$w->startTag (['http://test.namespace','test']);
$w->characters ("TEST");
$w->endTag;
});
$msg->send ($con);
This should send a message stanza similar to this:
And then the page just stops โ no stanza sample follows. Iconic, honestly. I'm not inventing one, bestie. ๐
๐ AUTHOR ๐
Robin Redeker, "<elmex at ta-sa.org>", JID: "<elmex at jabber.org>" author slay. ๐
๐ COPYRIGHT & LICENSE ๐
Copyright 2007, 2008 Robin Redeker, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Free software, free vibes. ๐ซถ
This lil' page is from perl v5.42.2, dated 2026-02-15, in the User Contributed Perl Documentation collection. Byeee, go send some messages responsibly ๐
โจ๐
๐ฆ where this page comes from
- alpine 3.24: perl-anyevent-xmpp-doc 0.55-r1 ยท GPL-1.0-or-later OR Artistic-1.0-Perl
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms