-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()} | {managed_bot_update, integer(), integer(), telega@model@types:managed_bot_updated(), telega@model@types:update()}. -type command() :: {command, binary(), binary(), gleam@option:option(binary())}. -file("src/telega/update.gleam", 220). -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", 361). -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>>; {managed_bot_update, From_id@30, _, Managed_bot, _} -> <<<<<<"managed bot "/utf8, (erlang:integer_to_binary( erlang:element(2, erlang:element(3, Managed_bot)) ))/binary>>/binary, " from "/utf8>>/binary, (erlang:integer_to_binary(From_id@30))/binary>> end. -file("src/telega/update.gleam", 493). -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", 611). -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", 623). -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", 635). -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", 510). -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", 530). -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", 540). -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", 550). -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", 560). -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", 570). -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", 584). -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", 593). -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", 602). -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", 643). -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", 647). -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(31, 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", 660). -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", 520). -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", 350). -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", 330). -spec decode_message_update( telega@model@types:update(), telega@model@types:message() ) -> update(). decode_message_update(Raw_update, Message) -> case {erlang:element(39, Message), erlang:element(42, Message), erlang:element(36, Message), erlang:element(44, Message), erlang:element(110, Message), erlang:element(30, 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", 674). -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", 689). -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", 701). -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", 717). -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", 729). -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", 738). -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", 750). -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", 759). -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", 771). -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", 783). -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", 790). -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", 822). -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", 834). -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", 843). -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", 855). -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", 867). -spec new_managed_bot_update( telega@model@types:update(), telega@model@types:managed_bot_updated() ) -> update(). new_managed_bot_update(Raw, Managed_bot) -> {managed_bot_update, erlang:element(2, erlang:element(2, Managed_bot)), erlang:element(2, erlang:element(2, Managed_bot)), Managed_bot, Raw}. -file("src/telega/update.gleam", 233). ?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 Raw_update of _ when erlang:element(15, Raw_update) =/= none -> Callback_query@1 = case erlang:element(15, Raw_update) of {some, Callback_query} -> Callback_query; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"telega/update"/utf8>>, function => <<"raw_to_update"/utf8>>, line => 236, value => _assert_fail, start => 5485, 'end' => 5544, pattern_start => 5496, pattern_end => 5516}) end, new_callback_query_update(Raw_update, Callback_query@1); _ when erlang:element(5, Raw_update) =/= none -> Channel_post@1 = case erlang:element(5, Raw_update) of {some, Channel_post} -> Channel_post; _assert_fail@1 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"telega/update"/utf8>>, function => <<"raw_to_update"/utf8>>, line => 240, value => _assert_fail@1, start => 5663, 'end' => 5718, pattern_start => 5674, pattern_end => 5692}) end, new_channel_post_update(Raw_update, Channel_post@1); _ when erlang:element(4, Raw_update) =/= none -> Edited_message@1 = case erlang:element(4, Raw_update) of {some, Edited_message} -> Edited_message; _assert_fail@2 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"telega/update"/utf8>>, function => <<"raw_to_update"/utf8>>, line => 244, value => _assert_fail@2, start => 5835, 'end' => 5894, pattern_start => 5846, pattern_end => 5866}) end, new_edited_message_update(Raw_update, Edited_message@1); _ when erlang:element(7, Raw_update) =/= none -> Business_connection@1 = case erlang:element(7, Raw_update) of {some, Business_connection} -> Business_connection; _assert_fail@3 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"telega/update"/utf8>>, function => <<"raw_to_update"/utf8>>, line => 248, value => _assert_fail@3, start => 6020, 'end' => 6089, pattern_start => 6031, pattern_end => 6056}) end, new_business_connection_update(Raw_update, Business_connection@1); _ when erlang:element(8, Raw_update) =/= none -> Business_message@1 = case erlang:element(8, Raw_update) of {some, Business_message} -> Business_message; _assert_fail@4 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"telega/update"/utf8>>, function => <<"raw_to_update"/utf8>>, line => 252, value => _assert_fail@4, start => 6222, 'end' => 6285, pattern_start => 6233, pattern_end => 6255}) end, new_business_message_update(Raw_update, Business_message@1); _ when erlang:element(9, Raw_update) =/= none -> Edited_business_message@1 = case erlang:element(9, Raw_update) of {some, Edited_business_message} -> Edited_business_message; _assert_fail@5 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"telega/update"/utf8>>, function => <<"raw_to_update"/utf8>>, line => 256, value => _assert_fail@5, start => 6419, 'end' => 6504, pattern_start => 6430, pattern_end => 6459}) end, new_edited_business_message_update( Raw_update, Edited_business_message@1 ); _ when erlang:element(10, Raw_update) =/= none -> Deleted_business_messages@1 = case erlang:element(10, Raw_update) of {some, Deleted_business_messages} -> Deleted_business_messages; _assert_fail@6 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"telega/update"/utf8>>, function => <<"raw_to_update"/utf8>>, line => 261, value => _assert_fail@6, start => 6654, 'end' => 6743, pattern_start => 6665, pattern_end => 6696}) end, new_deleted_business_message_update( Raw_update, Deleted_business_messages@1 ); _ when erlang:element(11, Raw_update) =/= none -> Message_reaction@1 = case erlang:element(11, Raw_update) of {some, Message_reaction} -> Message_reaction; _assert_fail@7 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"telega/update"/utf8>>, function => <<"raw_to_update"/utf8>>, line => 266, value => _assert_fail@7, start => 6887, 'end' => 6950, pattern_start => 6898, pattern_end => 6920}) end, new_message_reaction_update(Raw_update, Message_reaction@1); _ when erlang:element(12, Raw_update) =/= none -> Message_reaction_count@1 = case erlang:element(12, Raw_update) of {some, Message_reaction_count} -> Message_reaction_count; _assert_fail@8 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"telega/update"/utf8>>, function => <<"raw_to_update"/utf8>>, line => 270, value => _assert_fail@8, start => 7083, 'end' => 7166, pattern_start => 7094, pattern_end => 7122}) end, new_message_reaction_count_update( Raw_update, Message_reaction_count@1 ); _ when erlang:element(13, Raw_update) =/= none -> Inline_query@1 = case erlang:element(13, Raw_update) of {some, Inline_query} -> Inline_query; _assert_fail@9 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"telega/update"/utf8>>, function => <<"raw_to_update"/utf8>>, line => 275, value => _assert_fail@9, start => 7301, 'end' => 7356, pattern_start => 7312, pattern_end => 7330}) end, new_inline_query_update(Raw_update, Inline_query@1); _ when erlang:element(14, Raw_update) =/= none -> Chosen_inline_result@1 = case erlang:element(14, Raw_update) of {some, Chosen_inline_result} -> Chosen_inline_result; _assert_fail@10 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"telega/update"/utf8>>, function => <<"raw_to_update"/utf8>>, line => 279, value => _assert_fail@10, start => 7479, 'end' => 7550, pattern_start => 7490, pattern_end => 7516}) end, new_chosen_inline_result_update(Raw_update, Chosen_inline_result@1); _ when erlang:element(16, Raw_update) =/= none -> Shipping_query@1 = case erlang:element(16, Raw_update) of {some, Shipping_query} -> Shipping_query; _assert_fail@11 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"telega/update"/utf8>>, function => <<"raw_to_update"/utf8>>, line => 283, value => _assert_fail@11, start => 7683, 'end' => 7742, pattern_start => 7694, pattern_end => 7714}) end, new_shipping_query_update(Raw_update, Shipping_query@1); _ when erlang:element(17, Raw_update) =/= none -> Pre_checkout_query@1 = case erlang:element(17, Raw_update) of {some, Pre_checkout_query} -> Pre_checkout_query; _assert_fail@12 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"telega/update"/utf8>>, function => <<"raw_to_update"/utf8>>, line => 287, value => _assert_fail@12, start => 7867, 'end' => 7934, pattern_start => 7878, pattern_end => 7902}) end, new_pre_checkout_query_update(Raw_update, Pre_checkout_query@1); _ when erlang:element(18, Raw_update) =/= none -> Purchased_paid_media@1 = case erlang:element(18, Raw_update) of {some, Purchased_paid_media} -> Purchased_paid_media; _assert_fail@13 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"telega/update"/utf8>>, function => <<"raw_to_update"/utf8>>, line => 291, value => _assert_fail@13, start => 8069, 'end' => 8140, pattern_start => 8080, pattern_end => 8106}) end, new_paid_media_purchase_update(Raw_update, Purchased_paid_media@1); _ when erlang:element(19, Raw_update) =/= none -> Poll@1 = case erlang:element(19, Raw_update) of {some, Poll} -> Poll; _assert_fail@14 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"telega/update"/utf8>>, function => <<"raw_to_update"/utf8>>, line => 295, value => _assert_fail@14, start => 8262, 'end' => 8301, pattern_start => 8273, pattern_end => 8283}) end, new_poll_update(Raw_update, Poll@1); _ when erlang:element(20, Raw_update) =/= none -> Poll_answer@1 = case erlang:element(20, Raw_update) of {some, Poll_answer} -> Poll_answer; _assert_fail@15 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"telega/update"/utf8>>, function => <<"raw_to_update"/utf8>>, line => 299, value => _assert_fail@15, start => 8399, 'end' => 8452, pattern_start => 8410, pattern_end => 8427}) end, new_poll_answer_update(Raw_update, Poll_answer@1); _ when erlang:element(21, Raw_update) =/= none -> My_chat_member@1 = case erlang:element(21, Raw_update) of {some, My_chat_member} -> My_chat_member; _assert_fail@16 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"telega/update"/utf8>>, function => <<"raw_to_update"/utf8>>, line => 303, value => _assert_fail@16, start => 8567, 'end' => 8626, pattern_start => 8578, pattern_end => 8598}) end, new_my_chat_member_update(Raw_update, My_chat_member@1); _ when erlang:element(22, Raw_update) =/= none -> Chat_member@1 = case erlang:element(22, Raw_update) of {some, Chat_member} -> Chat_member; _assert_fail@17 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"telega/update"/utf8>>, function => <<"raw_to_update"/utf8>>, line => 307, value => _assert_fail@17, start => 8744, 'end' => 8797, pattern_start => 8755, pattern_end => 8772}) end, new_chat_member_update(Raw_update, Chat_member@1); _ when erlang:element(23, Raw_update) =/= none -> Chat_join_request@1 = case erlang:element(23, Raw_update) of {some, Chat_join_request} -> Chat_join_request; _assert_fail@18 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"telega/update"/utf8>>, function => <<"raw_to_update"/utf8>>, line => 311, value => _assert_fail@18, start => 8915, 'end' => 8980, pattern_start => 8926, pattern_end => 8949}) end, new_chat_join_request_update(Raw_update, Chat_join_request@1); _ when erlang:element(25, Raw_update) =/= none -> Removed_chat_boost@1 = case erlang:element(25, Raw_update) of {some, Removed_chat_boost} -> Removed_chat_boost; _assert_fail@19 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"telega/update"/utf8>>, function => <<"raw_to_update"/utf8>>, line => 315, value => _assert_fail@19, start => 9111, 'end' => 9178, pattern_start => 9122, pattern_end => 9146}) end, new_removed_chat_boost_update(Raw_update, Removed_chat_boost@1); _ when erlang:element(26, Raw_update) =/= none -> Managed_bot@1 = case erlang:element(26, Raw_update) of {some, Managed_bot} -> Managed_bot; _assert_fail@20 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"telega/update"/utf8>>, function => <<"raw_to_update"/utf8>>, line => 319, value => _assert_fail@20, start => 9304, 'end' => 9357, pattern_start => 9315, pattern_end => 9332}) end, new_managed_bot_update(Raw_update, Managed_bot@1); _ when erlang:element(3, Raw_update) =/= none -> Message@1 = case erlang:element(3, Raw_update) of {some, Message} -> Message; _assert_fail@21 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"telega/update"/utf8>>, function => <<"raw_to_update"/utf8>>, line => 323, value => _assert_fail@21, start => 9465, 'end' => 9510, pattern_start => 9476, pattern_end => 9489}) end, decode_message_update(Raw_update, Message@1); _ -> 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 => 326}) end.