Current section
Files
Jump to
Current section
Files
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, raw_to_update/1, raw/1, to_string/1, type_to_string/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()} |
{guest_message_update,
integer(),
integer(),
telega@model@types:message(),
telega@model@types:update()} |
{subscription_update,
integer(),
integer(),
telega@model@types:bot_subscription_updated(),
telega@model@types:update()}.
-type command() :: {command, binary(), binary(), gleam@option:option(binary())}.
-file("src/telega/update.gleam", 235).
-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", 754).
-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(15, Message))
end.
-file("src/telega/update.gleam", 712).
-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(15, Message)),
Message,
Raw}.
-file("src/telega/update.gleam", 625).
-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(15, Message)),
Text,
Message,
Raw}.
-file("src/telega/update.gleam", 779).
-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", 635).
-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(15, Message)),
extract_command(Text),
Message,
Raw}.
-file("src/telega/update.gleam", 762).
-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", 766).
-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(36, 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", 373).
-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", 689).
-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(15, Message)),
Web_app_data,
Message,
Raw}.
-file("src/telega/update.gleam", 679).
-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(15, Message)),
Voice,
Message,
Raw}.
-file("src/telega/update.gleam", 669).
-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(15, Message)),
Audio,
Message,
Raw}.
-file("src/telega/update.gleam", 659).
-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(15, Message)),
Video,
Message,
Raw}.
-file("src/telega/update.gleam", 645).
-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(15, Message)),
Photos,
Message,
Raw}.
-file("src/telega/update.gleam", 353).
-spec decode_message_update(
telega@model@types:update(),
telega@model@types:message()
) -> update().
decode_message_update(Raw_update, Message) ->
case {erlang:element(46, Message),
erlang:element(49, Message),
erlang:element(42, Message),
erlang:element(51, Message),
erlang:element(119, Message),
erlang:element(35, 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", 995).
-spec new_subscription_update(
telega@model@types:update(),
telega@model@types:bot_subscription_updated()
) -> update().
new_subscription_update(Raw, Subscription) ->
{subscription_update,
erlang:element(2, erlang:element(2, Subscription)),
erlang:element(2, erlang:element(2, Subscription)),
Subscription,
Raw}.
-file("src/telega/update.gleam", 1007).
-spec new_guest_message_update(
telega@model@types:update(),
telega@model@types:message()
) -> update().
new_guest_message_update(Raw, Guest_message) ->
{guest_message_update,
get_sender_id(Guest_message),
erlang:element(2, erlang:element(15, Guest_message)),
Guest_message,
Raw}.
-file("src/telega/update.gleam", 986).
-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", 974).
-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", 962).
-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", 953).
-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", 941).
-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", 909).
-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", 902).
-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", 890).
-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", 878).
-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", 869).
-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", 857).
-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", 848).
-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", 836).
-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", 820).
-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", 808).
-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", 793).
-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(15, Edited_business_message))
end,
erlang:element(2, erlang:element(15, Edited_business_message)),
Edited_business_message,
Raw}.
-file("src/telega/update.gleam", 742).
-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(15, Business_message))
end, erlang:element(2, erlang:element(15, Business_message)), Business_message, Raw}.
-file("src/telega/update.gleam", 730).
-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", 721).
-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(15, Edited_message)),
Edited_message,
Raw}.
-file("src/telega/update.gleam", 703).
-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(15, Channel_post)),
Channel_post,
Raw}.
-file("src/telega/update.gleam", 608).
-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(15, 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", 248).
?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(16, Raw_update) =/= none ->
Callback_query@1 = case erlang:element(16, 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 => <<?FILEPATH/utf8>>,
module => <<"telega/update"/utf8>>,
function => <<"raw_to_update"/utf8>>,
line => 251,
value => _assert_fail,
start => 5958,
'end' => 6017,
pattern_start => 5969,
pattern_end => 5989})
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 => <<?FILEPATH/utf8>>,
module => <<"telega/update"/utf8>>,
function => <<"raw_to_update"/utf8>>,
line => 255,
value => _assert_fail@1,
start => 6136,
'end' => 6191,
pattern_start => 6147,
pattern_end => 6165})
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 => <<?FILEPATH/utf8>>,
module => <<"telega/update"/utf8>>,
function => <<"raw_to_update"/utf8>>,
line => 259,
value => _assert_fail@2,
start => 6308,
'end' => 6367,
pattern_start => 6319,
pattern_end => 6339})
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 => <<?FILEPATH/utf8>>,
module => <<"telega/update"/utf8>>,
function => <<"raw_to_update"/utf8>>,
line => 263,
value => _assert_fail@3,
start => 6493,
'end' => 6562,
pattern_start => 6504,
pattern_end => 6529})
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 => <<?FILEPATH/utf8>>,
module => <<"telega/update"/utf8>>,
function => <<"raw_to_update"/utf8>>,
line => 267,
value => _assert_fail@4,
start => 6695,
'end' => 6758,
pattern_start => 6706,
pattern_end => 6728})
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 => <<?FILEPATH/utf8>>,
module => <<"telega/update"/utf8>>,
function => <<"raw_to_update"/utf8>>,
line => 271,
value => _assert_fail@5,
start => 6892,
'end' => 6977,
pattern_start => 6903,
pattern_end => 6932})
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 => <<?FILEPATH/utf8>>,
module => <<"telega/update"/utf8>>,
function => <<"raw_to_update"/utf8>>,
line => 276,
value => _assert_fail@6,
start => 7127,
'end' => 7216,
pattern_start => 7138,
pattern_end => 7169})
end,
new_deleted_business_message_update(
Raw_update,
Deleted_business_messages@1
);
_ when erlang:element(12, Raw_update) =/= none ->
Message_reaction@1 = case erlang:element(12, 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 => <<?FILEPATH/utf8>>,
module => <<"telega/update"/utf8>>,
function => <<"raw_to_update"/utf8>>,
line => 281,
value => _assert_fail@7,
start => 7360,
'end' => 7423,
pattern_start => 7371,
pattern_end => 7393})
end,
new_message_reaction_update(Raw_update, Message_reaction@1);
_ when erlang:element(13, Raw_update) =/= none ->
Message_reaction_count@1 = case erlang:element(13, 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 => <<?FILEPATH/utf8>>,
module => <<"telega/update"/utf8>>,
function => <<"raw_to_update"/utf8>>,
line => 285,
value => _assert_fail@8,
start => 7556,
'end' => 7639,
pattern_start => 7567,
pattern_end => 7595})
end,
new_message_reaction_count_update(
Raw_update,
Message_reaction_count@1
);
_ when erlang:element(14, Raw_update) =/= none ->
Inline_query@1 = case erlang:element(14, 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 => <<?FILEPATH/utf8>>,
module => <<"telega/update"/utf8>>,
function => <<"raw_to_update"/utf8>>,
line => 290,
value => _assert_fail@9,
start => 7774,
'end' => 7829,
pattern_start => 7785,
pattern_end => 7803})
end,
new_inline_query_update(Raw_update, Inline_query@1);
_ when erlang:element(15, Raw_update) =/= none ->
Chosen_inline_result@1 = case erlang:element(15, 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 => <<?FILEPATH/utf8>>,
module => <<"telega/update"/utf8>>,
function => <<"raw_to_update"/utf8>>,
line => 294,
value => _assert_fail@10,
start => 7952,
'end' => 8023,
pattern_start => 7963,
pattern_end => 7989})
end,
new_chosen_inline_result_update(Raw_update, Chosen_inline_result@1);
_ when erlang:element(17, Raw_update) =/= none ->
Shipping_query@1 = case erlang:element(17, 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 => <<?FILEPATH/utf8>>,
module => <<"telega/update"/utf8>>,
function => <<"raw_to_update"/utf8>>,
line => 298,
value => _assert_fail@11,
start => 8156,
'end' => 8215,
pattern_start => 8167,
pattern_end => 8187})
end,
new_shipping_query_update(Raw_update, Shipping_query@1);
_ when erlang:element(18, Raw_update) =/= none ->
Pre_checkout_query@1 = case erlang:element(18, 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 => <<?FILEPATH/utf8>>,
module => <<"telega/update"/utf8>>,
function => <<"raw_to_update"/utf8>>,
line => 302,
value => _assert_fail@12,
start => 8340,
'end' => 8407,
pattern_start => 8351,
pattern_end => 8375})
end,
new_pre_checkout_query_update(Raw_update, Pre_checkout_query@1);
_ when erlang:element(19, Raw_update) =/= none ->
Purchased_paid_media@1 = case erlang:element(19, 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 => <<?FILEPATH/utf8>>,
module => <<"telega/update"/utf8>>,
function => <<"raw_to_update"/utf8>>,
line => 306,
value => _assert_fail@13,
start => 8542,
'end' => 8613,
pattern_start => 8553,
pattern_end => 8579})
end,
new_paid_media_purchase_update(Raw_update, Purchased_paid_media@1);
_ when erlang:element(20, Raw_update) =/= none ->
Poll@1 = case erlang:element(20, 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 => <<?FILEPATH/utf8>>,
module => <<"telega/update"/utf8>>,
function => <<"raw_to_update"/utf8>>,
line => 310,
value => _assert_fail@14,
start => 8735,
'end' => 8774,
pattern_start => 8746,
pattern_end => 8756})
end,
new_poll_update(Raw_update, Poll@1);
_ when erlang:element(21, Raw_update) =/= none ->
Poll_answer@1 = case erlang:element(21, 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 => <<?FILEPATH/utf8>>,
module => <<"telega/update"/utf8>>,
function => <<"raw_to_update"/utf8>>,
line => 314,
value => _assert_fail@15,
start => 8872,
'end' => 8925,
pattern_start => 8883,
pattern_end => 8900})
end,
new_poll_answer_update(Raw_update, Poll_answer@1);
_ when erlang:element(22, Raw_update) =/= none ->
My_chat_member@1 = case erlang:element(22, 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 => <<?FILEPATH/utf8>>,
module => <<"telega/update"/utf8>>,
function => <<"raw_to_update"/utf8>>,
line => 318,
value => _assert_fail@16,
start => 9040,
'end' => 9099,
pattern_start => 9051,
pattern_end => 9071})
end,
new_my_chat_member_update(Raw_update, My_chat_member@1);
_ when erlang:element(23, Raw_update) =/= none ->
Chat_member@1 = case erlang:element(23, 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 => <<?FILEPATH/utf8>>,
module => <<"telega/update"/utf8>>,
function => <<"raw_to_update"/utf8>>,
line => 322,
value => _assert_fail@17,
start => 9217,
'end' => 9270,
pattern_start => 9228,
pattern_end => 9245})
end,
new_chat_member_update(Raw_update, Chat_member@1);
_ when erlang:element(24, Raw_update) =/= none ->
Chat_join_request@1 = case erlang:element(24, 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 => <<?FILEPATH/utf8>>,
module => <<"telega/update"/utf8>>,
function => <<"raw_to_update"/utf8>>,
line => 326,
value => _assert_fail@18,
start => 9388,
'end' => 9453,
pattern_start => 9399,
pattern_end => 9422})
end,
new_chat_join_request_update(Raw_update, Chat_join_request@1);
_ when erlang:element(26, Raw_update) =/= none ->
Removed_chat_boost@1 = case erlang:element(26, 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 => <<?FILEPATH/utf8>>,
module => <<"telega/update"/utf8>>,
function => <<"raw_to_update"/utf8>>,
line => 330,
value => _assert_fail@19,
start => 9584,
'end' => 9651,
pattern_start => 9595,
pattern_end => 9619})
end,
new_removed_chat_boost_update(Raw_update, Removed_chat_boost@1);
_ when erlang:element(27, Raw_update) =/= none ->
Managed_bot@1 = case erlang:element(27, 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 => <<?FILEPATH/utf8>>,
module => <<"telega/update"/utf8>>,
function => <<"raw_to_update"/utf8>>,
line => 334,
value => _assert_fail@20,
start => 9777,
'end' => 9830,
pattern_start => 9788,
pattern_end => 9805})
end,
new_managed_bot_update(Raw_update, Managed_bot@1);
_ when erlang:element(11, Raw_update) =/= none ->
Guest_message@1 = case erlang:element(11, Raw_update) of
{some, Guest_message} -> Guest_message;
_assert_fail@21 ->
erlang:error(#{gleam_error => let_assert,
message => <<"Pattern match failed, no pattern matched the value."/utf8>>,
file => <<?FILEPATH/utf8>>,
module => <<"telega/update"/utf8>>,
function => <<"raw_to_update"/utf8>>,
line => 338,
value => _assert_fail@21,
start => 9944,
'end' => 10001,
pattern_start => 9955,
pattern_end => 9974})
end,
new_guest_message_update(Raw_update, Guest_message@1);
_ when erlang:element(28, Raw_update) =/= none ->
Subscription@1 = case erlang:element(28, Raw_update) of
{some, Subscription} -> Subscription;
_assert_fail@22 ->
erlang:error(#{gleam_error => let_assert,
message => <<"Pattern match failed, no pattern matched the value."/utf8>>,
file => <<?FILEPATH/utf8>>,
module => <<"telega/update"/utf8>>,
function => <<"raw_to_update"/utf8>>,
line => 342,
value => _assert_fail@22,
start => 10118,
'end' => 10173,
pattern_start => 10129,
pattern_end => 10147})
end,
new_subscription_update(Raw_update, Subscription@1);
_ when erlang:element(3, Raw_update) =/= none ->
Message@1 = case erlang:element(3, Raw_update) of
{some, Message} -> Message;
_assert_fail@23 ->
erlang:error(#{gleam_error => let_assert,
message => <<"Pattern match failed, no pattern matched the value."/utf8>>,
file => <<?FILEPATH/utf8>>,
module => <<"telega/update"/utf8>>,
function => <<"raw_to_update"/utf8>>,
line => 346,
value => _assert_fail@23,
start => 10283,
'end' => 10328,
pattern_start => 10294,
pattern_end => 10307})
end,
decode_message_update(Raw_update, Message@1);
_ ->
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 => 349})
end.
-file("src/telega/update.gleam", 387).
?DOC(
" Get the original raw `ModelUpdate` behind any typed update. Useful when you\n"
" need a field that the typed variant does not surface (e.g. the sender's\n"
" `language_code`).\n"
).
-spec raw(update()) -> telega@model@types:update().
raw(Update) ->
case Update of
{text_update, _, _, _, _, Raw} ->
Raw;
{command_update, _, _, _, _, Raw@1} ->
Raw@1;
{message_update, _, _, _, Raw@2} ->
Raw@2;
{photo_update, _, _, _, _, Raw@3} ->
Raw@3;
{video_update, _, _, _, _, Raw@4} ->
Raw@4;
{audio_update, _, _, _, _, Raw@5} ->
Raw@5;
{voice_update, _, _, _, _, Raw@6} ->
Raw@6;
{media_group_update, _, _, _, _, Raw@7} ->
Raw@7;
{web_app_update, _, _, _, _, Raw@8} ->
Raw@8;
{callback_query_update, _, _, _, Raw@9} ->
Raw@9;
{channel_post_update, _, _, _, Raw@10} ->
Raw@10;
{edited_message_update, _, _, _, Raw@11} ->
Raw@11;
{edited_channel_post_update, _, _, _, Raw@12} ->
Raw@12;
{business_connection_update, _, _, _, Raw@13} ->
Raw@13;
{business_message_update, _, _, _, Raw@14} ->
Raw@14;
{chat_join_request_update, _, _, _, Raw@15} ->
Raw@15;
{chat_member_update, _, _, _, Raw@16} ->
Raw@16;
{chosen_inline_result_update, _, _, _, Raw@17} ->
Raw@17;
{deleted_business_message_update, _, _, _, Raw@18} ->
Raw@18;
{edited_business_message_update, _, _, _, Raw@19} ->
Raw@19;
{inline_query_update, _, _, _, Raw@20} ->
Raw@20;
{message_reaction_count_update, _, _, _, Raw@21} ->
Raw@21;
{message_reaction_update, _, _, _, Raw@22} ->
Raw@22;
{my_chat_member_update, _, _, _, Raw@23} ->
Raw@23;
{paid_media_purchase_update, _, _, _, Raw@24} ->
Raw@24;
{poll_answer_update, _, _, _, Raw@25} ->
Raw@25;
{poll_update, _, _, _, Raw@26} ->
Raw@26;
{pre_checkout_query_update, _, _, _, Raw@27} ->
Raw@27;
{removed_chat_boost, _, _, _, Raw@28} ->
Raw@28;
{shipping_query_update, _, _, _, Raw@29} ->
Raw@29;
{managed_bot_update, _, _, _, Raw@30} ->
Raw@30;
{guest_message_update, _, _, _, Raw@31} ->
Raw@31;
{subscription_update, _, _, _, Raw@32} ->
Raw@32
end.
-file("src/telega/update.gleam", 425).
-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>>;
{guest_message_update, From_id@31, _, Message@4, _} ->
<<<<<<"guest message "/utf8,
(erlang:integer_to_binary(erlang:element(2, Message@4)))/binary>>/binary,
" from "/utf8>>/binary,
(erlang:integer_to_binary(From_id@31))/binary>>;
{subscription_update, From_id@32, _, Subscription, _} ->
<<<<<<"subscription "/utf8,
(erlang:element(4, Subscription))/binary>>/binary,
" from "/utf8>>/binary,
(erlang:integer_to_binary(From_id@32))/binary>>
end.
-file("src/telega/update.gleam", 569).
?DOC(
" Returns a short snake_case tag for the update variant,\n"
" e.g. `\"text\"`, `\"command\"`, `\"callback_query\"`.\n"
" Used as the `update_type` metadata in telemetry events.\n"
).
-spec type_to_string(update()) -> binary().
type_to_string(Update) ->
case Update of
{text_update, _, _, _, _, _} ->
<<"text"/utf8>>;
{command_update, _, _, _, _, _} ->
<<"command"/utf8>>;
{photo_update, _, _, _, _, _} ->
<<"photo"/utf8>>;
{video_update, _, _, _, _, _} ->
<<"video"/utf8>>;
{audio_update, _, _, _, _, _} ->
<<"audio"/utf8>>;
{voice_update, _, _, _, _, _} ->
<<"voice"/utf8>>;
{media_group_update, _, _, _, _, _} ->
<<"media_group"/utf8>>;
{web_app_update, _, _, _, _, _} ->
<<"web_app"/utf8>>;
{message_update, _, _, _, _} ->
<<"message"/utf8>>;
{channel_post_update, _, _, _, _} ->
<<"channel_post"/utf8>>;
{edited_message_update, _, _, _, _} ->
<<"edited_message"/utf8>>;
{edited_channel_post_update, _, _, _, _} ->
<<"edited_channel_post"/utf8>>;
{business_connection_update, _, _, _, _} ->
<<"business_connection"/utf8>>;
{business_message_update, _, _, _, _} ->
<<"business_message"/utf8>>;
{edited_business_message_update, _, _, _, _} ->
<<"edited_business_message"/utf8>>;
{deleted_business_message_update, _, _, _, _} ->
<<"deleted_business_message"/utf8>>;
{message_reaction_update, _, _, _, _} ->
<<"message_reaction"/utf8>>;
{message_reaction_count_update, _, _, _, _} ->
<<"message_reaction_count"/utf8>>;
{inline_query_update, _, _, _, _} ->
<<"inline_query"/utf8>>;
{chosen_inline_result_update, _, _, _, _} ->
<<"chosen_inline_result"/utf8>>;
{callback_query_update, _, _, _, _} ->
<<"callback_query"/utf8>>;
{shipping_query_update, _, _, _, _} ->
<<"shipping_query"/utf8>>;
{pre_checkout_query_update, _, _, _, _} ->
<<"pre_checkout_query"/utf8>>;
{paid_media_purchase_update, _, _, _, _} ->
<<"paid_media_purchase"/utf8>>;
{poll_update, _, _, _, _} ->
<<"poll"/utf8>>;
{poll_answer_update, _, _, _, _} ->
<<"poll_answer"/utf8>>;
{my_chat_member_update, _, _, _, _} ->
<<"my_chat_member"/utf8>>;
{chat_member_update, _, _, _, _} ->
<<"chat_member"/utf8>>;
{chat_join_request_update, _, _, _, _} ->
<<"chat_join_request"/utf8>>;
{removed_chat_boost, _, _, _, _} ->
<<"removed_chat_boost"/utf8>>;
{managed_bot_update, _, _, _, _} ->
<<"managed_bot"/utf8>>;
{guest_message_update, _, _, _, _} ->
<<"guest_message"/utf8>>;
{subscription_update, _, _, _, _} ->
<<"subscription"/utf8>>
end.