Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import telebot
- import sys
- import time
- import os
- import shutil
- import requests
- requests.packages.urllib3.disable_warnings()
- TOKEN = "138599838:AAHKmwC2zOge47XhAQmMCAjU4pgGHPlzxU0"
- bot = telebot.TeleBot(TOKEN)
- administrador = 22784456
- bot.send_message(administrador, "Bot started.")
- def listener(msg):
- for m in msg:
- cid = m.chat.id
- if m.content_type == "photo":
- time.sleep(2)
- #fileid = m.photo.file_id
- time.sleep(2)
- file_info = bot.get_file(m.photo[0].file_id)
- #print file_info
- #filedown = requests.get('https://api.telegram.org/file/bot{0}/{1}'.format(API_TOKEN, file_info.file_path))
- #filedown = bot.download_file(file_info.file_path)
- with open("photo3.jpg","wb") as download:
- filedown = bot.download_file(file_info.file_path)
- download.write(filedown)
- print "OK!"
- #with open("photo3.jpg","wb") as download:
- # filedown.raw.decode_content = True
- # shutil.copyfileobj(filedown.raw, download)
- #with open("photo3.jpg","wb") as download:
- # for chunk in filedown.iter_content():
- # download.write(chunk)
- # download.close()
- if m.content_type == "text":
- bot.send_message(cid, "BOT OK!")
- bot.set_update_listener(listener)
- bot.polling()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement