Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import praw
- import pickle, random, time
- username=""
- password=""
- r=praw.Reddit(user_agent="linux, script on pythonanywhere.com, which likes /r/BlackCats users cats (by /u/ilikeyourblackcat)")
- r.login(username, password)
- subreddit = r.get_subreddit('blackcats')
- with open('blackCatBot.db', 'r') as pickle_in:
- done = pickle.load(pickle_in)
- ''' ---------------------------------------------------------------------------------------------------------------- '''
- ''' These below are the membership groups and their membership customized replies. '''
- ''' ---------------------------------------------------------------------------------------------------------------- '''
- default_replies = ["I like your black cat.", "Nice black cat.", "Your black cat is too cute.", "As dark as a shadow.",
- "What a cute shadow you have!", "Dark as midnight.", "Too cute to be a superstition!",
- "Wow. This is like I'm looking at my own little sweetie!", "I am the night. I am a blackcat!",
- "Velvety paws! So cute!", "Cuddle Bug!", "Now THAT is an adoring look!", "Cutie pie! Black cats are best cats.",
- "Too purrfect!", "Have you noticed that black cats are more relaxed than other cats?",
- "People are just jealous of the gorgeous sable color.", "It's so hard to get pictures of black cats",
- "What a cute baby.", "Black Velvet! Purrrrrfect!", "Look at that little face! Precious.",
- "I'm convinced black cats are solar powered and basking is their way of recharging their batteries for late night crazies.",
- "Is your cat solid black, or does it have some different colors in its undercoat? Gorgeous!",
- "Black cats love the sun, don't they!?", "Black cats just have the best little personalities. Too cute!",
- "Look at those eyes! So beautiful!", "Mesmerizing!", "Your cat is exactly like my baby! They could be twins!",
- "Cutie pie!", "What a cutie!", "Bellyrub!", "What a beautiful sweet kitty.", "Cats are made of stars.",
- "I love the floofy tail!"]
- ''' ---------------------------------------------------------------------------------------------------------------- '''
- XX = ["She", "Girl", "Pretty", "Ms.", "Ms", "Miss", "Mrs.", "Mrs", "Lady"]
- XY = ["Mr.", "Mr", "Handsome", "His", "Gentleman", "Gentlemen", "He"]
- XXreply = ["Her fur is cool, and it's black.", "She is quite the charmer.", "What a lovely lass there!",
- "She is a pretty black cat.", "She is so beautiful!", "So majestic. I want 8 of her!."]
- XYreply = ["His fur is cool, and it's black.", "He is quite the handsome boy.", "What a gentleman there!",
- "He is a handsome black cat.", "Very cute! Wish I had a tiny little black guy just like him.", "So majestic. I want 8 of him!"]
- ''' ---------------------------------------------------------------------------------------------------------------- '''
- #Regulars = ["Kuro", "Spam", "Felix", "Xander", "Fritz", "Ent"]
- #RegularReply = ["It is always a pleasure to see %s on Black Cats.", "Good to see you again %s!"]
- Kuro = ["Kuro"]
- KuroReply = ["It is always a pleasure to see Kuro on Black Cats.", "Good to see you again Kuro!",
- "Kuro, it's an honor to see you again!", "Kuro, have you been getting more vocal?",
- "I wish I had a kitty just like Kuro!"]
- Spam = ["Spam"]
- SpamReply = ["It is always a pleasure to see Spam on Black Cats.", "Good to see you again Spam!",
- "Spam, it's an honor to see you again!"]
- Felix = ["Felix"]
- FelixReply = ["It is always a pleasure to see Felix on Black Cats.", "Good to see you again Felix!",
- "Felix, it's an honor to see you again!"]
- Xander = ["Xander"]
- XanderReply = ["It is always a pleasure to see Xander on Black Cats.", "Good to see you again Xander!",
- "Xander, it's an honor to see you again!"]
- Ent = ["Ent"]
- EntReply = ["It is always a pleasure to see Ent on Black Cats.", "Good to see you again Ent!",
- "Ent, it's an honor to see you again!"]
- Fritz = ["Fritz"]
- FritzReply = ["Oh you silly Fritz, what are you up to this time!?", "Fritz is a special cat.",
- "Fritz, you look like you could use a kitty breakfast taco!", "I wish I had a kitty just like Fritz!"]
- ''' ---------------------------------------------------------------------------------------------------------------- '''
- def Word(inTitle, inGroup):
- alphabet_space = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
- 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ']
- preNewString = []
- for i in inTitle.lower():
- if i in [j.lower() for j in alphabet_space]:
- preNewString.append(i)
- cleanString = ''.join(preNewString)
- titleAsList = cleanString.split(' ')
- inGroup = [i.lower() for i in inGroup]
- for i in titleAsList:
- if i in inGroup:
- return True
- def main():
- submissions = subreddit.get_new()
- for submission in submissions:
- if submission.id not in done:
- done.append(submission.id)
- with open('blackCatBot.db', 'w') as pickle_out:
- pickle.dump(done, pickle_out)
- if submission.is_self == True:
- if Word(submission.title, Fritz) == True:
- submission.add_comment(random.choice(FritzReply))
- elif Word(submission.title, Kuro) == True:
- submission.add_comment(random.choice(KuroReply))
- elif Word(submission.title, Spam) == True:
- submission.add_comment(random.choice(SpamReply))
- elif Word(submission.title, Felix) == True:
- submission.add_comment(random.choice(FelixReply))
- elif Word(submission.title, Xander) == True:
- submission.add_comment(random.choice(XanderReply))
- elif Word(submission.title, Ent) == True:
- submission.add_comment(random.choice(EntReply))
- elif Word(submission.title, XX) == True:
- submission.add_comment(random.choice(XXreply))
- elif Word(submission.title, XY) == True:
- submission.add_comment(random.choice(XYreply))
- else:
- submission.add_comment(random.choice(default_replies))
- if __name__ == "__main__":
- while True:
- try:
- main()
- except Exception as e:
- log="Error: "+str(e)+" @ "+str(time.time())
- with open('blackCatBot.log', 'a') as f:
- f.writelines(log)
- print "Sleeping for 10 minutes."
- time.sleep(600)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement