Skip to content

Commit

Permalink
fixed class name type
Browse files Browse the repository at this point in the history
  • Loading branch information
LanceMaverick committed Feb 4, 2017
1 parent a3c4d04 commit f5eb879
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions beards/corgibase/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#show spacecats test plugin
#corgibase plugin
# Adapted from work by LanceMaverick

import random
import logging
from urllib.request import urlopen
Expand All @@ -11,7 +10,7 @@
from skybeard.predicates import regex_predicate
from . import config

class CorrgiBase(BeardChatHandler):
class CorgiBase(BeardChatHandler):
__userhelp__ = """
Say give me corgis or show me corgis to see some corgis!"""

Expand All @@ -28,20 +27,22 @@ async def send_corgi(self, msg):
user_agent = config.user_agent,
)
subreddit = reddit.subreddit('corgis')
hot_posts = subreddit.hot(limit=10)
hot_posts = subreddit.top(time_filter = 'all', limit=100)
url_list = [post.url for post in hot_posts]


try:
choice = random.choice(url_list)
extensions = ['.jpg', '.jpeg', '.png', '.gif']
if any (ext in choice for ext in extensions):
await self.sender.sendPhoto((choice.split("/")[-1], urlopen(choice)))
await self.sender.sendPhoto((
choice.split("/")[-1],
urlopen(choice)))
else:
await self.sender.sendMessage(choice)
except Exception as e:
logging.error(e)
await self.sender.sendPhoto(
("cat_photo.jpg",
urlopen('http://cdn.meme.am/instances/500x/55452028.jpg')))
await self.sender.sendPhoto((
"cat_photo.jpg",
urlopen('http://cdn.meme.am/instances/500x/55452028.jpg')))

File renamed without changes.

0 comments on commit f5eb879

Please sign in to comment.