def main(): with open("token.txt") as f: token = f.readline().strip() bot = telebot.TeleBot(token) @bot.message_handler(commands=['start']) def send_welcome(message): bot.reply_to(message, "Moin") @bot.message_handler(commands=["help", "h"]) def help(m): bot.reply_to(m, "Available **commands** are:\n* start\n* help\n* spam\n* r * reddit * meme\n") #TODO find out why parse mode does not work #now we can import reddit.init(bot) hhInteract.init(bot) reminder.init(bot) bot.polling()
if arg.startswith("debug="): responseWhitelist = arg[6:].split(',') elif arg == "noSearchComments": noSearchComments = True log.debug("Comment searching disabled") elif arg == "noSearchPosts": noSearchPosts = True log.debug("Post searching disabled") elif arg == "noRespondMessages": noRespondMessages = True log.debug("Message responses disabled") else: log.error("No user specified, aborting") sys.exit(0) if not reddit.init(log, responseWhitelist, user): sys.exit(0) database.init() signal.signal(signal.SIGINT, signal_handler) if once: sys.exit(0) errors = [] i = 1 while True: log.debug("Starting run")
user = None if len(sys.argv) >= 2: user = sys.argv[1] for arg in sys.argv: if arg == 'once': once = True elif arg == 'debug': debug = True elif arg == 'shortQuarter': globals.quarterLength = 30 else: log.error("No user specified, aborting") sys.exit(0) if not reddit.init(user): sys.exit(0) wiki.loadPages() index.init() while True: try: for message in reddit.getMessageStream(): startTime = time.perf_counter() log.debug("Processing message") wiki.loadPages() try:
from media import MediaObject import reddit reddit.init() listOfImgHosts = ['imgur', 'gfycat', 'gyazo', 'i.redd.it'] # Determine if a link is an image def isImage(post): for host in listOfImgHosts: if host in post.url: return True return False # Class for data from reddit class RedditObject(MediaObject): def __init__(self, title, image, link, content=""): MediaObject.__init__(self, title, image, link, content) # Determines if a post is def filterPost(postData, allowVideo=False, allowStickied=False): # Disallow stickied posts if postData.stickied and not allowStickied: return False if postData.is_video and not allowVideo: return False return True