-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmeme.py
More file actions
89 lines (58 loc) · 2.79 KB
/
meme.py
File metadata and controls
89 lines (58 loc) · 2.79 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
85
86
87
88
89
import logging
import praw
import random
from telegram import Update
from telegram.ext import Updater, CommandHandler, CallbackContext
import threading
PRAW_CLIENT_ID ="MhGsIxv8rghQ0Q"
PRAW_CLIENT_SECRET = "d55OpECjc3c0ZJXZnFMgZmnLQGWUoQ"
PRAW_USERAGENT = "erun bot V1.0 by /u/e_run_pie"
reddit = praw.Reddit(client_id=PRAW_CLIENT_ID,
client_secret=PRAW_CLIENT_SECRET,
user_agent=PRAW_USERAGENT)
#"dankvideos","youtubehaiku""MemeEconomy" ,
def get_memes_urls():
req_subreddits = ["memes", "dankmemes","ComedyCemetery","PrequelMemes","ProRetardMemes","Animemes","meme","4PanelCringe","dndmemes","ProgrammerHumor"] # subreddits
meme_list = []
for req_subreddit in req_subreddits:
subreddit = reddit.subreddit(req_subreddit)
for submission in subreddit.hot():
meme_list.append(
["https://reddit.com" + submission.permalink, submission.title, submission.url])
random.shuffle(meme_list) # to shuffle obtained posts
return meme_list[:1]
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO
)
logger = logging.getLogger(__name__)
def start(update: Update, context: CallbackContext) -> None:
update.message.reply_text('Pls do not start the bot this bot is not for public use !')
def status(update: Update, context: CallbackContext) -> None:
update.message.reply_text("bot is online ! be happy ")
restrict = ['https://reddit.com/r/ProRetardMemes/comments/4wmato/fuc_k/' , 'https://reddit.com/r/ProRetardMemes/comments/bn90to/ᵢ_ₐ_ᵣₑₐᵣd_ᵢ_ₐ_ᵣₒfₑᵢₒₐ_ᵣₑₐᵣd_ᵢ_ᵢᵣₑd_fₒᵣ_ₑₒₑ_ₒ_fᵤfᵢ/']
event = threading.Event()
def meme(update: Update, context: CallbackContext):
while True :
url_caption_list = get_memes_urls()
for url_caption in url_caption_list:
url = url_caption[0]
img_url = url_caption[2]
img_caption = url_caption[1]
context.bot.send_photo(chat_id='@redditmemee', photo = img_url, caption = img_caption +'\nSource : ' + url +'\n- @redditmemee -' )
waitlist=[900,1800,3600,450]
event.wait(random.choice(waitlist))
def main():
updater = Updater("1716073347:AAEqs18P2-oe5oPWVmzUMdpX_RbZMJQeAAw")
dispatcher = updater.dispatcher
limit=[]
if not limit:
dispatcher.bot.send_message( chat_id='@fadfafd' ,text = 'i am online do not forget to run me again ;) ')
a=1
limit.append(a)
dispatcher.add_handler(CommandHandler("start", start, run_async=True))
dispatcher.add_handler(CommandHandler("status", status, run_async=True))
dispatcher.add_handler(CommandHandler("memesecret", meme, run_async=True))
updater.start_polling()
updater.idle()
if __name__ == '__main__':
main()