forked from idooo/pancake-hipchat-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ some functions were ported to plugins
- Loading branch information
Showing
13 changed files
with
250 additions
and
398 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 |
---|---|---|
|
@@ -39,3 +39,5 @@ nosetests.xml | |
conf/*.conf | ||
|
||
nohup.out | ||
|
||
conf/bot_.py |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import random | ||
|
||
from arnold_phrases import ARNOLD_PHRASES | ||
|
||
class ArnoldPlugin(): | ||
|
||
help = "Arnold Schwarzenegger's phrase (/! name)" | ||
command = "!" | ||
|
||
@staticmethod | ||
def response(mentioned_user, random_user): | ||
|
||
phrase = random.choice(ARNOLD_PHRASES) | ||
|
||
if "{}" not in phrase: | ||
phrase = "{}, " + phrase | ||
|
||
username = mentioned_user | ||
|
||
if not username: | ||
username = random_user | ||
|
||
return phrase.format(username) |
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import re | ||
import requests | ||
|
||
class CatGIFPlugin(): | ||
|
||
help = "Post a random cat gif" | ||
command = "cat" | ||
|
||
def __init__(self): | ||
self.RE_URL = re.compile("<url>([^<]*)</url>", re.MULTILINE + re.IGNORECASE) | ||
|
||
def response(self): | ||
message = "Can't connect to cat API =(" | ||
params = {'format': 'xml', 'type': 'gif'} | ||
|
||
r = requests.get('http://thecatapi.com/api/images/get', params=params) | ||
|
||
if r.status_code == 200: | ||
response = r.text | ||
|
||
res = re.search(self.RE_URL, response) | ||
if res: | ||
message = res.groups()[0] | ||
|
||
return message |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import requests | ||
|
||
class GiphyPlugin(): | ||
|
||
help = "Get a random gif, with a optional search term (/gif keyboard cat)" | ||
command = "gif" | ||
|
||
@staticmethod | ||
def response(message): | ||
search_values = message.split('/gif', 1) | ||
tags = '' | ||
if len(search_values) == 2: | ||
tags = '+'.join(search_values[1].split()) | ||
|
||
r = requests.get('http://api.giphy.com/v1/gifs/random?api_key=dc6zaTOxFJmzC&tag=' + tags) | ||
|
||
if r.status_code == 200: | ||
response = r.json() | ||
return response['data']['image_url'] | ||
|
||
else: | ||
return "Can't connect to giphy API =(" |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import random | ||
|
||
from lego_quotes import LEGO_QUOTES | ||
|
||
class LegoPlugin(): | ||
|
||
help = "LEGO Movie quote's (/lego name)" | ||
command = "lego" | ||
|
||
@staticmethod | ||
def response(mentioned_user, random_user): | ||
|
||
phrase = random.choice(LEGO_QUOTES) | ||
|
||
if "{}" not in phrase: | ||
phrase = "{}, " + phrase | ||
|
||
username = mentioned_user | ||
|
||
if not username: | ||
username = random_user | ||
|
||
return phrase.format(username) |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.