From 6bb47e9a449a0058ffd9c8bd1605116ec1ff5472 Mon Sep 17 00:00:00 2001 From: Advik Singh Somvanshi Date: Sun, 22 May 2022 01:38:32 +0530 Subject: [PATCH 1/6] Update create_invite_link.py Added .types while importing inline markup keyboards (fix) Removed threading import since message is not to be deleted --- examples/create_invite_link.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/create_invite_link.py b/examples/create_invite_link.py index 71c6ed4..9413549 100644 --- a/examples/create_invite_link.py +++ b/examples/create_invite_link.py @@ -1,7 +1,7 @@ -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 as ikm #Only for creating Inline Buttons, not necessary for creating Invite Links +from telebot.types import InlineKeyboardButton as ikb #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 From 7edaa51995604fb11d3b6cf298c6b5510a98d178 Mon Sep 17 00:00:00 2001 From: Advik Singh Somvanshi Date: Sun, 22 May 2022 01:43:24 +0530 Subject: [PATCH 2/6] Update create_invite_link.py Removed while loop --- examples/create_invite_link.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/examples/create_invite_link.py b/examples/create_invite_link.py index 9413549..e7fc2ed 100644 --- a/examples/create_invite_link.py +++ b/examples/create_invite_link.py @@ -29,8 +29,4 @@ def newmember(msg): -while True: - try: - bot.infinity_polling() - except: - sleep(0.04) +bot.infinity_polling() From d6ec104829d30c611ae42c12c6efda5cea7c76c2 Mon Sep 17 00:00:00 2001 From: Advik Singh Somvanshi Date: Sun, 22 May 2022 01:48:48 +0530 Subject: [PATCH 3/6] Update create_invite_link.py Imported both inline keyboards in same line:| --- examples/create_invite_link.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/create_invite_link.py b/examples/create_invite_link.py index e7fc2ed..6259b92 100644 --- a/examples/create_invite_link.py +++ b/examples/create_invite_link.py @@ -1,7 +1,6 @@ import telebot from time import sleep, time -from telebot.types import InlineKeyboardMarkup as ikm #Only for creating Inline Buttons, not necessary for creating Invite Links -from telebot.types 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,8 +18,8 @@ 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 + 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. From 74d0604c053329d77c1a795f67557c8ac6ad7f80 Mon Sep 17 00:00:00 2001 From: Advik Singh Somvanshi Date: Sun, 22 May 2022 01:54:02 +0530 Subject: [PATCH 4/6] Update create_invite_link.py Bug fix (Real FINAL FIX!!) --- examples/create_invite_link.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/create_invite_link.py b/examples/create_invite_link.py index 6259b92..ffbc8b9 100644 --- a/examples/create_invite_link.py +++ b/examples/create_invite_link.py @@ -20,7 +20,7 @@ def newmember(msg): InviteLink = invite.invite_link #Get the actual invite link from 'invite' class 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) + 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. From 1d0efce76ec8695498f788348bd21f34f232d9d3 Mon Sep 17 00:00:00 2001 From: Advik Singh Somvanshi Date: Sun, 22 May 2022 02:17:21 +0530 Subject: [PATCH 5/6] Update create_invite_link.py Fix --- examples/create_invite_link.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/create_invite_link.py b/examples/create_invite_link.py index ffbc8b9..4679898 100644 --- a/examples/create_invite_link.py +++ b/examples/create_invite_link.py @@ -1,6 +1,7 @@ import telebot from time import sleep, time from telebot.types import InlineKeyboardMarkup, InlineKeyboardButton #Only for creating Inline Buttons, not necessary for creating Invite Links +mrkplink = InlineKeyboardMarkup() #Created Inline Keyboard Markup Token = "api_token" #Your Bot Access Token Group_ID = -1234567890 #Group ID for which invite link is to be created @@ -18,8 +19,9 @@ 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 = 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. From ee7adb00dfcb9495ddbf078638b8b5391f0ade29 Mon Sep 17 00:00:00 2001 From: Advik Singh Somvanshi Date: Mon, 23 May 2022 13:27:48 +0530 Subject: [PATCH 6/6] Re-fix inlinekeyboardmarkup --- examples/create_invite_link.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/create_invite_link.py b/examples/create_invite_link.py index 4679898..eb8cebf 100644 --- a/examples/create_invite_link.py +++ b/examples/create_invite_link.py @@ -1,7 +1,6 @@ import telebot from time import sleep, time from telebot.types import InlineKeyboardMarkup, InlineKeyboardButton #Only for creating Inline Buttons, not necessary for creating Invite Links -mrkplink = InlineKeyboardMarkup() #Created Inline Keyboard Markup Token = "api_token" #Your Bot Access Token Group_ID = -1234567890 #Group ID for which invite link is to be created @@ -20,6 +19,7 @@ def newmember(msg): 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 = 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)