Last active
July 26, 2022 07:08
-
-
Save foxlet/ead80f322d533acbb9b0 to your computer and use it in GitHub Desktop.
Snoovatars
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
from lxml import html | |
import requests | |
from cloudbot import hook | |
from cloudbot.util import timeformat, formatting | |
# A nice user agent for use with Reddit | |
headers = {'User-Agent': 'CloudBot/dev 1.0 - CloudBot Refresh by lukeroge'} | |
@hook.command | |
def snoovatar(text): | |
nickname = text | |
url = "http://reddit.com/user/{}/snoo/.json".format(nickname) | |
# The Reddit API will not play nice if it doesn't identify with headers... | |
r = requests.get(url, headers=headers) | |
data = r.json() | |
print(str(data)) | |
if '{}' in str(data): | |
return "http://reddit.com/user/{}/snoo/".format(nickname) | |
else: | |
return "{} has no Snoovatar.".format(nickname) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment