[Reddit BOT] A Homo-Erotic FluffyPony Loving Comment Bot in Python ; ) [Monero]

in #cryptocurrency7 years ago

<center> Homo-Erotic Fluffy lovins' </center>

FluffyPony, also known as  Riccardo Spagni, Monero's most infamous, and arguably most essential developer, is a icon of the community he supports. I'm all for privacy and I find Monero's ideas on how to make that happen using Ring Signature technology, almost sexual. Knowing I can move money around, no one knowing how much or how few, just rustles my jimmies to the point, I had to make a tribute to the man, the myth, and quite possibly the legend that is Riccardo.

This code is messy, I'm relatively new to Python and what you'll see is by no means best coding practices.  Although the code does work. It should not be imitated by anybody who wants to remain sane trying to mimic my experience. The bot searches for words related to "Fluffypony" in a few different variations and has up to 4 responses randomly chosen.  custom config.py file will be needed to run but, that can easily be emulated. Enough is enough, take a look. :)

#A reddit bot! for the Monero forums ;)
from random import randint
import praw
import config
import time
import os

def bot_login():
	r = praw.Reddit(username = config.username,
			password = config.password,
			client_id = config.client_id,
			client_secret = config.client_secret,
			user_agent = "FluffyPonerz Fairy 0.1")
			#returns the praw.reddit instance with our login information
			#and allows use to reference it in run_bot
	return r

def run_bot(r, commentsreplied):
	print('Initalizing.... Looking for comments.')
	
	key_words = ['fluffypony' 'fluffyponiza', 'fluffy', 'pony', 'ponie', 'fluffyhorse', 'exitscam']
	for comment in r.subreddit('Monero').comments(limit=None):
		if any(subs in comment.body for subs in key_words) and comment.id not in comments_replied_too and not comment.author == r.user.me():
			#Picks a random number for our replies
			x = randint(1,5)
			if x == 1:
				# comment.reply is the reply to the comment that contains key_words
				comment.reply("Hello! I'm Carry! The Fluffy Fairy! Here take this [Picture :D:D](http://i.imgur.com/Ys4UOXd.jpg)")
				#adds the comment.id to the comments_replied_too list
				comments_replied_too.append(comment.id)
				print("Commented on post: ", comment.id)
				#this small bit of code opens our txt file as Append then adds the comment.id and a newline then closes
				f = open('fluffybotCIDs.txt', 'a')
				f.write(comment.id + "\n")
				f.close()
				print("Sleeping for 25 seconds...")
				#imported from time, sleep basically makes the program wait for a defined amount of seconds time.sleep(seconds)
				time.sleep(25)
			elif x == 2:
				# comment.reply is the reply to the comment that contains key_words
				comment.reply("Hello! I'm Carry! The Fluffy Loving Fairy! Here take this [Photo :D:D](http://i.imgur.com/8jMBGVo.jpg)")
				#adds the comment.id to the comments_replied_too list
				comments_replied_too.append(comment.id)
				print("Commented on post: ", comment.id)
				#this small bit of code opens our txt file as Append then adds the comment.id and a newline then closes
				f = open('fluffybotCIDs.txt', 'a')
				f.write(comment.id + "\n")
				f.close()
				print("Sleeping for 25 seconds...")
				time.sleep(25)
			elif x == 3:
				# comment.reply is the reply to the comment that contains key_words
				comment.reply("Hello! I'm Carry your favorite Fluffy Fairy! He's a good guy, trust me. Really good.... ;)")
				#adds the comment.id to the comments_replied_too list
				comments_replied_too.append(comment.id)
				print("Commented on post: ", comment.id)
				#this small bit of code opens our txt file as Append then adds the comment.id and a newline then closes
				f = open('fluffybotCIDs.txt', 'a')
				f.write(comment.id + "\n")
				f.close()
				print("Sleeping for 25 seconds...")
				time.sleep(25)
			elif x == 4:
				# comment.reply is the reply to the comment that contains key_words
				comment.reply("Hello! I'm Carry the FluffyPony FAN Fairy! I hope one day, fluffers will lay in bed with me, he can put a ringCT around my wand anyday ;)")
				#adds the comment.id to the comments_replied_too list
				comments_replied_too.append(comment.id)
				print("Commented on post: ", comment.id)
				#this small bit of code opens our txt file as Append then adds the comment.id and a newline then closes
				f = open('fluffybotCIDs.txt', 'a')
				f.write(comment.id + "\n")
				f.close()
				print("Sleeping for 25 seconds...")
				time.sleep(25)
			elif x == 5:
				# comment.reply is the reply to the comment that contains key_words
				comment.reply("Hello! I'm Carry the Fluffypony evangalist! I'll get down and pray any day :D:D:D:D")
				#adds the comment.id to the comments_replied_too list
				comments_replied_too.append(comment.id)
				print("Commented on post: ", comment.id)
				#this small bit of code opens our txt file as Append then adds the comment.id and a newline then closes
				f = open('fluffybotCIDs.txt', 'a')
				f.write(comment.id + "\n")
				f.close()
				print("Sleeping for 25 seconds...")
				time.sleep(25)
			else:
				#If something wrong happens it prints a error and returns False to end the loop
				print("Error Error, I brokes sums hows :(")
				return False
	
def Read_CommentID():
	# if the fluffybotCIDs.txt file dosnt exist makes a list 
	if not os.path.isfile('fluffybotCIDs.txt'):
		comments_replied_too = []
	#if the text file is found, else: opens in read mode, reads the file then splits the words
	#based on the \n new line, character
	else:
		f = open('fluffybotCIDs.txt', 'r')
		comments_replied_too = f.read()
		comments_replied_too = comments_replied_too.split("\n")
	#returns the comments_replied_too.split("\n") command
	return comments_replied_too
	
r = bot_login()
#sets comments replied to to the Read_CommentID(function)
comments_replied_too = Read_CommentID()	
while True:
    run_bot(r, comments_replied_too)


Photo Creds: Big Lambda