Current section

Files

Jump to
telega src telega@update.erl
Raw

src/telega@update.erl

-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()} |
{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", 205).
-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", 252).
-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>>;
{web_app_update, From_id@7, _, Web_app_data, _, _} ->
<<<<<<"web app "/utf8, (erlang:element(2, Web_app_data))/binary>>/binary,
" from "/utf8>>/binary,
(erlang:integer_to_binary(From_id@7))/binary>>;
{callback_query_update, From_id@8, _, 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@8))/binary>>;
{channel_post_update, From_id@9, _, Post, _} ->
<<<<<<"channel post "/utf8,
(erlang:integer_to_binary(erlang:element(2, Post)))/binary>>/binary,
" from "/utf8>>/binary,
(erlang:integer_to_binary(From_id@9))/binary>>;
{edited_message_update, From_id@10, _, 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@10))/binary>>;
{edited_channel_post_update, From_id@11, _, 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@11))/binary>>;
{business_connection_update, From_id@12, _, Business_connection, _} ->
<<<<<<"business connection "/utf8,
(erlang:element(2, Business_connection))/binary>>/binary,
" from "/utf8>>/binary,
(erlang:integer_to_binary(From_id@12))/binary>>;
{business_message_update, From_id@13, _, 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@13))/binary>>;
{chat_join_request_update, From_id@14, _, 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@14))/binary>>;
{chat_member_update, From_id@15, _, 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@15))/binary>>;
{chosen_inline_result_update, From_id@16, _, Chosen_inline_result, _} ->
<<<<<<"chosen inline result "/utf8,
(erlang:element(2, Chosen_inline_result))/binary>>/binary,
" from "/utf8>>/binary,
(erlang:integer_to_binary(From_id@16))/binary>>;
{deleted_business_message_update,
From_id@17,
_,
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@17))/binary>>;
{edited_business_message_update, From_id@18, _, 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@18))/binary>>;
{inline_query_update, From_id@19, _, Inline_query, _} ->
<<<<<<"inline query "/utf8,
(erlang:element(2, Inline_query))/binary>>/binary,
" from "/utf8>>/binary,
(erlang:integer_to_binary(From_id@19))/binary>>;
{message_reaction_count_update,
From_id@20,
_,
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@20))/binary>>;
{message_reaction_update, From_id@21, _, 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@21))/binary>>;
{my_chat_member_update, From_id@22, _, 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@22))/binary>>;
{paid_media_purchase_update, From_id@23, _, _, _} ->
<<"paid media purchase from "/utf8,
(erlang:integer_to_binary(From_id@23))/binary>>;
{poll_answer_update, From_id@24, _, Poll_answer, _} ->
<<<<<<"poll answer "/utf8, (erlang:element(2, Poll_answer))/binary>>/binary,
" from "/utf8>>/binary,
(erlang:integer_to_binary(From_id@24))/binary>>;
{poll_update, From_id@25, _, Poll, _} ->
<<<<<<"poll "/utf8, (erlang:element(2, Poll))/binary>>/binary,
" from "/utf8>>/binary,
(erlang:integer_to_binary(From_id@25))/binary>>;
{pre_checkout_query_update, From_id@26, _, Pre_checkout_query, _} ->
<<<<<<"pre checkout query "/utf8,
(erlang:element(2, Pre_checkout_query))/binary>>/binary,
" from "/utf8>>/binary,
(erlang:integer_to_binary(From_id@26))/binary>>;
{removed_chat_boost, From_id@27, _, 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@27))/binary>>;
{shipping_query_update, From_id@28, _, Shipping_query, _} ->
<<<<<<"shipping query "/utf8,
(erlang:element(2, Shipping_query))/binary>>/binary,
" from "/utf8>>/binary,
(erlang:integer_to_binary(From_id@28))/binary>>
end.
-file("src/telega/update.gleam", 483).
-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(10, 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", 378).
-spec try_decode_callback_query(
telega@model@types:update(),
fun(() -> update())
) -> update().
try_decode_callback_query(Raw, On_none) ->
case erlang:element(15, Raw) of
{some, Callback_query} ->
new_callback_query_update(Raw, Callback_query);
none ->
On_none()
end.
-file("src/telega/update.gleam", 500).
-spec new_text_update(
telega@model@types:update(),
telega@model@types:message(),
binary()
) -> update().
new_text_update(Raw, Message, Text) ->
{text_update, case erlang:element(4, Message) of
{some, User} ->
erlang:element(2, User);
none ->
erlang:element(2, erlang:element(10, Message))
end, erlang:element(2, erlang:element(10, Message)), Text, Message, Raw}.
-file("src/telega/update.gleam", 526).
-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, case erlang:element(4, Message) of
{some, User} ->
erlang:element(2, User);
none ->
erlang:element(2, erlang:element(10, Message))
end, erlang:element(2, erlang:element(10, Message)), Photos, Message, Raw}.
-file("src/telega/update.gleam", 404).
-spec try_decode_photo_message(telega@model@types:update(), fun(() -> update())) -> update().
try_decode_photo_message(Raw, On_none) ->
case erlang:element(3, Raw) of
{some, Message} ->
case erlang:element(33, Message) of
{some, Photos} ->
new_photo_update(Raw, Message, Photos);
none ->
On_none()
end;
none ->
On_none()
end.
-file("src/telega/update.gleam", 539).
-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, case erlang:element(4, Message) of
{some, User} ->
erlang:element(2, User);
none ->
erlang:element(2, erlang:element(10, Message))
end, erlang:element(2, erlang:element(10, Message)), Video, Message, Raw}.
-file("src/telega/update.gleam", 415).
-spec try_decode_video_message(telega@model@types:update(), fun(() -> update())) -> update().
try_decode_video_message(Raw, On_none) ->
case erlang:element(3, Raw) of
{some, Message} ->
case erlang:element(36, Message) of
{some, Video} ->
new_video_update(Raw, Message, Video);
none ->
On_none()
end;
none ->
On_none()
end.
-file("src/telega/update.gleam", 552).
-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, case erlang:element(4, Message) of
{some, User} ->
erlang:element(2, User);
none ->
erlang:element(2, erlang:element(10, Message))
end, erlang:element(2, erlang:element(10, Message)), Audio, Message, Raw}.
-file("src/telega/update.gleam", 426).
-spec try_decode_audio_message(telega@model@types:update(), fun(() -> update())) -> update().
try_decode_audio_message(Raw, On_none) ->
case erlang:element(3, Raw) of
{some, Message} ->
case erlang:element(30, Message) of
{some, Audio} ->
new_audio_update(Raw, Message, Audio);
none ->
On_none()
end;
none ->
On_none()
end.
-file("src/telega/update.gleam", 565).
-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, case erlang:element(4, Message) of
{some, User} ->
erlang:element(2, User);
none ->
erlang:element(2, erlang:element(10, Message))
end, erlang:element(2, erlang:element(10, Message)), Voice, Message, Raw}.
-file("src/telega/update.gleam", 437).
-spec try_decode_voice_message(telega@model@types:update(), fun(() -> update())) -> update().
try_decode_voice_message(Raw, On_none) ->
case erlang:element(3, Raw) of
{some, Message} ->
case erlang:element(38, Message) of
{some, Voice} ->
new_voice_update(Raw, Message, Voice);
none ->
On_none()
end;
none ->
On_none()
end.
-file("src/telega/update.gleam", 578).
-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, case erlang:element(4, Message) of
{some, User} ->
erlang:element(2, User);
none ->
erlang:element(2, erlang:element(10, Message))
end, erlang:element(2, erlang:element(10, Message)), Web_app_data, Message, Raw}.
-file("src/telega/update.gleam", 448).
-spec try_decode_web_app_data(telega@model@types:update(), fun(() -> update())) -> update().
try_decode_web_app_data(Raw, On_none) ->
case erlang:element(3, Raw) of
{some, Message} ->
case erlang:element(93, Message) of
{some, Web_app_data} ->
new_web_app_data_update(Raw, Message, Web_app_data);
none ->
On_none()
end;
none ->
On_none()
end.
-file("src/telega/update.gleam", 595).
-spec new_channel_post_update(
telega@model@types:update(),
telega@model@types:message()
) -> update().
new_channel_post_update(Raw, Channel_post) ->
{channel_post_update, case erlang:element(4, Channel_post) of
{some, User} ->
erlang:element(2, User);
none ->
erlang:element(2, erlang:element(10, Channel_post))
end, erlang:element(2, erlang:element(10, Channel_post)), Channel_post, Raw}.
-file("src/telega/update.gleam", 371).
-spec try_decode_channel_post(telega@model@types:update(), fun(() -> update())) -> update().
try_decode_channel_post(Raw, On_none) ->
case erlang:element(5, Raw) of
{some, Channel_post} ->
new_channel_post_update(Raw, Channel_post);
none ->
On_none()
end.
-file("src/telega/update.gleam", 607).
-spec new_message_update(
telega@model@types:update(),
telega@model@types:message()
) -> update().
new_message_update(Raw, Message) ->
{message_update, case erlang:element(4, Message) of
{some, User} ->
erlang:element(2, User);
none ->
erlang:element(2, erlang:element(10, Message))
end, erlang:element(2, erlang:element(10, Message)), Message, Raw}.
-file("src/telega/update.gleam", 619).
-spec new_edited_message_update(
telega@model@types:update(),
telega@model@types:message()
) -> update().
new_edited_message_update(Raw, Edited_message) ->
{edited_message_update, case erlang:element(4, Edited_message) of
{some, User} ->
erlang:element(2, User);
none ->
erlang:element(2, erlang:element(10, Edited_message))
end, erlang:element(2, erlang:element(10, Edited_message)), Edited_message, Raw}.
-file("src/telega/update.gleam", 460).
-spec try_decode_edited_message(
telega@model@types:update(),
fun(() -> update())
) -> update().
try_decode_edited_message(Raw, On_none) ->
case erlang:element(4, Raw) of
{some, Edited_message} ->
new_edited_message_update(Raw, Edited_message);
none ->
On_none()
end.
-file("src/telega/update.gleam", 631).
-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", 467).
-spec try_decode_business_connection(
telega@model@types:update(),
fun(() -> update())
) -> update().
try_decode_business_connection(Raw, On_none) ->
case erlang:element(7, Raw) of
{some, Business_connection} ->
new_business_connection_update(Raw, Business_connection);
none ->
On_none()
end.
-file("src/telega/update.gleam", 643).
-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(4, Business_message) of
{some, User} ->
erlang:element(2, User);
none ->
erlang:element(2, erlang:element(10, Business_message))
end, erlang:element(2, erlang:element(10, Business_message)), Business_message, Raw}.
-file("src/telega/update.gleam", 475).
-spec try_decode_business_message(
telega@model@types:update(),
fun(() -> update())
) -> update().
try_decode_business_message(Raw, On_none) ->
case erlang:element(8, Raw) of
{some, Business_message} ->
new_business_message_update(Raw, Business_message);
none ->
On_none()
end.
-file("src/telega/update.gleam", 655).
-spec is_command_entity(binary(), telega@model@types:message_entity()) -> boolean().
is_command_entity(Text, Entity) ->
((erlang:element(2, Entity) =:= <<"bot_command"/utf8>>) andalso (erlang:element(
3,
Entity
)
=:= 0))
andalso (erlang:element(4, Entity) =:= string:length(Text)).
-file("src/telega/update.gleam", 661).
-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(26, Message) of
{some, Entities} ->
gleam@list:any(
Entities,
fun(_capture) ->
is_command_entity(Text, _capture)
end
);
none ->
false
end;
none ->
false
end end
).
-file("src/telega/update.gleam", 674).
-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", 513).
-spec new_command_update(
telega@model@types:update(),
telega@model@types:message(),
binary()
) -> update().
new_command_update(Raw, Message, Text) ->
{command_update, case erlang:element(4, Message) of
{some, User} ->
erlang:element(2, User);
none ->
erlang:element(2, erlang:element(10, Message))
end, erlang:element(2, erlang:element(10, Message)), extract_command(
Text
), Message, Raw}.
-file("src/telega/update.gleam", 397).
-spec try_decode_text_message(
telega@model@types:update(),
telega@model@types:message(),
binary()
) -> update().
try_decode_text_message(Raw, Message, Text) ->
case is_command_update(Text, Raw) of
true ->
new_command_update(Raw, Message, Text);
false ->
new_text_update(Raw, Message, Text)
end.
-file("src/telega/update.gleam", 386).
-spec try_decode_message(telega@model@types:update(), fun(() -> update())) -> update().
try_decode_message(Raw, On_none) ->
case erlang:element(3, Raw) of
{some, Message} ->
case erlang:element(25, Message) of
{some, Text} ->
try_decode_text_message(Raw, Message, Text);
none ->
new_message_update(Raw, Message)
end;
none ->
On_none()
end.
-file("src/telega/update.gleam", 801).
-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(4, Edited_business_message) of
{some, User} ->
erlang:element(2, User);
none ->
erlang:element(2, erlang:element(10, Edited_business_message))
end,
erlang:element(2, erlang:element(10, Edited_business_message)),
Edited_business_message,
Raw}.
-file("src/telega/update.gleam", 688).
-spec try_decode_edited_business_message(
telega@model@types:update(),
fun(() -> update())
) -> update().
try_decode_edited_business_message(Raw, On_none) ->
case erlang:element(9, Raw) of
{some, Edited_business_message} ->
new_edited_business_message_update(Raw, Edited_business_message);
none ->
On_none()
end.
-file("src/telega/update.gleam", 816).
-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", 696).
-spec try_decode_deleted_business_message(
telega@model@types:update(),
fun(() -> update())
) -> update().
try_decode_deleted_business_message(Raw, On_none) ->
case erlang:element(10, Raw) of
{some, Deleted_business_messages} ->
new_deleted_business_message_update(Raw, Deleted_business_messages);
none ->
On_none()
end.
-file("src/telega/update.gleam", 828).
-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) of
{some, User} ->
erlang:element(2, User);
none ->
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", 704).
-spec try_decode_message_reaction(
telega@model@types:update(),
fun(() -> update())
) -> update().
try_decode_message_reaction(Raw, On_none) ->
case erlang:element(11, Raw) of
{some, Message_reaction} ->
new_message_reaction_update(Raw, Message_reaction);
none ->
On_none()
end.
-file("src/telega/update.gleam", 843).
-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", 711).
-spec try_decode_message_reaction_count(
telega@model@types:update(),
fun(() -> update())
) -> update().
try_decode_message_reaction_count(Raw, On_none) ->
case erlang:element(12, Raw) of
{some, Message_reaction_count} ->
new_message_reaction_count_update(Raw, Message_reaction_count);
none ->
On_none()
end.
-file("src/telega/update.gleam", 855).
-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", 719).
-spec try_decode_inline_query(telega@model@types:update(), fun(() -> update())) -> update().
try_decode_inline_query(Raw, On_none) ->
case erlang:element(13, Raw) of
{some, Inline_query} ->
new_inline_query_update(Raw, Inline_query);
none ->
On_none()
end.
-file("src/telega/update.gleam", 864).
-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", 726).
-spec try_decode_chosen_inline_result(
telega@model@types:update(),
fun(() -> update())
) -> update().
try_decode_chosen_inline_result(Raw, On_none) ->
case erlang:element(14, Raw) of
{some, Chosen_inline_result} ->
new_chosen_inline_result_update(Raw, Chosen_inline_result);
none ->
On_none()
end.
-file("src/telega/update.gleam", 876).
-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", 734).
-spec try_decode_shipping_query(
telega@model@types:update(),
fun(() -> update())
) -> update().
try_decode_shipping_query(Raw, On_none) ->
case erlang:element(16, Raw) of
{some, Shipping_query} ->
new_shipping_query_update(Raw, Shipping_query);
none ->
On_none()
end.
-file("src/telega/update.gleam", 885).
-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", 741).
-spec try_decode_pre_checkout_query(
telega@model@types:update(),
fun(() -> update())
) -> update().
try_decode_pre_checkout_query(Raw, On_none) ->
case erlang:element(17, Raw) of
{some, Pre_checkout_query} ->
new_pre_checkout_query_update(Raw, Pre_checkout_query);
none ->
On_none()
end.
-file("src/telega/update.gleam", 897).
-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", 749).
-spec try_decode_paid_media_purchase(
telega@model@types:update(),
fun(() -> update())
) -> update().
try_decode_paid_media_purchase(Raw, On_none) ->
case erlang:element(18, Raw) of
{some, Purchased_paid_media} ->
new_paid_media_purchase_update(Raw, Purchased_paid_media);
none ->
On_none()
end.
-file("src/telega/update.gleam", 909).
-spec new_poll_update(telega@model@types:update(), telega@model@types:poll()) -> update().
new_poll_update(Raw, Poll) ->
{poll_update, 0, 0, Poll, Raw}.
-file("src/telega/update.gleam", 757).
-spec try_decode_poll(telega@model@types:update(), fun(() -> update())) -> update().
try_decode_poll(Raw, On_none) ->
case erlang:element(19, Raw) of
{some, Poll} ->
new_poll_update(Raw, Poll);
none ->
On_none()
end.
-file("src/telega/update.gleam", 920).
-spec new_poll_answer_update(
telega@model@types:update(),
telega@model@types:poll_answer()
) -> update().
new_poll_answer_update(Raw, Poll_answer) ->
{poll_answer_update, case erlang:element(4, Poll_answer) of
{some, User} ->
erlang:element(2, User);
none ->
0
end, case erlang:element(3, Poll_answer) of
{some, Chat} ->
erlang:element(2, Chat);
none ->
0
end, Poll_answer, Raw}.
-file("src/telega/update.gleam", 764).
-spec try_decode_poll_answer(telega@model@types:update(), fun(() -> update())) -> update().
try_decode_poll_answer(Raw, On_none) ->
case erlang:element(20, Raw) of
{some, Poll_answer} ->
new_poll_answer_update(Raw, Poll_answer);
none ->
On_none()
end.
-file("src/telega/update.gleam", 937).
-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", 771).
-spec try_decode_my_chat_member(
telega@model@types:update(),
fun(() -> update())
) -> update().
try_decode_my_chat_member(Raw, On_none) ->
case erlang:element(21, Raw) of
{some, My_chat_member} ->
new_my_chat_member_update(Raw, My_chat_member);
none ->
On_none()
end.
-file("src/telega/update.gleam", 949).
-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", 778).
-spec try_decode_chat_member(telega@model@types:update(), fun(() -> update())) -> update().
try_decode_chat_member(Raw, On_none) ->
case erlang:element(22, Raw) of
{some, Chat_member} ->
new_chat_member_update(Raw, Chat_member);
none ->
On_none()
end.
-file("src/telega/update.gleam", 958).
-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", 785).
-spec try_decode_chat_join_request(
telega@model@types:update(),
fun(() -> update())
) -> update().
try_decode_chat_join_request(Raw, On_none) ->
case erlang:element(23, Raw) of
{some, Chat_join_request} ->
new_chat_join_request_update(Raw, Chat_join_request);
none ->
On_none()
end.
-file("src/telega/update.gleam", 970).
-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", 793).
-spec try_decode_removed_chat_boost(
telega@model@types:update(),
fun(() -> update())
) -> update().
try_decode_removed_chat_boost(Raw, On_none) ->
case erlang:element(25, Raw) of
{some, Removed_chat_boost} ->
new_removed_chat_boost_update(Raw, Removed_chat_boost);
none ->
On_none()
end.
-file("src/telega/update.gleam", 218).
?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) ->
try_decode_callback_query(
Raw_update,
fun() ->
try_decode_channel_post(
Raw_update,
fun() ->
try_decode_edited_message(
Raw_update,
fun() ->
try_decode_business_connection(
Raw_update,
fun() ->
try_decode_business_message(
Raw_update,
fun() ->
try_decode_edited_business_message(
Raw_update,
fun() ->
try_decode_deleted_business_message(
Raw_update,
fun() ->
try_decode_message_reaction(
Raw_update,
fun() ->
try_decode_message_reaction_count(
Raw_update,
fun() ->
try_decode_inline_query(
Raw_update,
fun(
) ->
try_decode_chosen_inline_result(
Raw_update,
fun(
) ->
try_decode_shipping_query(
Raw_update,
fun(
) ->
try_decode_pre_checkout_query(
Raw_update,
fun(
) ->
try_decode_paid_media_purchase(
Raw_update,
fun(
) ->
try_decode_poll(
Raw_update,
fun(
) ->
try_decode_poll_answer(
Raw_update,
fun(
) ->
try_decode_my_chat_member(
Raw_update,
fun(
) ->
try_decode_chat_member(
Raw_update,
fun(
) ->
try_decode_chat_join_request(
Raw_update,
fun(
) ->
try_decode_removed_chat_boost(
Raw_update,
fun(
) ->
try_decode_photo_message(
Raw_update,
fun(
) ->
try_decode_video_message(
Raw_update,
fun(
) ->
try_decode_audio_message(
Raw_update,
fun(
) ->
try_decode_voice_message(
Raw_update,
fun(
) ->
try_decode_web_app_data(
Raw_update,
fun(
) ->
try_decode_message(
Raw_update,
fun(
) ->
erlang:error(
#{gleam_error => panic,
message => (<<"Unknown update: "/utf8,
(gleam@string:inspect(
Raw_update
))/binary>>),
file => <<?FILEPATH/utf8>>,
module => <<"telega/update"/utf8>>,
function => <<"raw_to_update"/utf8>>,
line => 249}
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
).