-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathhook.py
73 lines (66 loc) · 2.77 KB
/
hook.py
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
import requests
import re
import os.path
from os import path
from dotenv import load_dotenv
from facebook_scraper import get_posts
from discord_webhook import DiscordWebhook, DiscordEmbed
def fl(name):
if path.exists(name) !=True:
f = open(name, "a")
f.close()
def routiney():
fl('r.txt')
fl('hook.txt')
f=open('hook.txt','r')
f=f.read()
hooks=f.split()
total=len(f)
if total==0:
return
for post in get_posts('officialroutineofnepalbanda', pages=1):
time=str(post['post_id'])
f = open("r.txt", "r")
prev=f.read()
old=re.search(time, prev)
if old==None:
if(str(post['video'])!='None'):
webhook = DiscordWebhook(username='Routiney', avatar_url='https://pbs.twimg.com/profile_images/777188003445739521/t5GNGfAc_400x400.jpg', url=hooks, content=str(post['text'])+'\n<'+str(post['post_url'])+'>\n'+str(post['video']))
webhook.execute()
continue
webhook = DiscordWebhook(username='Routiney', avatar_url='https://pbs.twimg.com/profile_images/777188003445739521/t5GNGfAc_400x400.jpg', url=hooks)
embed = DiscordEmbed(description=str(post['text']))
embed.set_author(name='Routiney', url=post['post_url'], icon_url='https://pbs.twimg.com/profile_images/777188003445739521/t5GNGfAc_400x400.jpg')
img = post['images']
try:
imgcount=len(img)
if(imgcount>2):
webhook.add_embed(embed)
webhook.execute()
for imgs in post['images']:
webhook = DiscordWebhook(username='Routiney', avatar_url='https://cdn.discordapp.com/app-icons/786534057437691914/8dd876fd77d51452a5e3b3df4bc0ce18.png?size=256', url=hooks)
embed = DiscordEmbed(description='\u200b')
embed.set_image(url=imgs)
webhook.add_embed(embed)
webhook.execute()
else:
try:
embed.set_image(url=img[1])
embed.set_thumbnail(url=img[0])
except:
embed.set_image(url=post['image'])
embed.set_footer(text='Blah Blah Blah ...')
webhook.add_embed(embed)
response = webhook.execute()
except:
embed.set_image(url=post['image'])
webhook.add_embed(embed)
webhook.execute()
last=str(post['time'])
f = open("r.txt", "a")
f.write(last)
f.close()
ok()
def ok():
print('WORKEDDDD !!!!!!')
routiney()