-module(telega@update). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/telega/update.gleam"). -export([decode_raw/1, to_string/1, raw_to_update/1]). -export_type([update/0, command/0]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. -type update() :: {text_update, integer(), integer(), binary(), telega@model@types:message(), telega@model@types:update()} | {command_update, integer(), integer(), command(), telega@model@types:message(), telega@model@types:update()} | {photo_update, integer(), integer(), list(telega@model@types:photo_size()), telega@model@types:message(), telega@model@types:update()} | {video_update, integer(), integer(), telega@model@types:video(), telega@model@types:message(), telega@model@types:update()} | {audio_update, integer(), integer(), telega@model@types:audio(), telega@model@types:message(), telega@model@types:update()} | {voice_update, integer(), integer(), telega@model@types:voice(), telega@model@types:message(), telega@model@types:update()} | {media_group_update, integer(), integer(), binary(), list(telega@model@types:message()), telega@model@types:update()} | {web_app_update, integer(), integer(), telega@model@types:web_app_data(), telega@model@types:message(), telega@model@types:update()} | {message_update, integer(), integer(), telega@model@types:message(), telega@model@types:update()} | {channel_post_update, integer(), integer(), telega@model@types:message(), telega@model@types:update()} | {edited_message_update, integer(), integer(), telega@model@types:message(), telega@model@types:update()} | {edited_channel_post_update, integer(), integer(), telega@model@types:message(), telega@model@types:update()} | {business_connection_update, integer(), integer(), telega@model@types:business_connection(), telega@model@types:update()} | {business_message_update, integer(), integer(), telega@model@types:message(), telega@model@types:update()} | {edited_business_message_update, integer(), integer(), telega@model@types:message(), telega@model@types:update()} | {deleted_business_message_update, integer(), integer(), telega@model@types:business_messages_deleted(), telega@model@types:update()} | {message_reaction_update, integer(), integer(), telega@model@types:message_reaction_updated(), telega@model@types:update()} | {message_reaction_count_update, integer(), integer(), telega@model@types:message_reaction_count_updated(), telega@model@types:update()} | {inline_query_update, integer(), integer(), telega@model@types:inline_query(), telega@model@types:update()} | {chosen_inline_result_update, integer(), integer(), telega@model@types:chosen_inline_result(), telega@model@types:update()} | {callback_query_update, integer(), integer(), telega@model@types:callback_query(), telega@model@types:update()} | {shipping_query_update, integer(), integer(), telega@model@types:shipping_query(), telega@model@types:update()} | {pre_checkout_query_update, integer(), integer(), telega@model@types:pre_checkout_query(), telega@model@types:update()} | {paid_media_purchase_update, integer(), integer(), telega@model@types:paid_media_purchased(), telega@model@types:update()} | {poll_update, integer(), integer(), telega@model@types:poll(), telega@model@types:update()} | {poll_answer_update, integer(), integer(), telega@model@types:poll_answer(), telega@model@types:update()} | {my_chat_member_update, integer(), integer(), telega@model@types:chat_member_updated(), telega@model@types:update()} | {chat_member_update, integer(), integer(), telega@model@types:chat_member_updated(), telega@model@types:update()} | {chat_join_request_update, integer(), integer(), telega@model@types:chat_join_request(), telega@model@types:update()} | {removed_chat_boost, integer(), integer(), telega@model@types:chat_boost_removed(), telega@model@types:update()}. -type command() :: {command, binary(), binary(), gleam@option:option(binary())}. -file("src/telega/update.gleam", 213). -spec decode_raw(gleam@dynamic:dynamic_()) -> {ok, telega@model@types:update()} | {error, telega@error:telega_error()}. decode_raw(Json) -> _pipe = gleam@dynamic@decode:run( Json, telega@model@decoder:update_decoder() ), gleam@result:map_error( _pipe, fun(E) -> {decode_update_error, <<<<<<"Cannot decode update: "/utf8, (gleam@string:inspect(Json))/binary>>/binary, " "/utf8>>/binary, (gleam@string:inspect(E))/binary>>} end ). -file("src/telega/update.gleam", 709). -spec to_string(update()) -> binary(). to_string(Update) -> case Update of {command_update, From_id, _, Command, _, _} -> <<<<<<"command \""/utf8, (erlang:element(3, Command))/binary>>/binary, "\" from "/utf8>>/binary, (erlang:integer_to_binary(From_id))/binary>>; {text_update, From_id@1, _, Text, _, _} -> <<<<<<"text \""/utf8, Text/binary>>/binary, "\" from "/utf8>>/binary, (erlang:integer_to_binary(From_id@1))/binary>>; {message_update, From_id@2, _, Message, _} -> <<<<<<"message "/utf8, (erlang:integer_to_binary(erlang:element(2, Message)))/binary>>/binary, " from "/utf8>>/binary, (erlang:integer_to_binary(From_id@2))/binary>>; {photo_update, From_id@3, _, _, _, _} -> <<"photo from "/utf8, (erlang:integer_to_binary(From_id@3))/binary>>; {video_update, From_id@4, _, Video, _, _} -> <<<<<<"video "/utf8, (erlang:element(2, Video))/binary>>/binary, " from "/utf8>>/binary, (erlang:integer_to_binary(From_id@4))/binary>>; {audio_update, From_id@5, _, Audio, _, _} -> <<<<<<"audio "/utf8, (erlang:element(2, Audio))/binary>>/binary, " from "/utf8>>/binary, (erlang:integer_to_binary(From_id@5))/binary>>; {voice_update, From_id@6, _, Voice, _, _} -> <<<<<<"voice "/utf8, (erlang:element(2, Voice))/binary>>/binary, " from "/utf8>>/binary, (erlang:integer_to_binary(From_id@6))/binary>>; {media_group_update, From_id@7, _, Media_group_id, Messages, _} -> <<<<<<<<<<"media group "/utf8, Media_group_id/binary>>/binary, " with "/utf8>>/binary, (erlang:integer_to_binary(erlang:length(Messages)))/binary>>/binary, " items from "/utf8>>/binary, (erlang:integer_to_binary(From_id@7))/binary>>; {web_app_update, From_id@8, _, Web_app_data, _, _} -> <<<<<<"web app "/utf8, (erlang:element(2, Web_app_data))/binary>>/binary, " from "/utf8>>/binary, (erlang:integer_to_binary(From_id@8))/binary>>; {callback_query_update, From_id@9, _, Query, _} -> <<<<<<"callback query "/utf8, (gleam@option:unwrap( erlang:element(7, Query), <<"no data"/utf8>> ))/binary>>/binary, " from "/utf8>>/binary, (erlang:integer_to_binary(From_id@9))/binary>>; {channel_post_update, From_id@10, _, Post, _} -> <<<<<<"channel post "/utf8, (erlang:integer_to_binary(erlang:element(2, Post)))/binary>>/binary, " from "/utf8>>/binary, (erlang:integer_to_binary(From_id@10))/binary>>; {edited_message_update, From_id@11, _, Message@1, _} -> <<<<<<"edited message "/utf8, (erlang:integer_to_binary(erlang:element(2, Message@1)))/binary>>/binary, " from "/utf8>>/binary, (erlang:integer_to_binary(From_id@11))/binary>>; {edited_channel_post_update, From_id@12, _, Post@1, _} -> <<<<<<"edited channel post "/utf8, (erlang:integer_to_binary(erlang:element(2, Post@1)))/binary>>/binary, " from "/utf8>>/binary, (erlang:integer_to_binary(From_id@12))/binary>>; {business_connection_update, From_id@13, _, Business_connection, _} -> <<<<<<"business connection "/utf8, (erlang:element(2, Business_connection))/binary>>/binary, " from "/utf8>>/binary, (erlang:integer_to_binary(From_id@13))/binary>>; {business_message_update, From_id@14, _, Message@2, _} -> <<<<<<"business message "/utf8, (erlang:integer_to_binary(erlang:element(2, Message@2)))/binary>>/binary, " from "/utf8>>/binary, (erlang:integer_to_binary(From_id@14))/binary>>; {chat_join_request_update, From_id@15, _, Chat_join_request, _} -> <<<<<<"chat join request "/utf8, (erlang:integer_to_binary( erlang:element( 2, erlang:element(2, Chat_join_request) ) ))/binary>>/binary, " from "/utf8>>/binary, (erlang:integer_to_binary(From_id@15))/binary>>; {chat_member_update, From_id@16, _, Chat_member_updated, _} -> <<<<<<"chat member update "/utf8, (erlang:integer_to_binary( erlang:element( 2, erlang:element(2, Chat_member_updated) ) ))/binary>>/binary, " from "/utf8>>/binary, (erlang:integer_to_binary(From_id@16))/binary>>; {chosen_inline_result_update, From_id@17, _, Chosen_inline_result, _} -> <<<<<<"chosen inline result "/utf8, (erlang:element(2, Chosen_inline_result))/binary>>/binary, " from "/utf8>>/binary, (erlang:integer_to_binary(From_id@17))/binary>>; {deleted_business_message_update, From_id@18, _, Business_messages_deleted, _} -> <<<<<<"deleted business message "/utf8, (erlang:integer_to_binary( erlang:element( 2, erlang:element(3, Business_messages_deleted) ) ))/binary>>/binary, " from "/utf8>>/binary, (erlang:integer_to_binary(From_id@18))/binary>>; {edited_business_message_update, From_id@19, _, Message@3, _} -> <<<<<<"edited business message "/utf8, (erlang:integer_to_binary(erlang:element(2, Message@3)))/binary>>/binary, " from "/utf8>>/binary, (erlang:integer_to_binary(From_id@19))/binary>>; {inline_query_update, From_id@20, _, Inline_query, _} -> <<<<<<"inline query "/utf8, (erlang:element(2, Inline_query))/binary>>/binary, " from "/utf8>>/binary, (erlang:integer_to_binary(From_id@20))/binary>>; {message_reaction_count_update, From_id@21, _, Message_reaction_count_updated, _} -> <<<<<<"message reaction count update "/utf8, (erlang:integer_to_binary( erlang:element( 2, erlang:element( 2, Message_reaction_count_updated ) ) ))/binary>>/binary, " from "/utf8>>/binary, (erlang:integer_to_binary(From_id@21))/binary>>; {message_reaction_update, From_id@22, _, Message_reaction_updated, _} -> <<<<<<"message reaction update "/utf8, (erlang:integer_to_binary( erlang:element( 2, erlang:element(2, Message_reaction_updated) ) ))/binary>>/binary, " from "/utf8>>/binary, (erlang:integer_to_binary(From_id@22))/binary>>; {my_chat_member_update, From_id@23, _, Chat_member_updated@1, _} -> <<<<<<"my chat member update "/utf8, (erlang:integer_to_binary( erlang:element( 2, erlang:element(2, Chat_member_updated@1) ) ))/binary>>/binary, " from "/utf8>>/binary, (erlang:integer_to_binary(From_id@23))/binary>>; {paid_media_purchase_update, From_id@24, _, _, _} -> <<"paid media purchase from "/utf8, (erlang:integer_to_binary(From_id@24))/binary>>; {poll_answer_update, From_id@25, _, Poll_answer, _} -> <<<<<<"poll answer "/utf8, (erlang:element(2, Poll_answer))/binary>>/binary, " from "/utf8>>/binary, (erlang:integer_to_binary(From_id@25))/binary>>; {poll_update, From_id@26, _, Poll, _} -> <<<<<<"poll "/utf8, (erlang:element(2, Poll))/binary>>/binary, " from "/utf8>>/binary, (erlang:integer_to_binary(From_id@26))/binary>>; {pre_checkout_query_update, From_id@27, _, Pre_checkout_query, _} -> <<<<<<"pre checkout query "/utf8, (erlang:element(2, Pre_checkout_query))/binary>>/binary, " from "/utf8>>/binary, (erlang:integer_to_binary(From_id@27))/binary>>; {removed_chat_boost, From_id@28, _, Removed_chat_boost, _} -> <<<<<<"removed chat boost "/utf8, (erlang:integer_to_binary( erlang:element( 2, erlang:element(2, Removed_chat_boost) ) ))/binary>>/binary, " from "/utf8>>/binary, (erlang:integer_to_binary(From_id@28))/binary>>; {shipping_query_update, From_id@29, _, Shipping_query, _} -> <<<<<<"shipping query "/utf8, (erlang:element(2, Shipping_query))/binary>>/binary, " from "/utf8>>/binary, (erlang:integer_to_binary(From_id@29))/binary>> end. -file("src/telega/update.gleam", 836). -spec new_callback_query_update( telega@model@types:update(), telega@model@types:callback_query() ) -> update(). new_callback_query_update(Raw, Callback_query) -> {callback_query_update, erlang:element(2, erlang:element(3, Callback_query)), case erlang:element(4, Callback_query) of {some, Message} -> case Message of {message_maybe_inaccessible_message, Message@1} -> erlang:element(2, erlang:element(12, Message@1)); {inaccessible_message_maybe_inaccessible_message, Inaccessible} -> erlang:element(2, erlang:element(2, Inaccessible)) end; none -> erlang:element(2, erlang:element(3, Callback_query)) end, Callback_query, Raw}. -file("src/telega/update.gleam", 954). -spec new_business_connection_update( telega@model@types:update(), telega@model@types:business_connection() ) -> update(). new_business_connection_update(Raw, Business_connection) -> {business_connection_update, erlang:element(2, erlang:element(3, Business_connection)), erlang:element(4, Business_connection), Business_connection, Raw}. -file("src/telega/update.gleam", 966). -spec new_business_message_update( telega@model@types:update(), telega@model@types:message() ) -> update(). new_business_message_update(Raw, Business_message) -> {business_message_update, case erlang:element(5, Business_message) of {some, User} -> erlang:element(2, User); none -> erlang:element(2, erlang:element(12, Business_message)) end, erlang:element(2, erlang:element(12, Business_message)), Business_message, Raw}. -file("src/telega/update.gleam", 978). -spec get_sender_id(telega@model@types:message()) -> integer(). get_sender_id(Message) -> case {erlang:element(5, Message), erlang:element(6, Message)} of {_, {some, Sender_chat}} -> erlang:element(2, Sender_chat); {{some, User}, _} -> erlang:element(2, User); {_, _} -> erlang:element(2, erlang:element(12, Message)) end. -file("src/telega/update.gleam", 853). -spec new_text_update( telega@model@types:update(), telega@model@types:message(), binary() ) -> update(). new_text_update(Raw, Message, Text) -> {text_update, get_sender_id(Message), erlang:element(2, erlang:element(12, Message)), Text, Message, Raw}. -file("src/telega/update.gleam", 873). -spec new_photo_update( telega@model@types:update(), telega@model@types:message(), list(telega@model@types:photo_size()) ) -> update(). new_photo_update(Raw, Message, Photos) -> {photo_update, get_sender_id(Message), erlang:element(2, erlang:element(12, Message)), Photos, Message, Raw}. -file("src/telega/update.gleam", 883). -spec new_video_update( telega@model@types:update(), telega@model@types:message(), telega@model@types:video() ) -> update(). new_video_update(Raw, Message, Video) -> {video_update, get_sender_id(Message), erlang:element(2, erlang:element(12, Message)), Video, Message, Raw}. -file("src/telega/update.gleam", 893). -spec new_audio_update( telega@model@types:update(), telega@model@types:message(), telega@model@types:audio() ) -> update(). new_audio_update(Raw, Message, Audio) -> {audio_update, get_sender_id(Message), erlang:element(2, erlang:element(12, Message)), Audio, Message, Raw}. -file("src/telega/update.gleam", 903). -spec new_voice_update( telega@model@types:update(), telega@model@types:message(), telega@model@types:voice() ) -> update(). new_voice_update(Raw, Message, Voice) -> {voice_update, get_sender_id(Message), erlang:element(2, erlang:element(12, Message)), Voice, Message, Raw}. -file("src/telega/update.gleam", 913). -spec new_web_app_data_update( telega@model@types:update(), telega@model@types:message(), telega@model@types:web_app_data() ) -> update(). new_web_app_data_update(Raw, Message, Web_app_data) -> {web_app_update, get_sender_id(Message), erlang:element(2, erlang:element(12, Message)), Web_app_data, Message, Raw}. -file("src/telega/update.gleam", 927). -spec new_channel_post_update( telega@model@types:update(), telega@model@types:message() ) -> update(). new_channel_post_update(Raw, Channel_post) -> {channel_post_update, get_sender_id(Channel_post), erlang:element(2, erlang:element(12, Channel_post)), Channel_post, Raw}. -file("src/telega/update.gleam", 936). -spec new_message_update( telega@model@types:update(), telega@model@types:message() ) -> update(). new_message_update(Raw, Message) -> {message_update, get_sender_id(Message), erlang:element(2, erlang:element(12, Message)), Message, Raw}. -file("src/telega/update.gleam", 945). -spec new_edited_message_update( telega@model@types:update(), telega@model@types:message() ) -> update(). new_edited_message_update(Raw, Edited_message) -> {edited_message_update, get_sender_id(Edited_message), erlang:element(2, erlang:element(12, Edited_message)), Edited_message, Raw}. -file("src/telega/update.gleam", 986). -spec is_command_entity(telega@model@types:message_entity()) -> boolean(). is_command_entity(Entity) -> (erlang:element(2, Entity) =:= <<"bot_command"/utf8>>) andalso (erlang:element( 3, Entity ) =:= 0). -file("src/telega/update.gleam", 990). -spec is_command_update(binary(), telega@model@types:update()) -> boolean(). is_command_update(Text, Raw_update) -> gleam@bool:guard( not gleam_stdlib:string_starts_with(Text, <<"/"/utf8>>), false, fun() -> case erlang:element(3, Raw_update) of {some, Message} -> case erlang:element(30, Message) of {some, Entities} -> gleam@list:any(Entities, fun is_command_entity/1); none -> false end; none -> false end end ). -file("src/telega/update.gleam", 1003). -spec extract_command(binary()) -> command(). extract_command(Text) -> case gleam@string:split(Text, <<" "/utf8>>) of [Command | Payload] -> {command, Text, gleam@string:drop_start(Command, 1), begin _pipe = Payload, _pipe@1 = gleam@string:join(_pipe, <<" "/utf8>>), {some, _pipe@1} end}; [] -> {command, Text, <<""/utf8>>, none} end. -file("src/telega/update.gleam", 863). -spec new_command_update( telega@model@types:update(), telega@model@types:message(), binary() ) -> update(). new_command_update(Raw, Message, Text) -> {command_update, get_sender_id(Message), erlang:element(2, erlang:element(12, Message)), extract_command(Text), Message, Raw}. -file("src/telega/update.gleam", 698). -spec decode_text_message( telega@model@types:update(), telega@model@types:message(), binary() ) -> update(). decode_text_message(Raw_update, Message, Text) -> case is_command_update(Text, Raw_update) of true -> new_command_update(Raw_update, Message, Text); false -> new_text_update(Raw_update, Message, Text) end. -file("src/telega/update.gleam", 678). -spec decode_message_update( telega@model@types:update(), telega@model@types:message() ) -> update(). decode_message_update(Raw_update, Message) -> case {erlang:element(38, Message), erlang:element(41, Message), erlang:element(35, Message), erlang:element(43, Message), erlang:element(106, Message), erlang:element(29, Message)} of {{some, Photos}, _, _, _, _, _} -> new_photo_update(Raw_update, Message, Photos); {_, {some, Video}, _, _, _, _} -> new_video_update(Raw_update, Message, Video); {_, _, {some, Audio}, _, _, _} -> new_audio_update(Raw_update, Message, Audio); {_, _, _, {some, Voice}, _, _} -> new_voice_update(Raw_update, Message, Voice); {_, _, _, _, {some, Web_app_data}, _} -> new_web_app_data_update(Raw_update, Message, Web_app_data); {_, _, _, _, _, {some, Text}} -> decode_text_message(Raw_update, Message, Text); {_, _, _, _, _, none} -> new_message_update(Raw_update, Message) end. -file("src/telega/update.gleam", 1017). -spec new_edited_business_message_update( telega@model@types:update(), telega@model@types:message() ) -> update(). new_edited_business_message_update(Raw, Edited_business_message) -> {edited_business_message_update, case erlang:element(5, Edited_business_message) of {some, User} -> erlang:element(2, User); none -> erlang:element(2, erlang:element(12, Edited_business_message)) end, erlang:element(2, erlang:element(12, Edited_business_message)), Edited_business_message, Raw}. -file("src/telega/update.gleam", 1032). -spec new_deleted_business_message_update( telega@model@types:update(), telega@model@types:business_messages_deleted() ) -> update(). new_deleted_business_message_update(Raw, Deleted_business_messages) -> {deleted_business_message_update, erlang:element(2, erlang:element(3, Deleted_business_messages)), erlang:element(2, erlang:element(3, Deleted_business_messages)), Deleted_business_messages, Raw}. -file("src/telega/update.gleam", 1044). -spec new_message_reaction_update( telega@model@types:update(), telega@model@types:message_reaction_updated() ) -> update(). new_message_reaction_update(Raw, Message_reaction) -> {message_reaction_update, case {erlang:element(4, Message_reaction), erlang:element(5, Message_reaction)} of {_, {some, Actor_chat}} -> erlang:element(2, Actor_chat); {{some, User}, _} -> erlang:element(2, User); {_, _} -> erlang:element(2, erlang:element(2, Message_reaction)) end, erlang:element(2, erlang:element(2, Message_reaction)), Message_reaction, Raw}. -file("src/telega/update.gleam", 1060). -spec new_message_reaction_count_update( telega@model@types:update(), telega@model@types:message_reaction_count_updated() ) -> update(). new_message_reaction_count_update(Raw, Message_reaction_count) -> {message_reaction_count_update, erlang:element(2, erlang:element(2, Message_reaction_count)), erlang:element(2, erlang:element(2, Message_reaction_count)), Message_reaction_count, Raw}. -file("src/telega/update.gleam", 1072). -spec new_inline_query_update( telega@model@types:update(), telega@model@types:inline_query() ) -> update(). new_inline_query_update(Raw, Inline_query) -> {inline_query_update, erlang:element(2, erlang:element(3, Inline_query)), erlang:element(2, erlang:element(3, Inline_query)), Inline_query, Raw}. -file("src/telega/update.gleam", 1081). -spec new_chosen_inline_result_update( telega@model@types:update(), telega@model@types:chosen_inline_result() ) -> update(). new_chosen_inline_result_update(Raw, Chosen_inline_result) -> {chosen_inline_result_update, erlang:element(2, erlang:element(3, Chosen_inline_result)), erlang:element(2, erlang:element(3, Chosen_inline_result)), Chosen_inline_result, Raw}. -file("src/telega/update.gleam", 1093). -spec new_shipping_query_update( telega@model@types:update(), telega@model@types:shipping_query() ) -> update(). new_shipping_query_update(Raw, Shipping_query) -> {shipping_query_update, erlang:element(2, erlang:element(3, Shipping_query)), erlang:element(2, erlang:element(3, Shipping_query)), Shipping_query, Raw}. -file("src/telega/update.gleam", 1102). -spec new_pre_checkout_query_update( telega@model@types:update(), telega@model@types:pre_checkout_query() ) -> update(). new_pre_checkout_query_update(Raw, Pre_checkout_query) -> {pre_checkout_query_update, erlang:element(2, erlang:element(3, Pre_checkout_query)), erlang:element(2, erlang:element(3, Pre_checkout_query)), Pre_checkout_query, Raw}. -file("src/telega/update.gleam", 1114). -spec new_paid_media_purchase_update( telega@model@types:update(), telega@model@types:paid_media_purchased() ) -> update(). new_paid_media_purchase_update(Raw, Paid_media_purchased) -> {paid_media_purchase_update, erlang:element(2, erlang:element(2, Paid_media_purchased)), erlang:element(2, erlang:element(2, Paid_media_purchased)), Paid_media_purchased, Raw}. -file("src/telega/update.gleam", 1126). -spec new_poll_update(telega@model@types:update(), telega@model@types:poll()) -> update(). new_poll_update(Raw, Poll) -> {poll_update, -1, -1, Poll, Raw}. -file("src/telega/update.gleam", 1133). -spec new_poll_answer_update( telega@model@types:update(), telega@model@types:poll_answer() ) -> update(). new_poll_answer_update(Raw, Poll_answer) -> From_id = case erlang:element(4, Poll_answer) of {some, User} -> erlang:element(2, User); none -> telega@internal@log:warning( <<"PollAnswer received with neither user nor voter_chat. Poll ID: "/utf8, (erlang:element(2, Poll_answer))/binary>> ), 0 end, Chat_id = case erlang:element(3, Poll_answer) of {some, Chat} -> erlang:element(2, Chat); none -> case erlang:element(4, Poll_answer) of {some, User@1} -> erlang:element(2, User@1); none -> telega@internal@log:warning( <<"PollAnswer received with neither user nor voter_chat. Poll ID: "/utf8, (erlang:element(2, Poll_answer))/binary>> ), 0 end end, {poll_answer_update, From_id, Chat_id, Poll_answer, Raw}. -file("src/telega/update.gleam", 1165). -spec new_my_chat_member_update( telega@model@types:update(), telega@model@types:chat_member_updated() ) -> update(). new_my_chat_member_update(Raw, My_chat_member) -> {my_chat_member_update, erlang:element(2, erlang:element(3, My_chat_member)), erlang:element(2, erlang:element(2, My_chat_member)), My_chat_member, Raw}. -file("src/telega/update.gleam", 1177). -spec new_chat_member_update( telega@model@types:update(), telega@model@types:chat_member_updated() ) -> update(). new_chat_member_update(Raw, Chat_member) -> {chat_member_update, erlang:element(2, erlang:element(3, Chat_member)), erlang:element(2, erlang:element(2, Chat_member)), Chat_member, Raw}. -file("src/telega/update.gleam", 1186). -spec new_chat_join_request_update( telega@model@types:update(), telega@model@types:chat_join_request() ) -> update(). new_chat_join_request_update(Raw, Chat_join_request) -> {chat_join_request_update, erlang:element(2, erlang:element(3, Chat_join_request)), erlang:element(2, erlang:element(2, Chat_join_request)), Chat_join_request, Raw}. -file("src/telega/update.gleam", 1198). -spec new_removed_chat_boost_update( telega@model@types:update(), telega@model@types:chat_boost_removed() ) -> update(). new_removed_chat_boost_update(Raw, Removed_chat_boost) -> {removed_chat_boost, erlang:element(2, erlang:element(2, Removed_chat_boost)), erlang:element(2, erlang:element(2, Removed_chat_boost)), Removed_chat_boost, Raw}. -file("src/telega/update.gleam", 226). ?DOC(" Decode a update from the Telegram API to `Update` instance.\n"). -spec raw_to_update(telega@model@types:update()) -> update(). raw_to_update(Raw_update) -> case {erlang:element(15, Raw_update), erlang:element(5, Raw_update), erlang:element(4, Raw_update), erlang:element(7, Raw_update), erlang:element(8, Raw_update), erlang:element(9, Raw_update), erlang:element(10, Raw_update), erlang:element(11, Raw_update), erlang:element(12, Raw_update), erlang:element(13, Raw_update), erlang:element(14, Raw_update), erlang:element(16, Raw_update), erlang:element(17, Raw_update), erlang:element(18, Raw_update), erlang:element(19, Raw_update), erlang:element(20, Raw_update), erlang:element(21, Raw_update), erlang:element(22, Raw_update), erlang:element(23, Raw_update), erlang:element(25, Raw_update), erlang:element(3, Raw_update)} of {{some, Callback_query}, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _} -> new_callback_query_update(Raw_update, Callback_query); {_, {some, Channel_post}, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _} -> new_channel_post_update(Raw_update, Channel_post); {_, _, {some, Edited_message}, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _} -> new_edited_message_update(Raw_update, Edited_message); {_, _, _, {some, Business_connection}, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _} -> new_business_connection_update(Raw_update, Business_connection); {_, _, _, _, {some, Business_message}, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _} -> new_business_message_update(Raw_update, Business_message); {_, _, _, _, _, {some, Edited_business_message}, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _} -> new_edited_business_message_update( Raw_update, Edited_business_message ); {_, _, _, _, _, _, {some, Deleted_business_messages}, _, _, _, _, _, _, _, _, _, _, _, _, _, _} -> new_deleted_business_message_update( Raw_update, Deleted_business_messages ); {_, _, _, _, _, _, _, {some, Message_reaction}, _, _, _, _, _, _, _, _, _, _, _, _, _} -> new_message_reaction_update(Raw_update, Message_reaction); {_, _, _, _, _, _, _, _, {some, Message_reaction_count}, _, _, _, _, _, _, _, _, _, _, _, _} -> new_message_reaction_count_update( Raw_update, Message_reaction_count ); {_, _, _, _, _, _, _, _, _, {some, Inline_query}, _, _, _, _, _, _, _, _, _, _, _} -> new_inline_query_update(Raw_update, Inline_query); {_, _, _, _, _, _, _, _, _, _, {some, Chosen_inline_result}, _, _, _, _, _, _, _, _, _, _} -> new_chosen_inline_result_update(Raw_update, Chosen_inline_result); {_, _, _, _, _, _, _, _, _, _, _, {some, Shipping_query}, _, _, _, _, _, _, _, _, _} -> new_shipping_query_update(Raw_update, Shipping_query); {_, _, _, _, _, _, _, _, _, _, _, _, {some, Pre_checkout_query}, _, _, _, _, _, _, _, _} -> new_pre_checkout_query_update(Raw_update, Pre_checkout_query); {_, _, _, _, _, _, _, _, _, _, _, _, _, {some, Purchased_paid_media}, _, _, _, _, _, _, _} -> new_paid_media_purchase_update(Raw_update, Purchased_paid_media); {_, _, _, _, _, _, _, _, _, _, _, _, _, _, {some, Poll}, _, _, _, _, _, _} -> new_poll_update(Raw_update, Poll); {_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, {some, Poll_answer}, _, _, _, _, _} -> new_poll_answer_update(Raw_update, Poll_answer); {_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, {some, My_chat_member}, _, _, _, _} -> new_my_chat_member_update(Raw_update, My_chat_member); {_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, {some, Chat_member}, _, _, _} -> new_chat_member_update(Raw_update, Chat_member); {_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, {some, Chat_join_request}, _, _} -> new_chat_join_request_update(Raw_update, Chat_join_request); {_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, {some, Removed_chat_boost}, _} -> new_removed_chat_boost_update(Raw_update, Removed_chat_boost); {_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, {some, Message}} -> decode_message_update(Raw_update, Message); {_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, none} -> erlang:error(#{gleam_error => panic, message => (<<"Unknown update: "/utf8, (gleam@string:inspect(Raw_update))/binary>>), file => <>, module => <<"telega/update"/utf8>>, function => <<"raw_to_update"/utf8>>, line => 674}) end.