Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 13891

i am trying to make bot who can upload images telegram to instagram

$
0
0

S C:\Users\hp\Desktop\telegram> c:; cd 'c:\Users\hp\Desktop\telegram'; & 'C:\Program Files\Python312\python.exe''c:\Users\hp\.vscode\extensions\ms-python.python-2023.22.1\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher''54413''--''C:\Users\hp\Desktop\telegram\f.py' 2024-01-26 14:40:41,217 - INFO - Instabot version: 0.117.0 Started 2024-01-26 14:40:41,222 - INFO - Not yet logged in starting: PRE-LOGIN FLOW! 2024-01-26 14:40:48,775 - ERROR - Request returns 400 error! 2024-01-26 14:40:48,776 - INFO - Instagram's error message: The username you entered doesn't appear to belong to an account. Please check your username and try again. 2024-01-26 14:40:48,777 - INFO - Error type: invalid_user 2024-01-26 14:40:48,778 - ERROR - Failed to login go to instagram and change your password 2024-01-26 14:40:48,778 - INFO - Username or password is incorrect. PS C:\Users\hp\Desktop\telegram>

from telegram import Updatefrom telegram.ext import CommandHandler, CallbackContext, Applicationfrom instabot import Botimport asyncio# Initialize Telegram botTELEGRAM_TOKEN = ""bot = Bot()# Initialize Instagram bot with App ID and App SecretINSTAGRAM_APP_ID = ""INSTAGRAM_APP_SECRET = ""bot.login(username=INSTAGRAM_APP_ID, password=INSTAGRAM_APP_SECRET)async def start(update: Update, context: CallbackContext) -> None:    await update.message.reply_text('Welcome to the Instagram Image Uploader Bot! Please enter your Instagram username and password in the format: /login username password')async def login(update: Update, context: CallbackContext) -> None:    args = context.args    if len(args) != 2:        await update.message.reply_text('Please provide your Instagram username and password in the format: /login username password')        return    username = 'my_username '# i tried with @ and without @    password = 'my_password'    context.user_data['username'] = username    context.user_data['password'] = password    await update.message.reply_text(f'Thank you {username}! Now send me an image to upload to Instagram.')async def handle_image(update: Update, context: CallbackContext) -> None:    if 'username' not in context.user_data or 'password' not in context.user_data:        await update.message.reply_text('Please login first using /login username password')        return    file_id = update.message.photo[-1].file_id    file = context.bot.get_file(file_id)    file.download('image.jpg')    # Upload image to Instagram    bot.upload_photo("image.jpg", caption="Uploaded from Telegram bot")    # Send a message indicating successful upload    await update.message.reply_text("Image uploaded to Instagram successfully!")async def main():    application = Application.builder().token(TELEGRAM_TOKEN).build()  # Using Application from telegram.ext    start_handler = CommandHandler('start', start)    login_handler = CommandHandler('login', login)  # Removed pass_args=True    application.add_handler(start_handler)    application.add_handler(login_handler)    application.add_handler(MessageHandler(Filters.photo, handle_image))  # Handle image messages    try:        await application.run_polling()  # Using run_polling method of Application    finally:        await application.shutdown()        await asyncio.gather(*asyncio.all_tasks())if __name__ == '__main__':    asyncio.run(main())

why i am facing this problem please help methis is error in terminalc:; cd 'c:\Users\hp\Desktop\telegram'; & 'C:\Program Files\Python312\python.exe''c:\Users\hp.vscode\extensions\ms-python.python-2023.22.1\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher''54413''--''C:\Users\hp\Desktop\telegram\f.py'2024-01-26 14:40:41,217 - INFO - Instabot version: 0.117.0 Started2024-01-26 14:40:41,222 - INFO - Not yet logged in starting: PRE-LOGIN FLOW!2024-01-26 14:40:48,775 - ERROR - Request returns 400 error!2024-01-26 14:40:48,776 - INFO - Instagram's error message: The username you entered doesn't appear to belong to an account. Please check your username and tryagain.2024-01-26 14:40:48,777 - INFO - Error type: invalid_user2024-01-26 14:40:48,778 - ERROR - Failed to login go to instagram and change your password2024-01-26 14:40:48,778 - INFO - Username or password is incorrect.PS C:\Users\hp\Desktop\telegram>


Viewing all articles
Browse latest Browse all 13891

Trending Articles