forked from ninja8bpyt/Instagram_DP_Saver_Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
84 lines (63 loc) · 2.58 KB
/
bot.py
File metadata and controls
84 lines (63 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import logging
from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update
from telegram.ext import Updater, CommandHandler, CallbackQueryHandler, CallbackContext, MessageHandler, Filters, commandhandler
import os
from instaloader import Instaloader, Profile
import time
L = Instaloader()
TOKEN = "7024280142:AAE6mIYG0B_n5RMRCip1G0M9aMvTdht98Wg"
welcome_msg = '''<b>Welcome To the Bot</b>🖐🖐
<i>Send me anyones instagram username to get their DP</i>
ex : <b>ninja8bpyt</b> , <b>thenameisyash</b> etc'''
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO
)
logger = logging.getLogger(__name__)
# Start the Bot
def start(update, context):
update.message.reply_html(welcome_msg)
def help_msg(update, context):
update.message.reply_text("Nothing to help ,this is Way to Simple 😂😂")
def contact(update, context):
keyboard = [[InlineKeyboardButton(
"Contact", url="telegram.me/ninja8bpyt")], ]
reply_markup = InlineKeyboardMarkup(keyboard)
update.message.reply_text('Contact The Maker:', reply_markup=reply_markup)
# get teh username and send the DP
def username(update, context):
msg = update.message.reply_text("Downloading...")
query = update.message.text
chat_id = update.message.chat_id
# try:
dp = Profile.from_username(
L.context, query).profile_pic_url
context.bot.send_photo(
chat_id=chat_id, photo=dp, caption="Thank You For Using The bot 😀😀")
msg.edit_text("finished.")
time.sleep(5)
# except Exception:
# msg.edit_text("Try Again 😕😕 Check the username correctly")
def error(update, context):
"""Log Errors caused by Updates."""
logger.warning('Update "%s" caused error "%s"', update, context.error)
def main():
# Create the Updater and pass it your bot's token.
updater = Updater(TOKEN, use_context=True)
#PORT = int(os.environ.get('PORT', '8443'))
dp = updater.dispatcher
dp.add_handler(CommandHandler("start", start))
dp.add_handler(CommandHandler("help", help_msg))
dp.add_handler(CommandHandler("contact", contact))
dp.add_handler(MessageHandler(Filters.text, username))
# log all errors
dp.add_error_handler(error)
# Start the Bot
updater.start_polling()
#updater.start_webhook(listen="0.0.0.0", port=PORT, url_path=TOKEN)
#updater.bot.set_webhook(
# "https://igdp-bot.herokuapp.com/" + TOKEN)
# Run the bot until the user presses Ctrl-C or the process receives SIGINT,
# SIGTERM or SIGABRT
updater.idle()
if __name__ == '__main__':
main()