Net::A...::State(3pm)

πŸ“¦
version 0.19 Β· 2 versions
  • 0.19 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.19 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Net::Async::Matrix::Room::State πŸ’–

okay bestie, so this is Net::Async::Matrix::Room::State β€” a Perl module (that's the 3pm vibe, it lives in the User Contributed Perl Documentation) and it's literally the keeper of all the state events in a Matrix room πŸ¦‹


✨ NAME ✨

Net::Async::Matrix::Room::State β€” no cap, it represents the state events in a matrix room πŸ‘‘


🌸 DESCRIPTION 🌸

So here's the tea β˜• β€” instances of this class are holding down all of the known state events in a Net::Async::Matrix::Room at some instant in time. Like, a lil snapshot of the room's whole situation.

And here's the important part: these objects are mutable πŸ”₯ So if you grabbed a "live" state object from a room, it's not gonna just sit there being stale β€” it will change to keep track of newly received state events. It's giving main character energy, always updating, always aware πŸ’…


πŸŽ€ METHODS πŸŽ€

get_event

$event = $state->get_event( $type, $state_key )

Returns a HASH reference containing the raw event stored for the given type name and optional state_key. That's it, that's the whole vibe ✨

get_events

$events = $state->get_events( $type )

Returns a multi-level HASH reference mapping all of the known state keys for a given event type name to their raw stored events 🫢

Typically this is useful for m.room.member events, because the state keys will be user IDs. iykyk πŸ’œ


πŸ‘‘ CONVENIENCE ACCESSORS πŸ‘‘

okay so these next ones all fetch single values out of certain events, because that's just. so commonly used. they're here to make your life easier, periodt 🌈

name

$name = $state->name

Returns the name field of the m.room.name event, if it exists. πŸŽ€

join_rule

$join_rule = $state->join_rule

Returns the join_rule field of the m.room.join_rules event, if it exists. πŸšͺ

topic

$topic = $state->topic

Returns the topic field of the m.room.topic event, if it exists. πŸ’¬

aliases

@aliases = $state->aliases

Returns a list of the room alias from all the m.room.aliases events, in no particular order. so like, don't come for me about the ordering, it's just vibes πŸ¦‹

members

@members = $state->members

Returns a list of Member instances representing all of the members of the room from the m.room.member events whose membership state is not leave. everyone still in the group chat, basically πŸ’–

all_members

@members = $state->members

Similar to members but even includes members in leave state. πŸ‘€

Not gonna lie bestie β€” this is not normally what you want. It's the "everyone who was ever here" list. Use with intention. πŸ’€

member

$member = $state->member( $user_id )

Returns a Member instance representing a room member of the given user_id, or undef if none exists. πŸ™ˆ

member_level

$level = $state->member_level( $user_id )

Returns a number indicating the power level that the given user_id would have according to room state, taken from the m.room.power_levels event. ✨

This takes into account the users_default field, if no specific level exists for the given user_id. so it's not just gonna ghost you with a nothing answer 🌟


πŸ’œ AUTHOR πŸ’œ

Paul Evans <leonerd@leonerd.org.uk> β€” an icon, honestly 🫢


aaaand that's the whole page, bestie!! this was perl v5.36.0, dated 2022-12-10, and it's filed under Net::A...::State(3pm) in the User Contributed Perl Documentation. go forth and slay your Matrix state πŸ’…βœ¨πŸŒΈ

πŸ“¦ where this page comes from