-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #118 from LanceMaverick/dashboard-enhancements
Added toJSON methods to Commands and Beards.
- Loading branch information
Showing
10 changed files
with
69 additions
and
478 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,49 @@ | ||
#show spacecats test plugin | ||
# show spacecats test plugin | ||
# Adapted from work by LanceMaverick | ||
from os.path import basename | ||
import random | ||
import logging | ||
from urllib.request import urlopen | ||
import telepot | ||
import telepot.aio | ||
from skybeard.beards import BeardChatHandler | ||
from skybeard.predicates import regex_predicate | ||
from skybeard.decorators import admin | ||
|
||
|
||
class PostCats(BeardChatHandler): | ||
__userhelp__ = """ | ||
Say give me spacecats or show me spacecats if you want | ||
to, well, see cats in space.""" | ||
|
||
__commands__ = [ | ||
(regex_predicate('(give|show) me spacecats'), 'send_cat', | ||
"Sends a spacecat image"), | ||
] | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.register_command( | ||
regex_predicate('(give|show) me spacecats'), self.send_cat) | ||
|
||
|
||
async def send_cat(self, msg): | ||
cat_photos= [ | ||
'http://i.imgur.com/bJ043fy.jpg', | ||
'http://i.imgur.com/iFDXD5L.gif', | ||
'http://i.imgur.com/6r3cMsl.gif', | ||
'http://i.imgur.com/JpM5jcX.jpg', | ||
'http://i.imgur.com/r7swEJv.jpg', | ||
'http://i.imgur.com/vLVbiKu.jpg', | ||
'http://i.imgur.com/Yy0TCXA.jpg', | ||
'http://i.imgur.com/2eV7kmq.gif', | ||
'http://i.imgur.com/rnA769W.jpg', | ||
'http://i.imgur.com/08mxOAK.jpg', | ||
'http://i.imgur.com/Ct5GsQn.jpg', | ||
] | ||
cat_photos = [ | ||
'http://i.imgur.com/bJ043fy.jpg', | ||
'http://i.imgur.com/iFDXD5L.gif', | ||
'http://i.imgur.com/6r3cMsl.gif', | ||
'http://i.imgur.com/JpM5jcX.jpg', | ||
'http://i.imgur.com/r7swEJv.jpg', | ||
'http://i.imgur.com/vLVbiKu.jpg', | ||
'http://i.imgur.com/Yy0TCXA.jpg', | ||
'http://i.imgur.com/2eV7kmq.gif', | ||
'http://i.imgur.com/rnA769W.jpg', | ||
'http://i.imgur.com/08mxOAK.jpg', | ||
'http://i.imgur.com/Ct5GsQn.jpg', | ||
] | ||
|
||
try: | ||
choice = random.choice(cat_photos) | ||
await self.sender.sendPhoto((choice.split("/")[-1], urlopen(choice))) | ||
await self.sender.sendChatAction('upload_photo') | ||
await self.sender.sendPhoto( | ||
(basename(choice), urlopen(choice))) | ||
except Exception as e: | ||
logging.error(e) | ||
await self.sender.sendPhoto( | ||
("cat_photo.jpg", | ||
urlopen('http://cdn.meme.am/instances/500x/55452028.jpg'))) | ||
raise e |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters