Skip to content

Commit d6ec104

Browse files
authored
Update create_invite_link.py
Imported both inline keyboards in same line:|
1 parent 7edaa51 commit d6ec104

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

examples/create_invite_link.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import telebot
22
from time import sleep, time
3-
from telebot.types import InlineKeyboardMarkup as ikm #Only for creating Inline Buttons, not necessary for creating Invite Links
4-
from telebot.types import InlineKeyboardButton as ikb #Only for creating Inline Buttons, not necessary for creating Invite Links
3+
from telebot.types import InlineKeyboardMarkup, InlineKeyboardButton #Only for creating Inline Buttons, not necessary for creating Invite Links
54

65
Token = "api_token" #Your Bot Access Token
76
Group_ID = -1234567890 #Group ID for which invite link is to be created
@@ -19,8 +18,8 @@ def newmember(msg):
1918
#Create an invite link class that contains info about the created invite link using create_chat_invite_link() with parameters
2019
invite = bot.create_chat_invite_link(Group_ID, member_limit=1, expire_date=int(time())+45) #Here, the link will auto-expire in 45 seconds
2120
InviteLink = invite.invite_link #Get the actual invite link from 'invite' class
22-
mrkplink = ikm() #Created Inline Markup Keyboard
23-
mrkplink.add(ikb("Join our group 🚀", url=InviteLink)) #Added Invite Link to Inline Markup Keyboard
21+
mrkplink = InlineKeyboardMarkup() #Created Inline Keyboard Markup
22+
mrkplink.add(InlineKeyboardButton("Join our group 🚀", url=InviteLink)) #Added Invite Link to Inline Keyboard
2423
bot.send_message(msg.chat.id, f"Hey there {msg.from_user.first_name}, Click the link below to join our Official Group." reply_markup=mrkplink)
2524

2625
#This will send a message with the newly-created invite link as markup button.

0 commit comments

Comments
 (0)