@@ -44,7 +44,26 @@ class TeleBot:
4444 sendChatAction
4545 getUserProfilePhotos
4646 getUpdates
47- """
47+ getFile
48+ kickChatMember
49+ unbanChatMember
50+ restrictChatMember
51+ promoteChatMember
52+ exportChatInviteLink
53+ setChatPhoto
54+ deleteChatPhoto
55+ setChatTitle
56+ setChatDescription
57+ pinChatMessage
58+ unpinChatMessage
59+ leaveChat
60+ getChat
61+ getChatAdministrators
62+ getChatMembersCount
63+ getChatMember
64+ answerCallbackQuery
65+ answerInlineQuery
66+ """
4867
4968 def __init__ (self , token , threaded = True , skip_pending = False , num_threads = 2 ):
5069 """
@@ -613,6 +632,148 @@ def kick_chat_member(self, chat_id, user_id):
613632 def unban_chat_member (self , chat_id , user_id ):
614633 return apihelper .unban_chat_member (self .token , chat_id , user_id )
615634
635+ def restrict_chat_member (self , chat_id , user_id , until_date = None , can_send_messages = True ,
636+ can_send_media_messages = True , can_send_other_messages = True ,
637+ can_add_web_page_previews = True ):
638+ """
639+ Use this method to restrict a user in a supergroup.
640+ The bot must be an administrator in the supergroup for this to work and must have
641+ the appropriate admin rights. Pass True for all boolean parameters to lift restrictions from a user.
642+ Returns True on success.
643+ :param chat_id: Int or String : Unique identifier for the target group or username of the target supergroup
644+ or channel (in the format @channelusername)
645+ :param user_id: Int : Unique identifier of the target user
646+ :param until_date: Date when restrictions will be lifted for the user, unix time.
647+ If user is restricted for more than 366 days or less than 30 seconds from the current time,
648+ they are considered to be restricted forever
649+ :param can_send_messages: Pass True, if the user can send text messages, contacts, locations and venues
650+ :param can_send_media_messages Pass True, if the user can send audios, documents, photos, videos, video notes
651+ and voice notes, implies can_send_messages
652+ :param can_send_other_messages: Pass True, if the user can send animations, games, stickers and
653+ use inline bots, implies can_send_media_messages
654+ :param can_add_web_page_previews: Pass True, if the user may add web page previews to their messages,
655+ implies can_send_media_messages
656+ :return: types.Message
657+ """
658+ return apihelper .restrict_chat_member (self .token , chat_id , user_id , until_date , can_send_messages ,
659+ can_send_media_messages , can_send_other_messages ,
660+ can_add_web_page_previews )
661+
662+ def promote_chat_member (self , chat_id , user_id , can_change_info = False , can_post_messages = False ,
663+ can_edit_messages = False , can_delete_messages = False , can_invite_users = False ,
664+ can_restrict_members = False , can_pin_messages = False , can_promote_members = False ):
665+ """
666+ Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator
667+ in the chat for this to work and must have the appropriate admin rights.
668+ Pass False for all boolean parameters to demote a user. Returns True on success.
669+ :param chat_id: Unique identifier for the target chat or username of the target channel (
670+ in the format @channelusername)
671+ :param user_id: Int : Unique identifier of the target user
672+ :param can_change_info: Bool: Pass True, if the administrator can change chat title, photo and other settings
673+ :param can_post_messages: Bool : Pass True, if the administrator can create channel posts, channels only
674+ :param can_edit_messages: Bool : Pass True, if the administrator can edit messages of other users, channels only
675+ :param can_delete_messages: Bool : Pass True, if the administrator can delete messages of other users
676+ :param can_invite_users: Bool : Pass True, if the administrator can invite new users to the chat
677+ :param can_restrict_members: Bool: Pass True, if the administrator can restrict, ban or unban chat members
678+ :param can_pin_messages: Bool: Pass True, if the administrator can pin messages, supergroups only
679+ :param can_promote_members: Bool: Pass True, if the administrator can add new administrators with a subset
680+ of his own privileges or demote administrators that he has promoted, directly or indirectly
681+ (promoted by administrators that were appointed by him)
682+ :return:
683+ """
684+ return apihelper .promote_chat_member (self .token , chat_id , user_id , can_change_info , can_post_messages ,
685+ can_edit_messages , can_delete_messages , can_invite_users ,
686+ can_restrict_members , can_pin_messages , can_promote_members )
687+
688+ def export_chat_invite_link (self , chat_id ):
689+ """
690+ Use this method to export an invite link to a supergroup or a channel. The bot must be an administrator
691+ in the chat for this to work and must have the appropriate admin rights.
692+ Returns exported invite link as String on success.
693+ :param chat_id: Id: Unique identifier for the target chat or username of the target channel
694+ (in the format @channelusername)
695+ :return:
696+ """
697+ return apihelper .export_chat_invite_link (self .token , chat_id )
698+
699+ def set_chat_photo (self , chat_id , photo ):
700+ """
701+ Use this method to set a new profile photo for the chat. Photos can't be changed for private chats.
702+ The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
703+ Returns True on success.
704+ Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’
705+ setting is off in the target group.
706+ :param chat_id: Int or Str: Unique identifier for the target chat or username of the target channel
707+ (in the format @channelusername)
708+ :param photo: InputFile: New chat photo, uploaded using multipart/form-data
709+ :return:
710+ """
711+ return apihelper .set_chat_photo (self .token , chat_id , photo )
712+
713+ def delete_chat_photo (self , chat_id ):
714+ """
715+ Use this method to delete a chat photo. Photos can't be changed for private chats.
716+ The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
717+ Returns True on success.
718+ Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’
719+ setting is off in the target group.
720+ :param chat_id: Int or Str: Unique identifier for the target chat or username of the target channel
721+ (in the format @channelusername)
722+ :return:
723+ """
724+ return apihelper .delete_chat_photo (self .token , chat_id )
725+
726+ def set_chat_title (self , chat_id , title ):
727+ """
728+ Use this method to change the title of a chat. Titles can't be changed for private chats.
729+ The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
730+ Returns True on success.
731+ Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’
732+ setting is off in the target group.
733+ :param chat_id: Int or Str: Unique identifier for the target chat or username of the target channel
734+ (in the format @channelusername)
735+ :param title: New chat title, 1-255 characters
736+ :return:
737+ """
738+ return apihelper .set_chat_title (self .token , chat_id , title )
739+
740+ def set_chat_description (self , chat_id , description ):
741+ """
742+ Use this method to change the description of a supergroup or a channel.
743+ The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
744+ Returns True on success.
745+ :param chat_id: Int or Str: Unique identifier for the target chat or username of the target channel
746+ (in the format @channelusername)
747+ :param description: Str: New chat description, 0-255 characters
748+ :return:
749+ """
750+ return apihelper .set_chat_description (self .token , chat_id , description )
751+
752+ def pin_chat_message (self , chat_id , message_id , disable_notification = False ):
753+ """
754+ Use this method to pin a message in a supergroup.
755+ The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
756+ Returns True on success.
757+ :param chat_id: Int or Str: Unique identifier for the target chat or username of the target channel
758+ (in the format @channelusername)
759+ :param message_id: Int: Identifier of a message to pin
760+ :param disable_notification: Bool: Pass True, if it is not necessary to send a notification
761+ to all group members about the new pinned message
762+ :return:
763+ """
764+ return apihelper .pin_chat_message (self .token , chat_id , message_id , disable_notification )
765+
766+ def unpin_chat_message (self , chat_id ):
767+ """
768+ Use this method to unpin a message in a supergroup chat.
769+ The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
770+ Returns True on success.
771+ :param chat_id: Int or Str: Unique identifier for the target chat or username of the target channel
772+ (in the format @channelusername)
773+ :return:
774+ """
775+ return apihelper .unpin_chat_message (self .token , chat_id )
776+
616777 def edit_message_text (self , text , chat_id = None , message_id = None , inline_message_id = None , parse_mode = None ,
617778 disable_web_page_preview = None , reply_markup = None ):
618779 result = apihelper .edit_message_text (self .token , text , chat_id , message_id , inline_message_id , parse_mode ,
0 commit comments