Browse Source

added 420

master
Angerstoner 6 years ago
parent
commit
b4086b4982
  1. 27
      reddit.py
  2. 8
      schneiderbot.py

27
reddit.py

@ -1,7 +1,8 @@
import praw import praw
from prawcore import exceptions from prawcore import exceptions
import requests import requests
import random
four_twenty_groups = []
def get_post_type(url): def get_post_type(url):
@ -54,13 +55,21 @@ def get_reddit_post(sub, is_image_post=False):
return post return post
# def fourtwenty(bot, update):
def fourtwenty():
stoner_subs = ["StonerThoughts"]
# post = get_reddit_post(random.randint(0, len(stoner_subs) - 1))
post = get_reddit_post("StonerThoughts")
print(post.title)
print(post.text)
def toggle_four_twenty(bot, update):
chat_id = update.message.chat_id
if chat_id in four_twenty_groups:
four_twenty_groups.remove(chat_id)
update.message.reply_text("You killed the fire!")
else:
four_twenty_groups.append(update.message.chat_id)
update.message.reply_text("420 blaze it!")
def four_twenty(bot, update):
for group_id in four_twenty_groups:
post = get_reddit_post('trees', True)
bot.send_photo(chat_id=group_id, photo=post.url, caption=post.title)
def wrong_dog(bot, update): def wrong_dog(bot, update):
@ -93,5 +102,3 @@ def reddit_img(bot, update, args):
except AttributeError: except AttributeError:
update.message.reply_text(post) update.message.reply_text(post)
print("ERROR") print("ERROR")
# fourtwenty()y

8
schneiderbot.py

@ -1,6 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import datetime
import logging import logging
import random import random
@ -10,7 +10,7 @@ from telegram import ParseMode
from telegram.ext import Updater, CommandHandler from telegram.ext import Updater, CommandHandler
from coding_love import send_coding_love_gif from coding_love import send_coding_love_gif
from reddit import wrong_dog, hamster, reddit, reddit_img
from reddit import wrong_dog, hamster, reddit, reddit_img, toggle_four_twenty, four_twenty
from schneiderbot_twitter import toggle_pepito_for_group, check_pepito_and_post_auto, check_pepito_and_post_manually from schneiderbot_twitter import toggle_pepito_for_group, check_pepito_and_post_auto, check_pepito_and_post_manually
from db import Db from db import Db
from mensa import mensa from mensa import mensa
@ -209,6 +209,7 @@ def init_commands(dp):
dp.add_handler(CommandHandler("reddit_img", reddit_img, pass_args=True)) dp.add_handler(CommandHandler("reddit_img", reddit_img, pass_args=True))
dp.add_handler(CommandHandler("pepito", check_pepito_and_post_manually)) dp.add_handler(CommandHandler("pepito", check_pepito_and_post_manually))
dp.add_handler(CommandHandler("tpepito", toggle_pepito_for_group)) dp.add_handler(CommandHandler("tpepito", toggle_pepito_for_group))
dp.add_handler(CommandHandler("lightitup", toggle_four_twenty))
def main(): def main():
@ -224,7 +225,8 @@ def main():
dp = updater.dispatcher dp = updater.dispatcher
init_commands(dp) init_commands(dp)
job_minute = jq.run_repeating(check_pepito_and_post_auto, interval=180, first=0)
jq.run_repeating(check_pepito_and_post_auto, interval=180, first=0)
jq.run_daily(four_twenty, datetime.time(4, 20, 0), days=(0, 1, 2, 3, 4, 5, 6))
# on different commands - answer in Telegram # on different commands - answer in Telegram

Loading…
Cancel
Save