1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

Compare commits

...

7 Commits

Author SHA1 Message Date
Badiboy
6b19d631d1
Merge pull request #1565 from DevAdvik/master
Update create_invite_link.py
2022-05-23 14:16:42 +03:00
Advik Singh Somvanshi
ee7adb00df
Re-fix inlinekeyboardmarkup 2022-05-23 13:27:48 +05:30
Advik Singh Somvanshi
1d0efce76e
Update create_invite_link.py
Fix
2022-05-22 02:17:21 +05:30
Advik Singh Somvanshi
74d0604c05
Update create_invite_link.py
Bug fix (Real FINAL FIX!!)
2022-05-22 01:54:02 +05:30
Advik Singh Somvanshi
d6ec104829
Update create_invite_link.py
Imported both inline keyboards in same line:|
2022-05-22 01:48:48 +05:30
Advik Singh Somvanshi
7edaa51995
Update create_invite_link.py
Removed while loop
2022-05-22 01:43:24 +05:30
Advik Singh Somvanshi
6bb47e9a44
Update create_invite_link.py
Added .types while importing inline markup keyboards (fix)
Removed threading import since message is not to be deleted
2022-05-22 01:38:32 +05:30

View File

@ -1,7 +1,6 @@
import telebot, threading
import telebot
from time import sleep, time
from telebot import InlineKeyboardMarkup as ikm #Only for creating Inline Buttons, not necessary for creating Invite Links
from telebot import InlineKeyboardButton as ikb #Only for creating Inline Buttons, not necessary for creating Invite Links
from telebot.types import InlineKeyboardMarkup, InlineKeyboardButton #Only for creating Inline Buttons, not necessary for creating Invite Links
Token = "api_token" #Your Bot Access Token
Group_ID = -1234567890 #Group ID for which invite link is to be created
@ -19,9 +18,11 @@ def newmember(msg):
#Create an invite link class that contains info about the created invite link using create_chat_invite_link() with parameters
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
InviteLink = invite.invite_link #Get the actual invite link from 'invite' class
mrkplink = ikm() #Created Inline Markup Keyboard
mrkplink.add(ikb("Join our group 🚀", url=InviteLink)) #Added Invite Link to Inline Markup Keyboard
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)
mrkplink = InlineKeyboardMarkup() #Created Inline Keyboard Markup
mrkplink.add(InlineKeyboardButton("Join our group 🚀", url=InviteLink)) #Added Invite Link to Inline Keyboard
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)
#This will send a message with the newly-created invite link as markup button.
#The member limit will be 1 and expiring time will be 45 sec.
@ -29,8 +30,4 @@ def newmember(msg):
while True:
try:
bot.infinity_polling()
except:
sleep(0.04)
bot.infinity_polling()