· 6 years ago · Jan 01, 2020, 11:18 PM
1import instabot
2import telegram
3
4from telegram.ext import Updater,CommandHandler,MessageHandler,ConversationHandler, Filters
5from telegram.ext import CallbackQueryHandler, PicklePersistence
6from telegram import InlineKeyboardButton, InlineKeyboardMarkup
7
8import logging
9
10logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',level=logging.INFO)
11logger = logging.getLogger(__name__)
12
13u = Updater(token='987812301:AAGQhKRmFoWsD_HJ4PqEnKMKkvo4FtCT2T0', use_context=True)
14credict = {}
15
16dispatcher = u.dispatcher
17PASSWORD = 1
18PASSWORDHANDLE = 0
19HOME = 2
20RHELPER = 3
21lockdict = {}
22
23j = u.job_queue
24botlist = []
25lastmediacheck = {}
26acceptedusers = ['Idyllic']
27logger.info("starting")
28globalcount = [0]
29botdict = {}
30
31def start(update, context):
32 logger.info("/start")
33 keyboard = [[InlineKeyboardButton("Login", callback_data='button1'),
34 InlineKeyboardButton("FAQ", callback_data='button2')],
35 [InlineKeyboardButton("My Accounts", callback_data='button3'),
36 InlineKeyboardButton("Groupchat", url = "https://t.me/theboostme")],[InlineKeyboardButton("Current Users", callback_data='button5'),
37 InlineKeyboardButton("Remove Accounts", callback_data='button6')]]
38 name = update.effective_user.first_name
39 reply_markup = InlineKeyboardMarkup(keyboard)
40 startext = "Hello " + name + " and welcome to *Boostme*!" + "\n" + "" + "\n" + "This bot utilizes automatic likes to help you organically grow your Instagram account; around 30 seconds after you post a photo you will see likes flow in from our other users." + "\n" + "" + "\n" + "At the moment *BoostMe* is completely free to use and enjoy. If you are unfamiliar with autolikes it is highly recommended that you read our FAQ before starting!" + "\n" + "" + "\n" + "If you have any other questions feel free to contact our admins!"
41 update.message.reply_text(startext, reply_markup=reply_markup, parse_mode=telegram.ParseMode.MARKDOWN)
42
43def return_start(update, context):
44 logger.info("/return_start")
45 logger.debug("/return_start")
46 keyboard = [[InlineKeyboardButton("Login", callback_data='button1'),
47 InlineKeyboardButton("FAQ", callback_data='button2')],
48 [InlineKeyboardButton("My Accounts", callback_data='button3'),
49 InlineKeyboardButton("Groupchat", url = "https://t.me/theboostme")],[InlineKeyboardButton("Current Users", callback_data='button5'),
50 InlineKeyboardButton("Remove Accounts", callback_data='button6')]]
51 name = update.effective_user.first_name
52 reply_markup = InlineKeyboardMarkup(keyboard)
53 startext = "Hello " + name + " and welcome to *Boostme*!" + "\n" + "" + "\n" + "This bot utilizes automatic likes to help you organically grow your Instagram account; around 30 seconds after you post a photo you will see likes flow in from our other users." + "\n" + "" + "\n" + "At the moment *BoostMe* is completely free to use and enjoy. If you are unfamiliar with autolikes it is highly recommended that you read our FAQ before starting!" + "\n" + "" + "\n" + "If you have any other questions feel free to contact our admins!"
54 logger.debug(update.callback_query.edit_message_text(startext, reply_markup=reply_markup, parse_mode=telegram.ParseMode.MARKDOWN))
55
56def my_accounts(update, context):
57 query = update.callback_query
58 keyboard = [[InlineKeyboardButton("Return Home", callback_data='returnhome2')]]
59 reply_markup = InlineKeyboardMarkup(keyboard)
60 accountinfo = ""
61 if len(context.user_data) == 0:
62 query.edit_message_text(text="You have no accounts currently in the system",reply_markup=reply_markup)
63 else:
64 for key in context.user_data:
65 followers = len(botlist[0].get_user_following(key))
66 accountinfo += ("@" + key + " , Followers: " + str(followers) + '\n')
67 query.edit_message_text(text="Your *current* *accounts*: " + '\n' + accountinfo,reply_markup=reply_markup,parse_mode=telegram.ParseMode.MARKDOWN)
68
69def removeaccount(update, context):
70 query = update.callback_query
71 keyboard = [[InlineKeyboardButton("Return Home", callback_data='returnhome2')]]
72 reply_markup = InlineKeyboardMarkup(keyboard)
73 accountinfo = ""
74 if len(context.user_data) == 0:
75 query.edit_message_text(text="You have no accounts registered with us yet",reply_markup=reply_markup)
76 else:
77 for key in context.user_data:
78 followers = len(botlist[0].get_user_following(key))
79 accountinfo += ("@" + key + " , Followers: " + str(followers) + '\n')
80 query.edit_message_text(text="Respond with the username of the account you would like to remove. (no @)" + "\n" + "" + "\n" + accountinfo, reply_markup=reply_markup)
81 return RHELPER
82
83def rhelper(update, context):
84 logger.info("rhelp")
85 toremove = update.message.text
86 keyboard = [[InlineKeyboardButton("Return Home", callback_data='returnhome2')]]
87 reply_markup = InlineKeyboardMarkup(keyboard)
88 if toremove not in user_data:
89 context.bot.send_message(chat_id=update.effective_chat.id, text="Sorry, the account you specified is not currently registered under you.",reply_markup=reply_markup)
90 else:
91 idx = botdict[toremove]
92 del context.user_data[toremove]
93 del botlist[idx]
94 context.bot.send_message(chat_id=update.effective_chat.id, text="I removed " + toremove + " , you will no longer recieve or give likes.",reply_markup=reply_markup)
95
96def users(update, context):
97 query = update.callback_query
98 keyboard = [[InlineKeyboardButton("Return Home", callback_data='returnhome2')]]
99 reply_markup = InlineKeyboardMarkup(keyboard)
100 accountinfo = ""
101 accountcount = 0
102 if len(credict) == 0:
103 query.edit_message_text(text="There are currently no accounts registered with us",reply_markup=reply_markup)
104 else:
105 followersum = 0
106 for key in credict:
107 accountcount +=1
108 followers = len(botlist[0].get_user_following(key))
109 followersum += followers
110 accountinfo += ("@" + key + " , Followers: " + str(followers) + '\n')
111 query.edit_message_text(text="*Our total reach*: " + str(followersum) + "\n" + "" + "\n"+ "*Total accounts in the system*: " + str(accountcount) + "\n" + "" + "\n" + "*Current users*: " + '\n' + accountinfo,reply_markup=reply_markup,parse_mode=telegram.ParseMode.MARKDOWN)
112
113def addaccount(update, context):
114 logger.info("/addaccount")
115 query = update.callback_query
116 query.edit_message_text(text="Send the username of the account that you want to add, or /cancel")
117 return PASSWORD
118
119def password(update, context):
120 logger.info("/password")
121 username = update.message.text
122 keyboard = [[InlineKeyboardButton("Return Home", callback_data='returnhome2')]]
123 reply_markup = InlineKeyboardMarkup(keyboard)
124 if len(botlist) != 0:
125 checkid = botlist[0].get_user_id_from_username(username)
126 if checkid == None:
127 context.bot.send_message(chat_id=update.effective_chat.id, text="That username does not belong to any account on Instagram.",reply_markup=reply_markup)
128 return ConversationHandler.END
129
130 newid = update.effective_user.username
131 (context.chat_data)[newid] = [username]
132 context.bot.send_message(chat_id=update.effective_chat.id, text="Awesome now send your password, or use /cancel to cancel")
133 return PASSWORDHANDLE
134
135def passwordhandle(update, context):
136 logger.info("/passwordhandle")
137 keyboard = [[InlineKeyboardButton("Return Home", callback_data='returnhome2')]]
138 reply_markup = InlineKeyboardMarkup(keyboard)
139 newid = update.effective_user.username
140 password = update.message.text
141 (context.chat_data)[newid].append(password) #adds to local dict, specifc to chat...
142 botid = str(update.effective_user.id)
143 context.bot.send_message(chat_id=update.effective_chat.id, text="Processing give me a second...")
144 if context.chat_data[newid][0] in lockdict:
145 botid = lockdict[context.chat_data[newid][0]]
146 else:
147 botid = instabot.Bot(like_delay=4,max_likes_per_day=100000000,max_unlikes_per_day=10000000,max_follows_per_day=3500000,max_unfollows_per_day=350000000,max_comments_per_day=1000000,max_blocks_per_day=100000,max_unblocks_per_day=1000000,max_likes_to_like=1000000000,min_likes_to_like=-1,max_messages_per_day=3000000,filter_users=False,filter_private_users=False,filter_users_without_profile_photo=False,filter_previously_followed=False,filter_business_accounts=False,filter_verified_accounts=False,max_followers_to_follow=5000000,min_followers_to_follow=-1,max_following_to_follow=200000000,min_following_to_follow=-1,max_followers_to_following_ratio=150000000,max_following_to_followers_ratio=1500000000,min_media_count_to_follow=-1,max_following_to_block=20000000000,unlike_delay=10,follow_delay=30,unfollow_delay=30,comment_delay=60,block_delay=30,unblock_delay=30,message_delay=60,stop_words=("shop", "store", "free"),blacklist_hashtags=["#shop", "#store", "#free"],blocked_actions_protection=True,blocked_actions_sleep=False,blocked_actions_sleep_delay=300,verbosity=True,device=None,save_logfile=True,log_filename=None,log_follow_unfollow=False)
148 if botid.login(ask_for_code=True, username = (context.chat_data)[newid][0], password = (context.chat_data)[newid][1],is_threaded = True) == False:
149 context.bot.send_photo(chat_id=update.effective_chat.id, photo=open('lock.png', 'rb')) #change this for server
150 context.bot.send_message(chat_id=update.effective_chat.id, text="Either your password is incorrect or our servers triggered a location lock. To fix this issue please go to the instagram app/website and click 'this was me'.",reply_markup=reply_markup)
151 userlock = context.chat_data[newid][0]
152 lockdict[userlock] = botid
153 context.chat_data.clear()
154 return ConversationHandler.END
155 else:
156 botlist.append(botid)
157 credict[(context.chat_data)[newid][0]] = (context.chat_data)[newid][1] #adds to global user pass dict
158 context.bot.send_message(chat_id=update.effective_chat.id, text="Sucessfully logged in! Liking should start automatically next time you post",reply_markup=reply_markup)
159 write_file(credict, (str(update.effective_user.id)))
160 user = context.chat_data[newid][0]
161 botdict[user] = globalcount[0]
162 globalcount[0] += 1
163 passw = context.chat_data[newid][1]
164 context.user_data[user] = passw
165 context.chat_data.clear()
166 return ConversationHandler.END
167
168def like(update, context):
169 logger.info("/like")
170 context.bot.send_message(chat_id=update.effective_chat.id, text="Processing, one moment please")
171 for i in range(len(botlist)):
172 newid = botlist[i].get_media_id_from_link("https://www.instagram.com/p/B6gmXValZep/")
173 botlist[i].like_medias([newid])
174 context.bot.send_message(chat_id=update.effective_chat.id, text="Done!")
175
176def write_file(credict,botid):
177 logger.info("/writefile")
178 file = open("passwords.txt", 'w')
179 for key in credict:
180 line = key + " " + credict[key] + " " + botid +'\n'
181 file.write(line)
182 file.close()
183
184
185def restore(update, context):
186 logger.info("/restore")
187 file = open("passwords.txt", 'r')
188 context.bot.send_message(chat_id=update.effective_chat.id, text="Processing give me a second.")
189 for line in file:
190 linelist = line.split()
191 newusername = linelist[0]
192 newpassword = linelist[1]
193 credict[newusername] = newpassword
194 botid = linelist[2]
195 botid = instabot.Bot(like_delay=4,max_likes_per_day=100000000,max_unlikes_per_day=10000000,max_follows_per_day=3500000,max_unfollows_per_day=350000000,max_comments_per_day=1000000,max_blocks_per_day=100000,max_unblocks_per_day=1000000,max_likes_to_like=1000000000,min_likes_to_like=-1,max_messages_per_day=3000000,filter_users=False,filter_private_users=False,filter_users_without_profile_photo=False,filter_previously_followed=False,filter_business_accounts=False,filter_verified_accounts=False,max_followers_to_follow=5000000,min_followers_to_follow=-1,max_following_to_follow=200000000,min_following_to_follow=-1,max_followers_to_following_ratio=150000000,max_following_to_followers_ratio=1500000000,min_media_count_to_follow=-1,max_following_to_block=20000000000,unlike_delay=10,follow_delay=30,unfollow_delay=30,comment_delay=60,block_delay=30,unblock_delay=30,message_delay=60,stop_words=("shop", "store", "free"),blacklist_hashtags=["#shop", "#store", "#free"],blocked_actions_protection=True,blocked_actions_sleep=False,blocked_actions_sleep_delay=300,verbosity=True,device=None,save_logfile=True,log_filename=None,log_follow_unfollow=False)
196 botid.login(username = newusername, password = newpassword,is_threaded = True)
197 botlist.append(botid)
198 context.bot.send_message(chat_id=update.effective_chat.id, text="Done!")
199
200
201def check_post(context: telegram.ext.CallbackContext):
202 logger.info("checking post")
203 for key in credict:
204 if len(botlist) != 0:
205 newid = botlist[0].get_user_id_from_username(key)
206 mediaids = botlist[0].get_user_medias(newid, filtration = False) #gets recent media with username id
207 if len(mediaids) > 0:
208 lastmedia = mediaids[0]
209 if key in lastmediacheck and len(mediaids) > 0:
210 if lastmediacheck[key] != lastmedia:
211 for i in botlist:
212 i.like(lastmedia)
213 lastmediacheck[key] = lastmedia
214 else:
215 if len(mediaids) != 0:
216 lastmediacheck[key] = lastmedia
217 else:
218 print("No media detected")
219
220def FAQ_func(update, context):
221 query = update.callback_query
222 keyboard = [[InlineKeyboardButton("Return Home", callback_data='returnhome2')]]
223 reply_markup = InlineKeyboardMarkup(keyboard)
224 faqtext = "» *Why do I need to sign in?*" + "\n" + "BoostMe uses automatic likes which means our servers need to stay logged into your account. No human being ever sees your information, it is encrypted and sent directly through instagrams api" +"\n" + "" + "\n" + "» *Is there a risk of getting banned?*" + "\n" + "Actually BoostMe is hardcoded to login to each individual account under the front of an android phone. This means Instagram just thinks a normal user is liking photos when BoostMe engages." +"\n" + "" + "\n" + "» *Why is it free?*" + "\n" + "We want a user base before we start charging for premium features, no one would pay for a bot that they don’t know works!" +"\n" + "" + "\n" + "» *How does it work?*" + "\n" + "So basically our bot utilizes Instagrams api to log in and stay logged into your account. Every time you or any other user in the system posts a photo the bot detects this post and makes everyone logged in like it. This therefore boosts your post and helps it go viral." +"\n" + "" + "\n" + "» *Will this bot actually help me grow my account?*" + "\n" + "That all depends, do you post quality content, frequently and have good page appearance? Our bot helps photos go viral, aka hit explore, but it’s no magic growth solution. Automatic likes have been proven to work as a concept." +"\n" + "" + "\n" + "» *Can I even trust you?*" + "\n" + "That’s your choice, if you don’t trust us at first use a smaller account to see that what we made actually works. Telegram is full of scammers, BoostMe is a genuine service made for the benefit of all." +"\n" + "" + "\n" + "» *Additional questions?*" + "\n" + "Contact @idyllic, Im happy to help :)"
225 query.edit_message_text(text=faqtext,reply_markup=reply_markup,parse_mode=telegram.ParseMode.MARKDOWN)
226
227
228
229def cancel(update, context):
230 logger.info("/cancel")
231 query = update.callback_query
232 keyboard = [[InlineKeyboardButton("Return Home", callback_data='returnhome')]]
233 reply_markup = InlineKeyboardMarkup(keyboard)
234 context.bot.send_message(chat_id=update.effective_chat.id, text="I cancelled your request!",reply_markup=reply_markup)
235 return ConversationHandler.END
236
237def main():
238 logger.info("starting bot")
239 my_persistence = PicklePersistence(filename='instabot')
240 start_handler = CommandHandler(command='start', callback=start)
241 like_handler = CommandHandler(command='like', callback=like)
242 restore_handler = CommandHandler(command='restore', callback=restore)
243 return_home2 = CallbackQueryHandler(return_start, pattern='returnhome2')
244 faq = CallbackQueryHandler(FAQ_func, pattern='^' + str('button2') + '$')
245 user_handler = CallbackQueryHandler(users, pattern='^' + str('button5') + '$') #registers all handlers
246 myaccounts_handler = CallbackQueryHandler(my_accounts, pattern='^' + str('button3') + '$')
247 dispatcher.add_handler(myaccounts_handler)
248 dispatcher.add_handler(faq)
249 dispatcher.add_handler(return_home2)
250 dispatcher.add_handler(user_handler)
251 dispatcher.add_handler(start_handler)
252 dispatcher.add_handler(like_handler)
253 dispatcher.add_handler(restore_handler)
254 conv_handler = ConversationHandler(entry_points = [CommandHandler('addaccount',addaccount), CallbackQueryHandler(addaccount, pattern='^' + str('button1') + '$'),CallbackQueryHandler(return_start, pattern='returnhome')], states = {HOME: [CallbackQueryHandler(return_start, pattern='returnhome')], PASSWORD: [MessageHandler(Filters.text, password)],PASSWORDHANDLE: [MessageHandler(Filters.text, passwordhandle)]}, fallbacks=[CallbackQueryHandler(return_start, pattern='returnhome'),CommandHandler(command='cancel', callback=cancel) ],allow_reentry = True)
255 conv_handler2 = ConversationHandler(entry_points = [CommandHandler('removeaccount',removeaccount),CallbackQueryHandler(removeaccount, pattern='^' + str('button6') + '$'),CallbackQueryHandler(return_start, pattern='returnhome')], states = {HOME: [CallbackQueryHandler(return_start, pattern='returnhome')], RHELPER: [MessageHandler(Filters.text, rhelper)]}, fallbacks=[CallbackQueryHandler(return_start, pattern='returnhome'),CommandHandler(command='cancel', callback=cancel) ],allow_reentry = True)
256 dispatcher.add_handler(conv_handler)
257 dispatcher.add_handler(conv_handler2)
258 job_time = j.run_repeating(check_post, interval=30, first=0)
259 u.start_polling()
260 u.idle()
261
262main()