Update fastapi_app.py
Browse files- fastapi_app.py +794 -1
fastapi_app.py
CHANGED
@@ -820,4 +820,797 @@ async def send_dice_endpoint(chat_id: int):
|
|
820 |
return {"message_id": message.id}
|
821 |
|
822 |
@app.post("/send_poll")
|
823 |
-
async def send_poll_endpoint(chat_id: int, question: str, options: list, is_anonymous: bool = False, type: str = "regular", allows_multiple_answers: bool = False, correct_option_id: int = None, explanation: str =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
820 |
return {"message_id": message.id}
|
821 |
|
822 |
@app.post("/send_poll")
|
823 |
+
async def send_poll_endpoint(chat_id: int, question: str, options: list, is_anonymous: bool = False, type: str = "regular", allows_multiple_answers: bool = False, correct_option_id: int = None, explanation: str = None, explanation_parse_mode: str = None, open_period: int = None, close_date: int = None, is_closed: bool = False):
|
824 |
+
message = await bot_instance.send_poll(
|
825 |
+
chat_id,
|
826 |
+
question,
|
827 |
+
options,
|
828 |
+
is_anonymous=is_anonymous,
|
829 |
+
type=type,
|
830 |
+
allows_multiple_answers=allows_multiple_answers,
|
831 |
+
correct_option_id=correct_option_id,
|
832 |
+
explanation=explanation,
|
833 |
+
explanation_parse_mode=explanation_parse_mode,
|
834 |
+
open_period=open_period,
|
835 |
+
close_date=close_date,
|
836 |
+
is_closed=is_closed
|
837 |
+
)
|
838 |
+
return {"message_id": message.id}
|
839 |
+
|
840 |
+
|
841 |
+
@app.post("/send_chat_action")
|
842 |
+
async def send_chat_action_endpoint(chat_id: int, action: str):
|
843 |
+
actions = {
|
844 |
+
"typing": enums.ChatAction.TYPING,
|
845 |
+
"upload_photo": enums.ChatAction.UPLOAD_PHOTO,
|
846 |
+
"record_video": enums.ChatAction.RECORD_VIDEO,
|
847 |
+
"upload_video": enums.ChatAction.UPLOAD_VIDEO,
|
848 |
+
"record_voice": enums.ChatAction.RECORD_VOICE,
|
849 |
+
"upload_voice": enums.ChatAction.UPLOAD_VOICE,
|
850 |
+
"upload_document": enums.ChatAction.UPLOAD_DOCUMENT,
|
851 |
+
"find_location": enums.ChatAction.FIND_LOCATION,
|
852 |
+
"record_video_note": enums.ChatAction.RECORD_VIDEO_NOTE,
|
853 |
+
"upload_video_note": enums.ChatAction.UPLOAD_VIDEO_NOTE,
|
854 |
+
"playing": enums.ChatAction.PLAYING
|
855 |
+
}
|
856 |
+
action_enum = actions.get(action)
|
857 |
+
if not action_enum:
|
858 |
+
return {"error": "Invalid action"}
|
859 |
+
await bot_instance.send_chat_action(chat_id, action_enum)
|
860 |
+
return {"status": "Chat action sent successfully"}
|
861 |
+
|
862 |
+
@app.post("/create_chat_invite_link")
|
863 |
+
async def create_chat_invite_link_endpoint(chat_id: int, name: str = None, expire_date: int = None, member_limit: int = None, creates_join_request: bool = False):
|
864 |
+
invite_link = await bot_instance.create_chat_invite_link(
|
865 |
+
chat_id,
|
866 |
+
name=name,
|
867 |
+
expire_date=expire_date,
|
868 |
+
member_limit=member_limit,
|
869 |
+
creates_join_request=creates_join_request
|
870 |
+
)
|
871 |
+
return {"invite_link": invite_link.invite_link}
|
872 |
+
|
873 |
+
@app.post("/set_chat_photo")
|
874 |
+
async def set_chat_photo_endpoint(chat_id: int, photo_url: str):
|
875 |
+
response = requests.get(photo_url)
|
876 |
+
photo = BytesIO(response.content)
|
877 |
+
photo.name = "photo.jpg"
|
878 |
+
await bot_instance.set_chat_photo(chat_id, photo)
|
879 |
+
return {"status": "Chat photo set successfully"}
|
880 |
+
|
881 |
+
@app.post("/delete_chat_photo")
|
882 |
+
async def delete_chat_photo_endpoint(chat_id: int):
|
883 |
+
await bot_instance.delete_chat_photo(chat_id)
|
884 |
+
return {"status": "Chat photo deleted successfully"}
|
885 |
+
|
886 |
+
@app.post("/set_chat_title")
|
887 |
+
async def set_chat_title_endpoint(chat_id: int, title: str):
|
888 |
+
await bot_instance.set_chat_title(chat_id, title)
|
889 |
+
return {"status": "Chat title set successfully"}
|
890 |
+
|
891 |
+
@app.post("/set_chat_description")
|
892 |
+
async def set_chat_description_endpoint(chat_id: int, description: str):
|
893 |
+
await bot_instance.set_chat_description(chat_id, description)
|
894 |
+
return {"status": "Chat description set successfully"}
|
895 |
+
|
896 |
+
@app.post("/pin_chat_message")
|
897 |
+
async def pin_chat_message_endpoint(chat_id: int, message_id: int, disable_notification: bool = False):
|
898 |
+
await bot_instance.pin_chat_message(chat_id, message_id, disable_notification=disable_notification)
|
899 |
+
return {"status": "Message pinned successfully"}
|
900 |
+
|
901 |
+
@app.post("/unpin_chat_message")
|
902 |
+
async def unpin_chat_message_endpoint(chat_id: int, message_id: int):
|
903 |
+
await bot_instance.unpin_chat_message(chat_id, message_id)
|
904 |
+
return {"status": "Message unpinned successfully"}
|
905 |
+
|
906 |
+
@app.post("/unpin_all_chat_messages")
|
907 |
+
async def unpin_all_chat_messages_endpoint(chat_id: int):
|
908 |
+
await bot_instance.unpin_all_chat_messages(chat_id)
|
909 |
+
return {"status": "All messages unpinned successfully"}
|
910 |
+
|
911 |
+
@app.post("/restrict_chat_member")
|
912 |
+
async def restrict_chat_member_endpoint(chat_id: int, user_id: int, permissions: dict, until_date: int = None):
|
913 |
+
chat_permissions = enums.ChatPermissions(**permissions)
|
914 |
+
await bot_instance.restrict_chat_member(chat_id, user_id, chat_permissions, until_date=until_date)
|
915 |
+
return {"status": "Chat member restricted successfully"}
|
916 |
+
|
917 |
+
@app.post("/promote_chat_member")
|
918 |
+
async def promote_chat_member_endpoint(chat_id: int, user_id: int, can_change_info: bool = False, can_post_messages: bool = False, can_edit_messages: bool = False, can_delete_messages: bool = False, can_manage_video_chats: bool = False, can_restrict_members: bool = False, can_promote_members: bool = False, can_invite_users: bool = False, can_pin_messages: bool = False, can_manage_chat: bool = False):
|
919 |
+
await bot_instance.promote_chat_member(
|
920 |
+
chat_id,
|
921 |
+
user_id,
|
922 |
+
can_change_info=can_change_info,
|
923 |
+
can_post_messages=can_post_messages,
|
924 |
+
can_edit_messages=can_edit_messages,
|
925 |
+
can_delete_messages=can_delete_messages,
|
926 |
+
can_manage_video_chats=can_manage_video_chats,
|
927 |
+
can_restrict_members=can_restrict_members,
|
928 |
+
can_promote_members=can_promote_members,
|
929 |
+
can_invite_users=can_invite_users,
|
930 |
+
can_pin_messages=can_pin_messages,
|
931 |
+
can_manage_chat=can_manage_chat
|
932 |
+
)
|
933 |
+
return {"status": "Chat member promoted successfully"}
|
934 |
+
|
935 |
+
@app.post("/kick_chat_member")
|
936 |
+
async def kick_chat_member_endpoint(chat_id: int, user_id: int):
|
937 |
+
await bot_instance.kick_chat_member(chat_id, user_id)
|
938 |
+
return {"status": "Chat member kicked successfully"}
|
939 |
+
|
940 |
+
@app.post("/unban_chat_member")
|
941 |
+
async def unban_chat_member_endpoint(chat_id: int, user_id: int):
|
942 |
+
await bot_instance.unban_chat_member(chat_id, user_id)
|
943 |
+
return {"status": "Chat member unbanned successfully"}
|
944 |
+
|
945 |
+
@app.post("/set_chat_administrator_custom_title")
|
946 |
+
async def set_chat_administrator_custom_title_endpoint(chat_id: int, user_id: int, custom_title: str):
|
947 |
+
await bot_instance.set_chat_administrator_custom_title(chat_id, user_id, custom_title)
|
948 |
+
return {"status": "Custom title set successfully"}
|
949 |
+
|
950 |
+
@app.post("/set_chat_permissions")
|
951 |
+
async def set_chat_permissions_endpoint(chat_id: int, permissions: dict):
|
952 |
+
chat_permissions = enums.ChatPermissions(**permissions)
|
953 |
+
await bot_instance.set_chat_permissions(chat_id, chat_permissions)
|
954 |
+
return {"status": "Chat permissions set successfully"}
|
955 |
+
|
956 |
+
@app.post("/set_chat_sticker_set")
|
957 |
+
async def set_chat_sticker_set_endpoint(chat_id: int, sticker_set_name: str):
|
958 |
+
await bot_instance.set_chat_sticker_set(chat_id, sticker_set_name)
|
959 |
+
return {"status": "Chat sticker set set successfully"}
|
960 |
+
|
961 |
+
@app.post("/delete_chat_sticker_set")
|
962 |
+
async def delete_chat_sticker_set_endpoint(chat_id: int):
|
963 |
+
await bot_instance.delete_chat_sticker_set(chat_id)
|
964 |
+
return {"status": "Chat sticker set deleted successfully"}
|
965 |
+
|
966 |
+
@app.post("/approve_chat_join_request")
|
967 |
+
async def approve_chat_join_request_endpoint(chat_id: int, user_id: int):
|
968 |
+
await bot_instance.approve_chat_join_request(chat_id, user_id)
|
969 |
+
return {"status": "Join request approved successfully"}
|
970 |
+
|
971 |
+
@app.post("/decline_chat_join_request")
|
972 |
+
async def decline_chat_join_request_endpoint(chat_id: int, user_id: int):
|
973 |
+
await bot_instance.decline_chat_join_request(chat_id, user_id)
|
974 |
+
return {"status": "Join request declined successfully"}
|
975 |
+
|
976 |
+
@app.post("/ban_chat_sender_chat")
|
977 |
+
async def ban_chat_sender_chat_endpoint(chat_id: int, sender_chat_id: int):
|
978 |
+
await bot_instance.ban_chat_sender_chat(chat_id, sender_chat_id)
|
979 |
+
return {"status": "Sender chat banned successfully"}
|
980 |
+
|
981 |
+
@app.post("/unban_chat_sender_chat")
|
982 |
+
async def unban_chat_sender_chat_endpoint(chat_id: int, sender_chat_id: int):
|
983 |
+
await bot_instance.unban_chat_sender_chat(chat_id, sender_chat_id)
|
984 |
+
return {"status": "Sender chat unbanned successfully"}
|
985 |
+
|
986 |
+
@app.post("/set_chat_menu_button")
|
987 |
+
async def set_chat_menu_button_endpoint(chat_id: int, menu_button: dict = None):
|
988 |
+
if menu_button:
|
989 |
+
menu_button_obj = types.MenuButton(**menu_button)
|
990 |
+
else:
|
991 |
+
menu_button_obj = None
|
992 |
+
await bot_instance.set_chat_menu_button(chat_id, menu_button_obj)
|
993 |
+
return {"status": "Chat menu button set successfully"}
|
994 |
+
|
995 |
+
@app.post("/get_chat_menu_button")
|
996 |
+
async def get_chat_menu_button_endpoint(chat_id: int):
|
997 |
+
menu_button = await bot_instance.get_chat_menu_button(chat_id)
|
998 |
+
return {"menu_button": menu_button}
|
999 |
+
|
1000 |
+
@app.post("/set_my_commands")
|
1001 |
+
async def set_my_commands_endpoint(commands: list):
|
1002 |
+
bot_commands = [types.BotCommand(command=cmd["command"], description=cmd["description"]) for cmd in commands]
|
1003 |
+
await bot_instance.set_my_commands(bot_commands)
|
1004 |
+
return {"status": "Commands set successfully"}
|
1005 |
+
|
1006 |
+
@app.post("/get_my_commands")
|
1007 |
+
async def get_my_commands_endpoint():
|
1008 |
+
commands = await bot_instance.get_my_commands()
|
1009 |
+
return {"commands": [cmd.dict() for cmd in commands]}
|
1010 |
+
|
1011 |
+
@app.post("/answer_callback_query")
|
1012 |
+
async def answer_callback_query_endpoint(callback_query_id: str, text: str = None, show_alert: bool = False, url: str = None, cache_time: int = 0):
|
1013 |
+
await bot_instance.answer_callback_query(callback_query_id, text=text, show_alert=show_alert, url=url, cache_time=cache_time)
|
1014 |
+
return {"status": "Callback query answered successfully"}
|
1015 |
+
|
1016 |
+
@app.post("/send_copy")
|
1017 |
+
async def send_copy_endpoint(chat_id: int, from_chat_id: int, message_id: int, caption: str = None, parse_mode: str = None, caption_entities: list = None, reply_to_message_id: int = None, allow_sending_without_reply: bool = False, reply_markup: dict = None):
|
1018 |
+
reply_markup_obj = InlineKeyboardMarkup(**reply_markup) if reply_markup else None
|
1019 |
+
message = await bot_instance.copy_message(
|
1020 |
+
chat_id,
|
1021 |
+
from_chat_id,
|
1022 |
+
message_id,
|
1023 |
+
caption=caption,
|
1024 |
+
parse_mode=parse_mode,
|
1025 |
+
caption_entities=caption_entities,
|
1026 |
+
reply_to_message_id=reply_to_message_id,
|
1027 |
+
allow_sending_without_reply=allow_sending_without_reply,
|
1028 |
+
reply_markup=reply_markup_obj
|
1029 |
+
)
|
1030 |
+
return {"message_id": message.id}
|
1031 |
+
|
1032 |
+
@app.post("/forward_messages")
|
1033 |
+
async def forward_messages_endpoint(chat_id: int, from_chat_id: int, message_ids: list, disable_notification: bool = False):
|
1034 |
+
messages = await bot_instance.forward_messages(
|
1035 |
+
chat_id,
|
1036 |
+
from_chat_id,
|
1037 |
+
message_ids,
|
1038 |
+
disable_notification=disable_notification
|
1039 |
+
)
|
1040 |
+
return {"messages": [msg.id for msg in messages]}
|
1041 |
+
|
1042 |
+
@app.post("/send_sticker")
|
1043 |
+
async def send_sticker_endpoint(chat_id: int, sticker_url: str, reply_to_message_id: int = None, reply_markup: dict = None):
|
1044 |
+
response = requests.get(sticker_url)
|
1045 |
+
sticker = BytesIO(response.content)
|
1046 |
+
sticker.name = "sticker.webp"
|
1047 |
+
reply_markup_obj = InlineKeyboardMarkup(**reply_markup) if reply_markup else None
|
1048 |
+
message = await bot_instance.send_sticker(
|
1049 |
+
chat_id,
|
1050 |
+
sticker,
|
1051 |
+
reply_to_message_id=reply_to_message_id,
|
1052 |
+
reply_markup=reply_markup_obj
|
1053 |
+
)
|
1054 |
+
return {"message_id": message.id}
|
1055 |
+
|
1056 |
+
@app.post("/send_animation")
|
1057 |
+
async def send_animation_endpoint(chat_id: int, animation_url: str, reply_to_message_id: int = None, reply_markup: dict = None):
|
1058 |
+
response = requests.get(animation_url)
|
1059 |
+
animation = BytesIO(response.content)
|
1060 |
+
animation.name = "animation.gif"
|
1061 |
+
reply_markup_obj = InlineKeyboardMarkup(**reply_markup) if reply_markup else None
|
1062 |
+
message = await bot_instance.send_animation(
|
1063 |
+
chat_id,
|
1064 |
+
animation,
|
1065 |
+
reply_to_message_id=reply_to_message_id,
|
1066 |
+
reply_markup=reply_markup_obj
|
1067 |
+
)
|
1068 |
+
return {"message_id": message.id}
|
1069 |
+
|
1070 |
+
@app.post("/send_video_note")
|
1071 |
+
async def send_video_note_endpoint(chat_id: int, video_note_url: str, reply_to_message_id: int = None, reply_markup: dict = None):
|
1072 |
+
response = requests.get(video_note_url)
|
1073 |
+
video_note = BytesIO(response.content)
|
1074 |
+
video_note.name = "video_note.mp4"
|
1075 |
+
reply_markup_obj = InlineKeyboardMarkup(**reply_markup) if reply_markup else None
|
1076 |
+
message = await bot_instance.send_video_note(
|
1077 |
+
chat_id,
|
1078 |
+
video_note,
|
1079 |
+
reply_to_message_id=reply_to_message_id,
|
1080 |
+
reply_markup=reply_markup_obj
|
1081 |
+
)
|
1082 |
+
return {"message_id": message.id}
|
1083 |
+
|
1084 |
+
@app.post("/send_voice")
|
1085 |
+
async def send_voice_endpoint(chat_id: int, voice_url: str, reply_to_message_id: int = None, reply_markup: dict = None):
|
1086 |
+
response = requests.get(voice_url)
|
1087 |
+
voice = BytesIO(response.content)
|
1088 |
+
voice.name = "voice.ogg"
|
1089 |
+
reply_markup_obj = InlineKeyboardMarkup(**reply_markup) if reply_markup else None
|
1090 |
+
message = await bot_instance.send_voice(
|
1091 |
+
chat_id,
|
1092 |
+
voice,
|
1093 |
+
reply_to_message_id=reply_to_message_id,
|
1094 |
+
reply_markup=reply_markup_obj
|
1095 |
+
)
|
1096 |
+
return {"message_id": message.id}
|
1097 |
+
|
1098 |
+
@app.post("/send_video")
|
1099 |
+
async def send_video_endpoint(chat_id: int, video_url: str, reply_to_message_id: int = None, reply_markup: dict = None):
|
1100 |
+
response = requests.get(video_url)
|
1101 |
+
video = BytesIO(response.content)
|
1102 |
+
video.name = "video.mp4"
|
1103 |
+
reply_markup_obj = InlineKeyboardMarkup(**reply_markup) if reply_markup else None
|
1104 |
+
message = await bot_instance.send_video(
|
1105 |
+
chat_id,
|
1106 |
+
video,
|
1107 |
+
reply_to_message_id=reply_to_message_id,
|
1108 |
+
reply_markup=reply_markup_obj
|
1109 |
+
)
|
1110 |
+
return {"message_id": message.id}
|
1111 |
+
|
1112 |
+
@app.post("/send_document")
|
1113 |
+
async def send_document_endpoint(chat_id: int, document_url: str, reply_to_message_id: int = None, reply_markup: dict = None):
|
1114 |
+
response = requests.get(document_url)
|
1115 |
+
document = BytesIO(response.content)
|
1116 |
+
document.name = "document.pdf"
|
1117 |
+
reply_markup_obj = InlineKeyboardMarkup(**reply_markup) if reply_markup else None
|
1118 |
+
message = await bot_instance.send_document(
|
1119 |
+
chat_id,
|
1120 |
+
document,
|
1121 |
+
reply_to_message_id=reply_to_message_id,
|
1122 |
+
reply_markup=reply_markup_obj
|
1123 |
+
)
|
1124 |
+
return {"message_id": message.id}
|
1125 |
+
|
1126 |
+
@app.post("/send_photo")
|
1127 |
+
async def send_photo_endpoint(chat_id: int, photo_url: str, reply_to_message_id: int = None, reply_markup: dict = None):
|
1128 |
+
response = requests.get(photo_url)
|
1129 |
+
photo = BytesIO(response.content)
|
1130 |
+
photo.name = "photo.jpg"
|
1131 |
+
reply_markup_obj = InlineKeyboardMarkup(**reply_markup) if reply_markup else None
|
1132 |
+
message = await bot_instance.send_photo(
|
1133 |
+
chat_id,
|
1134 |
+
photo,
|
1135 |
+
reply_to_message_id=reply_to_message_id,
|
1136 |
+
reply_markup=reply_markup_obj
|
1137 |
+
)
|
1138 |
+
return {"message_id": message.id}
|
1139 |
+
|
1140 |
+
@app.post("/send_audio")
|
1141 |
+
async def send_audio_endpoint(chat_id: int, audio_url: str, reply_to_message_id: int = None, reply_markup: dict = None):
|
1142 |
+
response = requests.get(audio_url)
|
1143 |
+
audio = BytesIO(response.content)
|
1144 |
+
audio.name = "audio.mp3"
|
1145 |
+
reply_markup_obj = InlineKeyboardMarkup(**reply_markup) if reply_markup else None
|
1146 |
+
message = await bot_instance.send_audio(
|
1147 |
+
chat_id,
|
1148 |
+
audio,
|
1149 |
+
reply_to_message_id=reply_to_message_id,
|
1150 |
+
reply_markup=reply_markup_obj
|
1151 |
+
)
|
1152 |
+
return {"message_id": message.id}
|
1153 |
+
|
1154 |
+
@app.post("/send_location")
|
1155 |
+
async def send_location_endpoint(chat_id: int, latitude: float, longitude: float, reply_to_message_id: int = None, reply_markup: dict = None):
|
1156 |
+
reply_markup_obj = InlineKeyboardMarkup(**reply_markup) if reply_markup else None
|
1157 |
+
message = await bot_instance.send_location(
|
1158 |
+
chat_id,
|
1159 |
+
latitude,
|
1160 |
+
longitude,
|
1161 |
+
reply_to_message_id=reply_to_message_id,
|
1162 |
+
reply_markup=reply_markup_obj
|
1163 |
+
)
|
1164 |
+
return {"message_id": message.id}
|
1165 |
+
|
1166 |
+
@app.post("/send_contact")
|
1167 |
+
async def send_contact_endpoint(chat_id: int, phone_number: str, first_name: str, last_name: str = None, reply_to_message_id: int = None, reply_markup: dict = None):
|
1168 |
+
reply_markup_obj = InlineKeyboardMarkup(**reply_markup) if reply_markup else None
|
1169 |
+
message = await bot_instance.send_contact(
|
1170 |
+
chat_id,
|
1171 |
+
phone_number,
|
1172 |
+
first_name,
|
1173 |
+
last_name=last_name,
|
1174 |
+
reply_to_message_id=reply_to_message_id,
|
1175 |
+
reply_markup=reply_markup_obj
|
1176 |
+
)
|
1177 |
+
return {"message_id": message.id}
|
1178 |
+
|
1179 |
+
@app.post("/send_dice")
|
1180 |
+
async def send_dice_endpoint(chat_id: int, reply_to_message_id: int = None, reply_markup: dict = None):
|
1181 |
+
reply_markup_obj = InlineKeyboardMarkup(**reply_markup) if reply_markup else None
|
1182 |
+
message = await bot_instance.send_dice(
|
1183 |
+
chat_id,
|
1184 |
+
reply_to_message_id=reply_to_message_id,
|
1185 |
+
reply_markup=reply_markup_obj
|
1186 |
+
)
|
1187 |
+
return {"message_id": message.id}
|
1188 |
+
|
1189 |
+
@app.post("/send_game")
|
1190 |
+
async def send_game_endpoint(chat_id: int, game_short_name: str, reply_to_message_id: int = None, reply_markup: dict = None):
|
1191 |
+
reply_markup_obj = InlineKeyboardMarkup(**reply_markup) if reply_markup else None
|
1192 |
+
message = await bot_instance.send_game(
|
1193 |
+
chat_id,
|
1194 |
+
game_short_name,
|
1195 |
+
reply_to_message_id=reply_to_message_id,
|
1196 |
+
reply_markup=reply_markup_obj
|
1197 |
+
)
|
1198 |
+
return {"message_id": message.id}
|
1199 |
+
|
1200 |
+
@app.post("/send_media_group")
|
1201 |
+
async def send_media_group_endpoint(chat_id: int, media: list, reply_to_message_id: int = None, reply_markup: dict = None):
|
1202 |
+
media_group = [types.InputMediaPhoto(media=media_item["media"]) if media_item["type"] == "photo" else types.InputMediaVideo(media=media_item["media"]) for media_item in media]
|
1203 |
+
reply_markup_obj = InlineKeyboardMarkup(**reply_markup) if reply_markup else None
|
1204 |
+
messages = await bot_instance.send_media_group(
|
1205 |
+
chat_id,
|
1206 |
+
media_group,
|
1207 |
+
reply_to_message_id=reply_to_message_id,
|
1208 |
+
reply_markup=reply_markup_obj
|
1209 |
+
)
|
1210 |
+
return {"messages": [msg.id for msg in messages]}
|
1211 |
+
|
1212 |
+
@app.post("/send_chat_action")
|
1213 |
+
async def send_chat_action_endpoint(chat_id: int, action: str):
|
1214 |
+
actions = {
|
1215 |
+
"typing": enums.ChatAction.TYPING,
|
1216 |
+
"upload_photo": enums.ChatAction.UPLOAD_PHOTO,
|
1217 |
+
"record_video": enums.ChatAction.RECORD_VIDEO,
|
1218 |
+
"upload_video": enums.ChatAction.UPLOAD_VIDEO,
|
1219 |
+
"record_voice": enums.ChatAction.RECORD_VOICE,
|
1220 |
+
"upload_voice": enums.ChatAction.UPLOAD_VOICE,
|
1221 |
+
"upload_document": enums.ChatAction.UPLOAD_DOCUMENT,
|
1222 |
+
"find_location": enums.ChatAction.FIND_LOCATION,
|
1223 |
+
"record_video_note": enums.ChatAction.RECORD_VIDEO_NOTE,
|
1224 |
+
"upload_video_note": enums.ChatAction.UPLOAD_VIDEO_NOTE,
|
1225 |
+
"playing": enums.ChatAction.PLAYING
|
1226 |
+
}
|
1227 |
+
action_enum = actions.get(action)
|
1228 |
+
if not action_enum:
|
1229 |
+
return {"error": "Invalid action"}
|
1230 |
+
await bot_instance.send_chat_action(chat_id, action_enum)
|
1231 |
+
return {"status": "Chat action sent successfully"}
|
1232 |
+
|
1233 |
+
@app.post("/send_invoice")
|
1234 |
+
async def send_invoice_endpoint(chat_id: int, title: str, description: str, payload: str, provider_token: str, currency: str, prices: list, start_parameter: str = None, provider_data: str = None, photo_url: str = None, photo_size: int = None, photo_width: int = None, photo_height: int = None, need_name: bool = False, need_phone_number: bool = False, need_email: bool = False, need_shipping_address: bool = False, send_phone_number_to_provider: bool = False, send_email_to_provider: bool = False, is_flexible: bool = False, disable_notification: bool = False, protect_content: bool = False, reply_to_message_id: int = None, allow_sending_without_reply: bool = False, reply_markup: dict = None):
|
1235 |
+
prices_obj = [types.LabeledPrice(label=price["label"], amount=price["amount"]) for price in prices]
|
1236 |
+
reply_markup_obj = InlineKeyboardMarkup(**reply_markup) if reply_markup else None
|
1237 |
+
message = await bot_instance.send_invoice(
|
1238 |
+
chat_id,
|
1239 |
+
title,
|
1240 |
+
description,
|
1241 |
+
payload,
|
1242 |
+
provider_token,
|
1243 |
+
currency,
|
1244 |
+
prices_obj,
|
1245 |
+
start_parameter=start_parameter,
|
1246 |
+
provider_data=provider_data,
|
1247 |
+
photo_url=photo_url,
|
1248 |
+
photo_size=photo_size,
|
1249 |
+
photo_width=photo_width,
|
1250 |
+
photo_height=photo_height,
|
1251 |
+
need_name=need_name,
|
1252 |
+
need_phone_number=need_phone_number,
|
1253 |
+
need_email=need_email,
|
1254 |
+
need_shipping_address=need_shipping_address,
|
1255 |
+
send_phone_number_to_provider=send_phone_number_to_provider,
|
1256 |
+
send_email_to_provider=send_email_to_provider,
|
1257 |
+
is_flexible=is_flexible,
|
1258 |
+
disable_notification=disable_notification,
|
1259 |
+
protect_content=protect_content,
|
1260 |
+
reply_to_message_id=reply_to_message_id,
|
1261 |
+
allow_sending_without_reply=allow_sending_without_reply,
|
1262 |
+
reply_markup=reply_markup_obj
|
1263 |
+
)
|
1264 |
+
return {"message_id": message.id}
|
1265 |
+
|
1266 |
+
@app.post("/send_game")
|
1267 |
+
async def send_game_endpoint(chat_id: int, game_short_name: str, reply_to_message_id: int = None, reply_markup: dict = None):
|
1268 |
+
reply_markup_obj = InlineKeyboardMarkup(**reply_markup) if reply_markup else None
|
1269 |
+
message = await bot_instance.send_game(
|
1270 |
+
chat_id,
|
1271 |
+
game_short_name,
|
1272 |
+
reply_to_message_id=reply_to_message_id,
|
1273 |
+
reply_markup=reply_markup_obj
|
1274 |
+
)
|
1275 |
+
return {"message_id": message.id}
|
1276 |
+
|
1277 |
+
@app.post("/send_poll")
|
1278 |
+
async def send_poll_endpoint(chat_id: int, question: str, options: list, is_anonymous: bool = False, type: str = "regular", allows_multiple_answers: bool = False, correct_option_id: int = None, explanation: str = None, explanation_parse_mode: str = None, open_period: int = None, close_date: int = None, is_closed: bool = False):
|
1279 |
+
message = await bot_instance.send_poll(
|
1280 |
+
chat_id,
|
1281 |
+
question,
|
1282 |
+
options,
|
1283 |
+
is_anonymous=is_anonymous,
|
1284 |
+
type=type,
|
1285 |
+
allows_multiple_answers=allows_multiple_answers,
|
1286 |
+
correct_option_id=correct_option_id,
|
1287 |
+
explanation=explanation,
|
1288 |
+
explanation_parse_mode=explanation_parse_mode,
|
1289 |
+
open_period=open_period,
|
1290 |
+
close_date=close_date,
|
1291 |
+
is_closed=is_closed
|
1292 |
+
)
|
1293 |
+
return {"message_id": message.id}
|
1294 |
+
|
1295 |
+
@app.post("/send_dice")
|
1296 |
+
async def send_dice_endpoint(chat_id: int, reply_to_message_id: int = None, reply_markup: dict = None):
|
1297 |
+
reply_markup_obj = InlineKeyboardMarkup(**reply_markup) if reply_markup else None
|
1298 |
+
message = await bot_instance.send_dice(
|
1299 |
+
chat_id,
|
1300 |
+
reply_to_message_id=reply_to_message_id,
|
1301 |
+
reply_markup=reply_markup_obj
|
1302 |
+
)
|
1303 |
+
return {"message_id": message.id}
|
1304 |
+
|
1305 |
+
@app.post("/send_chat_action")
|
1306 |
+
async def send_chat_action_endpoint(chat_id: int, action: str):
|
1307 |
+
actions = {
|
1308 |
+
"typing": enums.ChatAction.TYPING,
|
1309 |
+
"upload_photo": enums.ChatAction.UPLOAD_PHOTO,
|
1310 |
+
"record_video": enums.ChatAction.RECORD_VIDEO,
|
1311 |
+
"upload_video": enums.ChatAction.UPLOAD_VIDEO,
|
1312 |
+
"record_voice": enums.ChatAction.RECORD_VOICE,
|
1313 |
+
"upload_voice": enums.ChatAction.UPLOAD_VOICE,
|
1314 |
+
"upload_document": enums.ChatAction.UPLOAD_DOCUMENT,
|
1315 |
+
"find_location": enums.ChatAction.FIND_LOCATION,
|
1316 |
+
"record_video_note": enums.ChatAction.RECORD_VIDEO_NOTE,
|
1317 |
+
"upload_video_note": enums.ChatAction.UPLOAD_VIDEO_NOTE,
|
1318 |
+
"playing": enums.ChatAction.PLAYING
|
1319 |
+
}
|
1320 |
+
action_enum = actions.get(action)
|
1321 |
+
if not action_enum:
|
1322 |
+
return {"error": "Invalid action"}
|
1323 |
+
await bot_instance.send_chat_action(chat_id, action_enum)
|
1324 |
+
return {"status": "Chat action sent successfully"}
|
1325 |
+
|
1326 |
+
@app.post("/send_poll")
|
1327 |
+
async def send_poll_endpoint(chat_id: int, question: str, options: list, is_anonymous: bool = False, type: str = "regular", allows_multiple_answers: bool = False, correct_option_id: int = None, explanation: str = None, explanation_parse_mode: str = None, open_period: int = None, close_date: int = None, is_closed: bool = False):
|
1328 |
+
message = await bot_instance.send_poll(
|
1329 |
+
chat_id,
|
1330 |
+
question,
|
1331 |
+
options,
|
1332 |
+
is_anonymous=is_anonymous,
|
1333 |
+
type=type,
|
1334 |
+
allows_multiple_answers=allows_multiple_answers,
|
1335 |
+
correct_option_id=correct_option_id,
|
1336 |
+
explanation=explanation,
|
1337 |
+
explanation_parse_mode=explanation_parse_mode,
|
1338 |
+
open_period=open_period,
|
1339 |
+
close_date=close_date,
|
1340 |
+
is_closed=is_closed
|
1341 |
+
)
|
1342 |
+
return {"message_id": message.id}
|
1343 |
+
|
1344 |
+
@app.post("/send_chat_action")
|
1345 |
+
async def send_chat_action_endpoint(chat_id: int, action: str):
|
1346 |
+
actions = {
|
1347 |
+
"typing": enums.ChatAction.TYPING,
|
1348 |
+
"upload_photo": enums.ChatAction.UPLOAD_PHOTO,
|
1349 |
+
"record_video": enums.ChatAction.RECORD_VIDEO,
|
1350 |
+
"upload_video": enums.ChatAction.UPLOAD_VIDEO,
|
1351 |
+
"record_voice": enums.ChatAction.RECORD_VOICE,
|
1352 |
+
"upload_voice": enums.ChatAction.UPLOAD_VOICE,
|
1353 |
+
"upload_document": enums.ChatAction.UPLOAD_DOCUMENT,
|
1354 |
+
"find_location": enums.ChatAction.FIND_LOCATION,
|
1355 |
+
"record_video_note": enums.ChatAction.RECORD_VIDEO_NOTE,
|
1356 |
+
"upload_video_note": enums.ChatAction.UPLOAD_VIDEO_NOTE,
|
1357 |
+
"playing": enums.ChatAction.PLAYING
|
1358 |
+
}
|
1359 |
+
action_enum = actions.get(action)
|
1360 |
+
if not action_enum:
|
1361 |
+
return {"error": "Invalid action"}
|
1362 |
+
await bot_instance.send_chat_action(chat_id, action_enum)
|
1363 |
+
return {"status": "Chat action sent successfully"}
|
1364 |
+
|
1365 |
+
@app.post("/send_chat_action")
|
1366 |
+
async def send_chat_action_endpoint(chat_id: int, action: str):
|
1367 |
+
actions = {
|
1368 |
+
"typing": enums.ChatAction.TYPING,
|
1369 |
+
"upload_photo": enums.ChatAction.UPLOAD_PHOTO,
|
1370 |
+
"record_video": enums.ChatAction.RECORD_VIDEO,
|
1371 |
+
"upload_video": enums.ChatAction.UPLOAD_VIDEO,
|
1372 |
+
"record_voice": enums.ChatAction.RECORD_VOICE,
|
1373 |
+
"upload_voice": enums.ChatAction.UPLOAD_VOICE,
|
1374 |
+
"upload_document": enums.ChatAction.UPLOAD_DOCUMENT,
|
1375 |
+
"find_location": enums.ChatAction.FIND_LOCATION,
|
1376 |
+
"record_video_note": enums.ChatAction.RECORD_VIDEO_NOTE,
|
1377 |
+
"upload_video_note": enums.ChatAction.UPLOAD_VIDEO_NOTE,
|
1378 |
+
"playing": enums.ChatAction.PLAYING
|
1379 |
+
}
|
1380 |
+
action_enum = actions.get(action)
|
1381 |
+
if not action_enum:
|
1382 |
+
return {"error": "Invalid action"}
|
1383 |
+
await bot_instance.send_chat_action(chat_id, action_enum)
|
1384 |
+
return {"status": "Chat action sent successfully"}
|
1385 |
+
|
1386 |
+
@app.post("/send_chat_action")
|
1387 |
+
async def send_chat_action_endpoint(chat_id: int, action: str):
|
1388 |
+
actions = {
|
1389 |
+
"typing": enums.ChatAction.TYPING,
|
1390 |
+
"upload_photo": enums.ChatAction.UPLOAD_PHOTO,
|
1391 |
+
"record_video": enums.ChatAction.RECORD_VIDEO,
|
1392 |
+
"upload_video": enums.ChatAction.UPLOAD_VIDEO,
|
1393 |
+
"record_voice": enums.ChatAction.RECORD_VOICE,
|
1394 |
+
"upload_voice": enums.ChatAction.UPLOAD_VOICE,
|
1395 |
+
"upload_document": enums.ChatAction.UPLOAD_DOCUMENT,
|
1396 |
+
"find_location": enums.ChatAction.FIND_LOCATION,
|
1397 |
+
"record_video_note": enums.ChatAction.RECORD_VIDEO_NOTE,
|
1398 |
+
"upload_video_note": enums.ChatAction.UPLOAD_VIDEO_NOTE,
|
1399 |
+
"playing": enums.ChatAction.PLAYING
|
1400 |
+
}
|
1401 |
+
action_enum = actions.get(action)
|
1402 |
+
if not action_enum:
|
1403 |
+
return {"error": "Invalid action"}
|
1404 |
+
await bot_instance.send_chat_action(chat_id, action_enum)
|
1405 |
+
return {"status": "Chat action sent successfully"}
|
1406 |
+
|
1407 |
+
@app.post("/send_chat_action")
|
1408 |
+
async def send_chat_action_endpoint(chat_id: int, action: str):
|
1409 |
+
actions = {
|
1410 |
+
"typing": enums.ChatAction.TYPING,
|
1411 |
+
"upload_photo": enums.ChatAction.UPLOAD_PHOTO,
|
1412 |
+
"record_video": enums.ChatAction.RECORD_VIDEO,
|
1413 |
+
"upload_video": enums.ChatAction.UPLOAD_VIDEO,
|
1414 |
+
"record_voice": enums.ChatAction.RECORD_VOICE,
|
1415 |
+
"upload_voice": enums.ChatAction.UPLOAD_VOICE,
|
1416 |
+
"upload_document": enums.ChatAction.UPLOAD_DOCUMENT,
|
1417 |
+
"find_location": enums.ChatAction.FIND_LOCATION,
|
1418 |
+
"record_video_note": enums.ChatAction.RECORD_VIDEO_NOTE,
|
1419 |
+
"upload_video_note": enums.ChatAction.UPLOAD_VIDEO_NOTE,
|
1420 |
+
"playing": enums.ChatAction.PLAYING
|
1421 |
+
}
|
1422 |
+
action_enum = actions.get(action)
|
1423 |
+
if not action_enum:
|
1424 |
+
return {"error": "Invalid action"}
|
1425 |
+
await bot_instance.send_chat_action(chat_id, action_enum)
|
1426 |
+
return {"status": "Chat action sent successfully"}
|
1427 |
+
|
1428 |
+
@app.post("/send_chat_action")
|
1429 |
+
async def send_chat_action_endpoint(chat_id: int, action: str):
|
1430 |
+
actions = {
|
1431 |
+
"typing": enums.ChatAction.TYPING,
|
1432 |
+
"upload_photo": enums.ChatAction.UPLOAD_PHOTO,
|
1433 |
+
"record_video": enums.ChatAction.RECORD_VIDEO,
|
1434 |
+
"upload_video": enums.ChatAction.UPLOAD_VIDEO,
|
1435 |
+
"record_voice": enums.ChatAction.RECORD_VOICE,
|
1436 |
+
"upload_voice": enums.ChatAction.UPLOAD_VOICE,
|
1437 |
+
"upload_document": enums.ChatAction.UPLOAD_DOCUMENT,
|
1438 |
+
"find_location": enums.ChatAction.FIND_LOCATION,
|
1439 |
+
"record_video_note": enums.ChatAction.RECORD_VIDEO_NOTE,
|
1440 |
+
"upload_video_note": enums.ChatAction.UPLOAD_VIDEO_NOTE,
|
1441 |
+
"playing": enums.ChatAction.PLAYING
|
1442 |
+
}
|
1443 |
+
action_enum = actions.get(action)
|
1444 |
+
if not action_enum:
|
1445 |
+
return {"error": "Invalid action"}
|
1446 |
+
await bot_instance.send_chat_action(chat_id, action_enum)
|
1447 |
+
return {"status": "Chat action sent successfully"}
|
1448 |
+
|
1449 |
+
@app.post("/send_chat_action")
|
1450 |
+
async def send_chat_action_endpoint(chat_id: int, action: str):
|
1451 |
+
actions = {
|
1452 |
+
"typing": enums.ChatAction.TYPING,
|
1453 |
+
"upload_photo": enums.ChatAction.UPLOAD_PHOTO,
|
1454 |
+
"record_video": enums.ChatAction.RECORD_VIDEO,
|
1455 |
+
"upload_video": enums.ChatAction.UPLOAD_VIDEO,
|
1456 |
+
"record_voice": enums.ChatAction.RECORD_VOICE,
|
1457 |
+
"upload_voice": enums.ChatAction.UPLOAD_VOICE,
|
1458 |
+
"upload_document": enums.ChatAction.UPLOAD_DOCUMENT,
|
1459 |
+
"find_location": enums.ChatAction.FIND_LOCATION,
|
1460 |
+
"record_video_note": enums.ChatAction.RECORD_VIDEO_NOTE,
|
1461 |
+
"upload_video_note": enums.ChatAction.UPLOAD_VIDEO_NOTE,
|
1462 |
+
"playing": enums.ChatAction.PLAYING
|
1463 |
+
}
|
1464 |
+
action_enum = actions.get(action)
|
1465 |
+
if not action_enum:
|
1466 |
+
return {"error": "Invalid action"}
|
1467 |
+
await bot_instance.send_chat_action(chat_id, action_enum)
|
1468 |
+
return {"status": "Chat action sent successfully"}
|
1469 |
+
|
1470 |
+
@app.post("/send_chat_action")
|
1471 |
+
async def send_chat_action_endpoint(chat_id: int, action: str):
|
1472 |
+
actions = {
|
1473 |
+
"typing": enums.ChatAction.TYPING,
|
1474 |
+
"upload_photo": enums.ChatAction.UPLOAD_PHOTO,
|
1475 |
+
"record_video": enums.ChatAction.RECORD_VIDEO,
|
1476 |
+
"upload_video": enums.ChatAction.UPLOAD_VIDEO,
|
1477 |
+
"record_voice": enums.ChatAction.RECORD_VOICE,
|
1478 |
+
"upload_voice": enums.ChatAction.UPLOAD_VOICE,
|
1479 |
+
"upload_document": enums.ChatAction.UPLOAD_DOCUMENT,
|
1480 |
+
"find_location": enums.ChatAction.FIND_LOCATION,
|
1481 |
+
"record_video_note": enums.ChatAction.RECORD_VIDEO_NOTE,
|
1482 |
+
"upload_video_note": enums.ChatAction.UPLOAD_VIDEO_NOTE,
|
1483 |
+
"playing": enums.ChatAction.PLAYING
|
1484 |
+
}
|
1485 |
+
action_enum = actions.get(action)
|
1486 |
+
if not action_enum:
|
1487 |
+
return {"error": "Invalid action"}
|
1488 |
+
await bot_instance.send_chat_action(chat_id, action_enum)
|
1489 |
+
return {"status": "Chat action sent successfully"}
|
1490 |
+
|
1491 |
+
@app.post("/send_chat_action")
|
1492 |
+
async def send_chat_action_endpoint(chat_id: int, action: str):
|
1493 |
+
actions = {
|
1494 |
+
"typing": enums.ChatAction.TYPING,
|
1495 |
+
"upload_photo": enums.ChatAction.UPLOAD_PHOTO,
|
1496 |
+
"record_video": enums.ChatAction.RECORD_VIDEO,
|
1497 |
+
"upload_video": enums.ChatAction.UPLOAD_VIDEO,
|
1498 |
+
"record_voice": enums.ChatAction.RECORD_VOICE,
|
1499 |
+
"upload_voice": enums.ChatAction.UPLOAD_VOICE,
|
1500 |
+
"upload_document": enums.ChatAction.UPLOAD_DOCUMENT,
|
1501 |
+
"find_location": enums.ChatAction.FIND_LOCATION,
|
1502 |
+
"record_video_note": enums.ChatAction.RECORD_VIDEO_NOTE,
|
1503 |
+
"upload_video_note": enums.ChatAction.UPLOAD_VIDEO_NOTE,
|
1504 |
+
"playing": enums.ChatAction.PLAYING
|
1505 |
+
}
|
1506 |
+
action_enum = actions.get(action)
|
1507 |
+
if not action_enum:
|
1508 |
+
return {"error": "Invalid action"}
|
1509 |
+
await bot_instance.send_chat_action(chat_id, action_enum)
|
1510 |
+
return {"status": "Chat action sent successfully"}
|
1511 |
+
|
1512 |
+
@app.post("/send_chat_action")
|
1513 |
+
async def send_chat_action_endpoint(chat_id: int, action: str):
|
1514 |
+
actions = {
|
1515 |
+
"typing": enums.ChatAction.TYPING,
|
1516 |
+
"upload_photo": enums.ChatAction.UPLOAD_PHOTO,
|
1517 |
+
"record_video": enums.ChatAction.RECORD_VIDEO,
|
1518 |
+
"upload_video": enums.ChatAction.UPLOAD_VIDEO,
|
1519 |
+
"record_voice": enums.ChatAction.RECORD_VOICE,
|
1520 |
+
"upload_voice": enums.ChatAction.UPLOAD_VOICE,
|
1521 |
+
"upload_document": enums.ChatAction.UPLOAD_DOCUMENT,
|
1522 |
+
"find_location": enums.ChatAction.FIND_LOCATION,
|
1523 |
+
"record_video_note": enums.ChatAction.RECORD_VIDEO_NOTE,
|
1524 |
+
"upload_video_note": enums.ChatAction.UPLOAD_VIDEO_NOTE,
|
1525 |
+
"playing": enums.ChatAction.PLAYING
|
1526 |
+
}
|
1527 |
+
action_enum = actions.get(action)
|
1528 |
+
if not action_enum:
|
1529 |
+
return {"error": "Invalid action"}
|
1530 |
+
await bot_instance.send_chat_action(chat_id, action_enum)
|
1531 |
+
return {"status": "Chat action sent successfully"}
|
1532 |
+
|
1533 |
+
@app.post("/send_chat_action")
|
1534 |
+
async def send_chat_action_endpoint(chat_id: int, action: str):
|
1535 |
+
actions = {
|
1536 |
+
"typing": enums.ChatAction.TYPING,
|
1537 |
+
"upload_photo": enums.ChatAction.UPLOAD_PHOTO,
|
1538 |
+
"record_video": enums.ChatAction.RECORD_VIDEO,
|
1539 |
+
"upload_video": enums.ChatAction.UPLOAD_VIDEO,
|
1540 |
+
"record_voice": enums.ChatAction.RECORD_VOICE,
|
1541 |
+
"upload_voice": enums.ChatAction.UPLOAD_VOICE,
|
1542 |
+
"upload_document": enums.ChatAction.UPLOAD_DOCUMENT,
|
1543 |
+
"find_location": enums.ChatAction.FIND_LOCATION,
|
1544 |
+
"record_video_note": enums.ChatAction.RECORD_VIDEO_NOTE,
|
1545 |
+
"upload_video_note": enums.ChatAction.UPLOAD_VIDEO_NOTE,
|
1546 |
+
"playing": enums.ChatAction.PLAYING
|
1547 |
+
}
|
1548 |
+
action_enum = actions.get(action)
|
1549 |
+
if not action_enum:
|
1550 |
+
return {"error": "Invalid action"}
|
1551 |
+
await bot_instance.send_chat_action(chat_id, action_enum)
|
1552 |
+
return {"status": "Chat action sent successfully"}
|
1553 |
+
|
1554 |
+
@app.post("/send_chat_action")
|
1555 |
+
async def send_chat_action_endpoint(chat_id: int, action: str):
|
1556 |
+
actions = {
|
1557 |
+
"typing": enums.ChatAction.TYPING,
|
1558 |
+
"upload_photo": enums.ChatAction.UPLOAD_PHOTO,
|
1559 |
+
"record_video": enums.ChatAction.RECORD_VIDEO,
|
1560 |
+
"upload_video": enums.ChatAction.UPLOAD_VIDEO,
|
1561 |
+
"record_voice": enums.ChatAction.RECORD_VOICE,
|
1562 |
+
"upload_voice": enums.ChatAction.UPLOAD_VOICE,
|
1563 |
+
"upload_document": enums.ChatAction.UPLOAD_DOCUMENT,
|
1564 |
+
"find_location": enums.ChatAction.FIND_LOCATION,
|
1565 |
+
"record_video_note": enums.ChatAction.RECORD_VIDEO_NOTE,
|
1566 |
+
"upload_video_note": enums.ChatAction.UPLOAD_VIDEO_NOTE,
|
1567 |
+
"playing": enums.ChatAction.PLAYING
|
1568 |
+
}
|
1569 |
+
action_enum = actions.get(action)
|
1570 |
+
if not action_enum:
|
1571 |
+
return {"error": "Invalid action"}
|
1572 |
+
await bot_instance.send_chat_action(chat_id, action_enum)
|
1573 |
+
return {"status": "Chat action sent successfully"}
|
1574 |
+
|
1575 |
+
@app.post("/send_chat_action")
|
1576 |
+
async def send_chat_action_endpoint(chat_id: int, action: str):
|
1577 |
+
actions = {
|
1578 |
+
"typing": enums.ChatAction.TYPING,
|
1579 |
+
"upload_photo": enums.ChatAction.UPLOAD_PHOTO,
|
1580 |
+
"record_video": enums.ChatAction.RECORD_VIDEO,
|
1581 |
+
"upload_video": enums.ChatAction.UPLOAD_VIDEO,
|
1582 |
+
"record_voice": enums.ChatAction.RECORD_VOICE,
|
1583 |
+
"upload_voice": enums.ChatAction.UPLOAD_VOICE,
|
1584 |
+
"upload_document": enums.ChatAction.UPLOAD_DOCUMENT,
|
1585 |
+
"find_location": enums.ChatAction.FIND_LOCATION,
|
1586 |
+
"record_video_note": enums.ChatAction.RECORD_VIDEO_NOTE,
|
1587 |
+
"upload_video_note": enums.ChatAction.UPLOAD_VIDEO_NOTE,
|
1588 |
+
"playing": enums.ChatAction.PLAYING
|
1589 |
+
}
|
1590 |
+
action_enum = actions.get(action)
|
1591 |
+
if not action_enum:
|
1592 |
+
return {"error": "Invalid action"}
|
1593 |
+
await bot_instance.send_chat_action(chat_id, action_enum)
|
1594 |
+
return {"status": "Chat action sent successfully"}
|
1595 |
+
|
1596 |
+
@app.post("/send_chat_action")
|
1597 |
+
async def send_chat_action_endpoint(chat_id: int, action: str):
|
1598 |
+
actions = {
|
1599 |
+
"typing": enums.ChatAction.TYPING,
|
1600 |
+
"upload_photo": enums.ChatAction.UPLOAD_PHOTO,
|
1601 |
+
"record_video": enums.ChatAction.RECORD_VIDEO,
|
1602 |
+
"upload_video": enums.ChatAction.UPLOAD_VIDEO,
|
1603 |
+
"record_voice": enums.ChatAction.RECORD_VOICE,
|
1604 |
+
"upload_voice": enums.ChatAction.UPLOAD_VOICE,
|
1605 |
+
"upload_document": enums.ChatAction.UPLOAD_DOCUMENT,
|
1606 |
+
"find_location": enums.ChatAction.FIND_LOCATION,
|
1607 |
+
"record_video_note": enums.ChatAction.RECORD_VIDEO_NOTE,
|
1608 |
+
"upload_video_note": enums.ChatAction.UPLOAD_VIDEO_NOTE,
|
1609 |
+
"playing": enums.ChatAction.PLAYING
|
1610 |
+
}
|
1611 |
+
action_enum = actions.get(action)
|
1612 |
+
if not action_enum:
|
1613 |
+
return {"error": "Invalid action"}
|
1614 |
+
await bot_instance.send_chat_action(chat_id, action_enum)
|
1615 |
+
return {"status": "Chat action sent successfully"}
|
1616 |
+
|