File tree Expand file tree Collapse file tree
pyrogram/methods/payments Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -53,6 +53,9 @@ async def convert_gift_to_stars(
5353 # Convert gift
5454 await app.convert_gift_to_stars(message_id=123)
5555 """
56+ if not isinstance (owned_gift_id , str ):
57+ raise ValueError (f"owned_gift_id has to be str, but { type (owned_gift_id )} was provided" )
58+
5659 saved_gift_match = re .match (r"^(-\d+)_(\d+)$" , owned_gift_id )
5760 slug_match = self .UPGRADED_GIFT_RE .match (owned_gift_id )
5861
Original file line number Diff line number Diff line change 1616# You should have received a copy of the GNU Lesser General Public License
1717# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818
19- import re
20-
2119import pyrogram
2220from pyrogram import raw , types
2321
Original file line number Diff line number Diff line change @@ -54,7 +54,8 @@ async def hide_gift(
5454 # Hide gift in channel (owned_gift_id packed in format chatID_savedID)
5555 await app.hide_gift(owned_gift_id="123_456")
5656 """
57- owned_gift_id = str (owned_gift_id )
57+ if not isinstance (owned_gift_id , str ):
58+ raise ValueError (f"owned_gift_id has to be str, but { type (owned_gift_id )} was provided" )
5859
5960 saved_gift_match = re .match (r"^(-\d+)_(\d+)$" , owned_gift_id )
6061 slug_match = self .UPGRADED_GIFT_RE .match (owned_gift_id )
Original file line number Diff line number Diff line change @@ -51,7 +51,8 @@ async def set_gift_resale_price(
5151 # Change resale price of a unique gift
5252 await app.set_gift_resale_price(owned_gift_id="123456", resale_star_count=100)
5353 """
54- owned_gift_id = str (owned_gift_id )
54+ if not isinstance (owned_gift_id , str ):
55+ raise ValueError (f"owned_gift_id has to be str, but { type (owned_gift_id )} was provided" )
5556
5657 saved_gift_match = re .match (r"^(-\d+)_(\d+)$" , owned_gift_id )
5758 slug_match = self .UPGRADED_GIFT_RE .match (owned_gift_id )
Original file line number Diff line number Diff line change @@ -58,8 +58,11 @@ async def set_pinned_gifts(
5858 stargifts = []
5959
6060 for gift in owned_gift_ids :
61- saved_gift_match = re .match (r"^(-\d+)_(\d+)$" , str (gift ))
62- slug_match = self .UPGRADED_GIFT_RE .match (str (gift ))
61+ if not isinstance (gift , str ):
62+ raise ValueError (f"gift id has to be str, but { type (gift )} was provided" )
63+
64+ saved_gift_match = re .match (r"^(-\d+)_(\d+)$" , gift )
65+ slug_match = self .UPGRADED_GIFT_RE .match (gift )
6366
6467 if saved_gift_match :
6568 stargifts .append (
Original file line number Diff line number Diff line change @@ -54,7 +54,8 @@ async def show_gift(
5454 # Show gift in channel (owned_gift_id packed in format chatID_savedID)
5555 await app.show_gift(owned_gift_id="123_456")
5656 """
57- owned_gift_id = str (owned_gift_id )
57+ if not isinstance (owned_gift_id , str ):
58+ raise ValueError (f"owned_gift_id has to be str, but { type (owned_gift_id )} was provided" )
5859
5960 saved_gift_match = re .match (r"^(-\d+)_(\d+)$" , owned_gift_id )
6061 slug_match = self .UPGRADED_GIFT_RE .match (owned_gift_id )
Original file line number Diff line number Diff line change @@ -65,7 +65,8 @@ async def transfer_gift(
6565 # Transfer gift to another user
6666 await app.transfer_gift(owned_gift_id="123", new_owner_chat_id=123)
6767 """
68- owned_gift_id = str (owned_gift_id )
68+ if not isinstance (owned_gift_id , str ):
69+ raise ValueError (f"owned_gift_id has to be str, but { type (owned_gift_id )} was provided" )
6970
7071 saved_gift_match = re .match (r"^(-\d+)_(\d+)$" , owned_gift_id )
7172 slug_match = self .UPGRADED_GIFT_RE .match (owned_gift_id )
Original file line number Diff line number Diff line change @@ -66,7 +66,8 @@ async def upgrade_gift(
6666 # Upgrade gift in channel (owned_gift_id packed in format chatID_savedID)
6767 await app.upgrade_gift(owned_gift_id="123_456")
6868 """
69- owned_gift_id = str (owned_gift_id )
69+ if not isinstance (owned_gift_id , str ):
70+ raise ValueError (f"owned_gift_id has to be str, but { type (owned_gift_id )} was provided" )
7071
7172 saved_gift_match = re .match (r"^(-\d+)_(\d+)$" , owned_gift_id )
7273 slug_match = self .UPGRADED_GIFT_RE .match (owned_gift_id )
You can’t perform that action at this time.
0 commit comments