-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreverse-search.py
More file actions
76 lines (72 loc) · 2.97 KB
/
reverse-search.py
File metadata and controls
76 lines (72 loc) · 2.97 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
import sys
import time
import requests
import json
import telepot
import re
import tweepy
import subprocess
import os
import string
import random
from datetime import datetime
from telepot.loop import MessageLoop
import wget
# IMGUR CREDENTIALS
client_id = "PUT YOUR IMGUR CLIENT ID HERE" # put your client ID here
headers = {'Authorization': 'Client-ID ' + client_id}
# TELEGRAM CREDENTIALS
TOKEN2 = "" #PUT YOUR TELEGGRAM BOT CREDS HERE
# TWITTER CREDENTIALS
auth = tweepy.OAuthHandler("TWITTER API KEY" , "TWITTER API SECRET ")
auth.set_access_token("TWITTER ACCESS TOKEN", "TWITTER ACCESS SECRET")
import tweepy
api = tweepy.API(auth)
#SEARCH ENGINES
baseurl = "GOOGLE: https://images.google.com/searchbyimage?image_url="
yandex = "YANDEX: https://yandex.com/images/search?rpt=imageview&url="
tineye0 = "TINEYE: https://tineye.com/search/?url="
#CODE BEGINS
def handle(msg):
content_type, chat_type, chat_id = telepot.glance(msg)
if content_type == 'photo' and "channel" not in chat_type:
photoz= msg['photo']
letters = string.ascii_letters
name = ''.join(random.choice(letters) for i in range(10))
for i in photoz:
fileid = i['file_id']
qqq = bot.getFile(fileid)
path = qqq['file_path']
url = "https://api.telegram.org/file/bot" + TOKEN2 + "/" + path
if os.path.exists(str(name) + ".jpg"):
os.remove(str(name) + ".jpg")
wget.download(url, str(name) + ".jpg")
with open(str(name) + ".jpg", "rb") as imagefile:
filetoupload = imagefile.read()
qq = requests.post("https://api.imgur.com/3/upload.json", data= {"image": filetoupload} ,headers=headers)
pp = qq.json()
imgurdata = pp['data']
imgurlink = imgurdata['link']
bot.sendMessage(chat_id, str(baseurl) + str(imgurlink) + "\n\n" + str(yandex) + str(imgurlink) + "\n\n" + str(tineye0) + imgurlink ,disable_web_page_preview=True)
imagefile.close()
if os.path.exists(str(name) + ".jpg"):
os.remove(str(name) + ".jpg")
elif content_type == 'text':
try:
a = msg['text']
a = re.findall(r'[0-9]{10,25}',a)[-1]
tweet = api.get_status(a, tweet_mode="extended")._json
tweet = tweet['entities']
tweet = tweet['media'][0]
tweet = tweet['media_url_https']
yandex1 = "YANDEX: https://yandex.com/images/search?rpt=imageview&url=" + tweet
tieye = "TINEYE: https://tineye.com/search/?url=" + tweet
tweet = "GOOGLE: https://images.google.com/searchbyimage?image_url=" + tweet
bot.sendMessage(chat_id,str(tweet) + "\n\n" + str(tieye) + "\n\n" + str(yandex1),disable_web_page_preview=True)
except:
pass
bot = telepot.Bot(TOKEN2)
MessageLoop(bot, handle).run_as_thread()
print('\n' + 'Listening..')
while 1:
time.sleep(10)