formatting everything and adding corsa club to the trackdays command since they finally put their shit on msreg
This commit is contained in:
parent
32bf0f5275
commit
d5f6d87b92
@ -9,97 +9,115 @@ import get_from_reddit
|
|||||||
def get_red_panda():
|
def get_red_panda():
|
||||||
red_panda = None
|
red_panda = None
|
||||||
while not red_panda:
|
while not red_panda:
|
||||||
red_panda = requests.get('https://some-random-api.ml/img/red_panda').json()['link']
|
red_panda = requests.get("https://some-random-api.ml/img/red_panda").json()[
|
||||||
return red_panda
|
"link"
|
||||||
|
]
|
||||||
|
return red_panda
|
||||||
|
|
||||||
|
|
||||||
def get_panda():
|
def get_panda():
|
||||||
panda = None
|
panda = None
|
||||||
while not panda:
|
while not panda:
|
||||||
panda = requests.get('https://some-random-api.ml/img/panda').json()['link']
|
panda = requests.get("https://some-random-api.ml/img/panda").json()["link"]
|
||||||
return panda
|
return panda
|
||||||
|
|
||||||
|
|
||||||
def get_racoon():
|
def get_racoon():
|
||||||
racoon = None
|
racoon = None
|
||||||
while not racoon:
|
while not racoon:
|
||||||
racoon = requests.get('https://some-random-api.ml/img/racoon').json()['link']
|
racoon = requests.get("https://some-random-api.ml/img/racoon").json()["link"]
|
||||||
return racoon
|
return racoon
|
||||||
|
|
||||||
|
|
||||||
def get_fox():
|
def get_fox():
|
||||||
fox = None
|
fox = None
|
||||||
while not fox:
|
while not fox:
|
||||||
fox = requests.get('https://some-random-api.ml/img/fox').json()['link']
|
fox = requests.get("https://some-random-api.ml/img/fox").json()["link"]
|
||||||
return fox
|
return fox
|
||||||
|
|
||||||
|
|
||||||
def get_cat():
|
def get_cat():
|
||||||
cat = None
|
cat = None
|
||||||
while not cat:
|
while not cat:
|
||||||
cat = requests.get('https://some-random-api.ml/img/cat').json()['link']
|
cat = requests.get("https://some-random-api.ml/img/cat").json()["link"]
|
||||||
return cat
|
return cat
|
||||||
|
|
||||||
|
|
||||||
def get_kangaroo():
|
def get_kangaroo():
|
||||||
kangaroo = None
|
kangaroo = None
|
||||||
while not kangaroo:
|
while not kangaroo:
|
||||||
kangaroo = requests.get('https://some-random-api.ml/img/kangaroo').json()['link']
|
kangaroo = requests.get("https://some-random-api.ml/img/kangaroo").json()[
|
||||||
return kangaroo
|
"link"
|
||||||
|
]
|
||||||
|
return kangaroo
|
||||||
|
|
||||||
|
|
||||||
def get_koala():
|
def get_koala():
|
||||||
koala = None
|
koala = None
|
||||||
while not koala:
|
while not koala:
|
||||||
koala = requests.get('https://some-random-api.ml/img/koala').json()['link']
|
koala = requests.get("https://some-random-api.ml/img/koala").json()["link"]
|
||||||
return koala
|
return koala
|
||||||
|
|
||||||
|
|
||||||
def get_dog():
|
def get_dog():
|
||||||
return random.choice([random_sheeb, random_dog, random_dog_reddit])()
|
return random.choice([random_sheeb, random_dog, random_dog_reddit])()
|
||||||
|
|
||||||
|
|
||||||
def get_birb():
|
def get_birb():
|
||||||
return random.choice([random_bird, random_bird_reddit])()
|
return random.choice([random_bird, random_bird_reddit])()
|
||||||
|
|
||||||
|
|
||||||
def random_sheeb():
|
def random_sheeb():
|
||||||
return requests.get(
|
return requests.get("http://shibe.online/api/shibes?count=1&urls=true").text.split(
|
||||||
'http://shibe.online/api/shibes?count=1&urls=true'
|
'"'
|
||||||
).text.split('"')[1]
|
)[1]
|
||||||
|
|
||||||
|
|
||||||
def random_dog():
|
def random_dog():
|
||||||
dog_url = None
|
dog_url = None
|
||||||
while not dog_url:
|
while not dog_url:
|
||||||
dog_url = requests.get('https://dog.ceo/api/breeds/image/random').json()['message']
|
dog_url = requests.get("https://dog.ceo/api/breeds/image/random").json()[
|
||||||
return dog_url
|
"message"
|
||||||
|
]
|
||||||
|
return dog_url
|
||||||
|
|
||||||
|
|
||||||
def random_bird():
|
def random_bird():
|
||||||
bird = None
|
bird = None
|
||||||
while not bird:
|
while not bird:
|
||||||
bird = requests.get('https://some-random-api.ml/img/birb').json()['link']
|
bird = requests.get("https://some-random-api.ml/img/birb").json()["link"]
|
||||||
if 'mp4' in bird[-3:]:
|
if "mp4" in bird[-3:]:
|
||||||
bird = None
|
bird = None
|
||||||
return bird
|
return bird
|
||||||
|
|
||||||
|
|
||||||
def random_dog_reddit():
|
def random_dog_reddit():
|
||||||
return get_from_reddit.get_image(
|
return get_from_reddit.get_image(
|
||||||
[
|
[
|
||||||
'AustralianCattleDog',
|
"AustralianCattleDog",
|
||||||
'GSP',
|
"GSP",
|
||||||
'corgi',
|
"corgi",
|
||||||
'dogpictures',
|
"dogpictures",
|
||||||
'rarepuppers',
|
"rarepuppers",
|
||||||
'tippytaps',
|
"tippytaps",
|
||||||
'vizsla',
|
"vizsla",
|
||||||
'zoomies',
|
"zoomies",
|
||||||
'shiba',
|
"shiba",
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def random_bird_reddit():
|
def random_bird_reddit():
|
||||||
return get_from_reddit.get_image(
|
return get_from_reddit.get_image(
|
||||||
[
|
[
|
||||||
'birbs',
|
"birbs",
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_rat():
|
def get_rat():
|
||||||
return get_from_reddit.get_image('rats')
|
return get_from_reddit.get_image("rats")
|
||||||
|
|
||||||
|
|
||||||
def dale():
|
def dale():
|
||||||
return random.choice(glob.glob('/tmp/dale/*'))
|
return random.choice(glob.glob("/tmp/dale/*"))
|
||||||
|
|
||||||
|
97
app/bf5.py
97
app/bf5.py
@ -1,59 +1,60 @@
|
|||||||
import requests, json, pprint, discord
|
import requests, json, pprint, discord
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
pp = pprint.PrettyPrinter(indent=4)
|
|
||||||
|
|
||||||
def get_player(player):
|
def get_player(player):
|
||||||
player = player.lower()
|
player = player.lower()
|
||||||
url = "https://battlefieldtracker.com/bfv/profile/origin/" + player + "/overview"
|
url = "https://battlefieldtracker.com/bfv/profile/origin/" + player + "/overview"
|
||||||
headers = { 'User-Agent' : 'Mozilla/5.0 (Windows NT 6.1; Win64; x64)' }
|
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64)"}
|
||||||
response = requests.get(url, headers=headers).text
|
response = requests.get(url, headers=headers).text
|
||||||
soup = BeautifulSoup(response, "html.parser")
|
soup = BeautifulSoup(response, "html.parser")
|
||||||
script = soup.find_all("script")
|
script = soup.find_all("script")
|
||||||
|
|
||||||
jsonstring = str(script[1])
|
jsonstring = str(script[1])
|
||||||
jsonstring = jsonstring[33:-131]
|
jsonstring = jsonstring[33:-131]
|
||||||
data = json.loads(jsonstring)
|
data = json.loads(jsonstring)
|
||||||
|
|
||||||
# Get Player Data
|
# Get Player Data
|
||||||
origin_name = 'bfv|origin|' + player
|
origin_name = "bfv|origin|" + player
|
||||||
|
|
||||||
base_stat_blob = data['stats-v2']['standardProfiles'][origin_name]
|
base_stat_blob = data["stats-v2"]["standardProfiles"][origin_name]
|
||||||
account_name = base_stat_blob['platformInfo']['platformUserHandle']
|
account_name = base_stat_blob["platformInfo"]["platformUserHandle"]
|
||||||
avatar_url = base_stat_blob['platformInfo']['avatarUrl']
|
avatar_url = base_stat_blob["platformInfo"]["avatarUrl"]
|
||||||
|
|
||||||
stats_overview = base_stat_blob['segments'][0]['stats']
|
|
||||||
rank = stats_overview['rank']
|
|
||||||
rank_title = rank['metadata']['label']
|
|
||||||
rank_number = rank['displayValue']
|
|
||||||
|
|
||||||
# Build the embed
|
stats_overview = base_stat_blob["segments"][0]["stats"]
|
||||||
embed = discord.Embed(description='-------', color=15105570, type="rich")
|
rank = stats_overview["rank"]
|
||||||
embed.set_thumbnail(url=avatar_url)
|
rank_title = rank["metadata"]["label"]
|
||||||
embed.set_author(name="Battlefield V stats for %s" % account_name)
|
rank_number = rank["displayValue"]
|
||||||
embed.add_field(name="**Rank**", value="%s, %s" % (rank_number, rank_title), inline=False)
|
|
||||||
|
|
||||||
gameplay_stats = [
|
# Build the embed
|
||||||
'scorePerMinute',
|
embed = discord.Embed(description="-------", color=15105570, type="rich")
|
||||||
'kdRatio',
|
embed.set_thumbnail(url=avatar_url)
|
||||||
'assists',
|
embed.set_author(name="Battlefield V stats for %s" % account_name)
|
||||||
'shotsAccuracy',
|
embed.add_field(
|
||||||
'killStreak',
|
name="**Rank**", value="%s, %s" % (rank_number, rank_title), inline=False
|
||||||
'dogtagsTaken',
|
)
|
||||||
'headshots',
|
|
||||||
'longestHeadshot',
|
|
||||||
'heals',
|
|
||||||
'revives',
|
|
||||||
'revivesRecieved',
|
|
||||||
'resupplies',
|
|
||||||
'aceSquad',
|
|
||||||
'wlPercentage',
|
|
||||||
]
|
|
||||||
|
|
||||||
for stat in gameplay_stats:
|
gameplay_stats = [
|
||||||
embed.add_field(name="**%s**" % stats_overview[stat]['displayName'], value=stats_overview[stat]['displayValue'], inline=True)
|
"scorePerMinute",
|
||||||
# embed.add_field(name='Raw value', value=stats_overview[stat]['displayValue'], inline=True)
|
"kdRatio",
|
||||||
# embed.add_field(name='Global Percentile', value=stats_overview[stat]['percentile'], inline=True)
|
"assists",
|
||||||
return embed
|
"shotsAccuracy",
|
||||||
|
"killStreak",
|
||||||
|
"dogtagsTaken",
|
||||||
|
"headshots",
|
||||||
|
"longestHeadshot",
|
||||||
|
"heals",
|
||||||
|
"revives",
|
||||||
|
"revivesRecieved",
|
||||||
|
"resupplies",
|
||||||
|
"aceSquad",
|
||||||
|
"wlPercentage",
|
||||||
|
]
|
||||||
|
|
||||||
# assault_stats = base_stat_blob['segments'][9]
|
for stat in gameplay_stats:
|
||||||
# medic_stats = base_stat_blob['segments'][10]
|
embed.add_field(
|
||||||
|
name="**%s**" % stats_overview[stat]["displayName"],
|
||||||
|
value=stats_overview[stat]["displayValue"],
|
||||||
|
inline=True,
|
||||||
|
)
|
||||||
|
return embed
|
||||||
|
980
app/bot.py
980
app/bot.py
File diff suppressed because it is too large
Load Diff
@ -1,15 +1,22 @@
|
|||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
|
||||||
def download_image(url, path=None):
|
def download_image(url, path=None):
|
||||||
|
|
||||||
request = requests.get(url)
|
request = requests.get(url)
|
||||||
suffix_list = ['jpeg', 'jpg', 'png', 'tif', 'svg',]
|
suffix_list = [
|
||||||
extension = request.headers['content-type'].split('/')[1]
|
"jpeg",
|
||||||
|
"jpg",
|
||||||
|
"png",
|
||||||
|
"tif",
|
||||||
|
"svg",
|
||||||
|
]
|
||||||
|
extension = request.headers["content-type"].split("/")[1]
|
||||||
|
|
||||||
if not path:
|
if not path:
|
||||||
path = "/tmp/image.{}".format(extension)
|
path = "/tmp/image.{}".format(extension)
|
||||||
|
|
||||||
if extension in suffix_list:
|
if extension in suffix_list:
|
||||||
open(path, 'wb').write(requests.get(url).content)
|
open(path, "wb").write(requests.get(url).content)
|
||||||
return path
|
return path
|
||||||
return 'Invalid image format'
|
return "Invalid image format"
|
||||||
|
157
app/corona.py
157
app/corona.py
@ -8,75 +8,113 @@ import requests
|
|||||||
import string
|
import string
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
|
||||||
def get_csv():
|
def get_csv():
|
||||||
git_url = 'https://api.github.com/repos/CSSEGISandData/COVID-19/contents/csse_covid_19_data/csse_covid_19_daily_reports'
|
git_url = "https://api.github.com/repos/CSSEGISandData/COVID-19/contents/csse_covid_19_data/csse_covid_19_daily_reports"
|
||||||
git_blob = requests.get(git_url).json()
|
git_blob = requests.get(git_url).json()
|
||||||
|
|
||||||
today = datetime.datetime.utcnow().date()
|
today = datetime.datetime.utcnow().date()
|
||||||
todays_date = today.strftime('%m-%d-%Y')
|
todays_date = today.strftime("%m-%d-%Y")
|
||||||
yesterday = today - datetime.timedelta(days=1)
|
yesterday = today - datetime.timedelta(days=1)
|
||||||
yesterdays_date = yesterday.strftime('%m-%d-%Y')
|
yesterdays_date = yesterday.strftime("%m-%d-%Y")
|
||||||
|
|
||||||
most_recent = next(filter(lambda x: yesterdays_date in x['name'], git_blob))
|
most_recent = next(filter(lambda x: yesterdays_date in x["name"], git_blob))
|
||||||
file_name = most_recent['name']
|
file_name = most_recent["name"]
|
||||||
download_url = most_recent['download_url']
|
download_url = most_recent["download_url"]
|
||||||
most_recent_csv = "/app/%s" % file_name
|
most_recent_csv = "/app/%s" % file_name
|
||||||
if not os.path.exists(most_recent_csv):
|
if not os.path.exists(most_recent_csv):
|
||||||
print("no local csv found, downloading %s" % file_name)
|
print("no local csv found, downloading %s" % file_name)
|
||||||
r = requests.get(download_url, allow_redirects=True)
|
r = requests.get(download_url, allow_redirects=True)
|
||||||
open(most_recent_csv, 'wb').write(r.content)
|
open(most_recent_csv, "wb").write(r.content)
|
||||||
|
|
||||||
two_days_ago = today - datetime.timedelta(days=2)
|
two_days_ago = today - datetime.timedelta(days=2)
|
||||||
two_days_ago_date = two_days_ago.strftime('%m-%d-%Y')
|
two_days_ago_date = two_days_ago.strftime("%m-%d-%Y")
|
||||||
yesterday_object = next(filter(lambda x: two_days_ago_date in x['name'], git_blob))
|
yesterday_object = next(filter(lambda x: two_days_ago_date in x["name"], git_blob))
|
||||||
yesterday_filename = yesterday_object['name']
|
yesterday_filename = yesterday_object["name"]
|
||||||
yesterday_url = yesterday_object['download_url']
|
yesterday_url = yesterday_object["download_url"]
|
||||||
yesterday_csv = "/app/%s" % yesterday_filename
|
yesterday_csv = "/app/%s" % yesterday_filename
|
||||||
|
|
||||||
if not os.path.exists(yesterday_csv):
|
if not os.path.exists(yesterday_csv):
|
||||||
print("no local csv found, downloading %s" % yesterday_filename)
|
print("no local csv found, downloading %s" % yesterday_filename)
|
||||||
r = requests.get(yesterday_url, allow_redirects=True)
|
r = requests.get(yesterday_url, allow_redirects=True)
|
||||||
open(yesterday_csv, 'wb').write(r.content)
|
open(yesterday_csv, "wb").write(r.content)
|
||||||
|
|
||||||
return most_recent_csv, yesterday_csv
|
return most_recent_csv, yesterday_csv
|
||||||
|
|
||||||
|
|
||||||
def query_csv(csv_path, location):
|
def query_csv(csv_path, location):
|
||||||
series = read_csv(csv_path, header=0, parse_dates=[0], index_col=0, squeeze=True)
|
series = read_csv(csv_path, header=0, parse_dates=[0], index_col=0, squeeze=True)
|
||||||
last_updated = series['Last_Update'].iloc[0]
|
last_updated = series["Last_Update"].iloc[0]
|
||||||
location_query = series.loc[series['Province_State'] == location]
|
location_query = series.loc[series["Province_State"] == location]
|
||||||
if location_query.empty:
|
|
||||||
location_query = series.loc[series['Country_Region'] == location]
|
|
||||||
if location_query.empty:
|
if location_query.empty:
|
||||||
embed = discord.Embed(description="No results found for %s.\n\nPlease enter a valid Country name or US state" % location, color=0x428bca, type="rich")
|
location_query = series.loc[series["Country_Region"] == location]
|
||||||
embed.set_author(name="CSSE at Johns Hopkins University", icon_url='https://www.pngitem.com/pimgs/m/27-270528_johns-hopkins-was-a-founding-member-of-the.png')
|
if location_query.empty:
|
||||||
return embed
|
embed = discord.Embed(
|
||||||
return last_updated, location_query.sum()
|
description="No results found for %s.\n\nPlease enter a valid Country name or US state"
|
||||||
|
% location,
|
||||||
|
color=0x428BCA,
|
||||||
|
type="rich",
|
||||||
|
)
|
||||||
|
embed.set_author(
|
||||||
|
name="CSSE at Johns Hopkins University",
|
||||||
|
icon_url="https://www.pngitem.com/pimgs/m/27-270528_johns-hopkins-was-a-founding-member-of-the.png",
|
||||||
|
)
|
||||||
|
return embed
|
||||||
|
return last_updated, location_query.sum()
|
||||||
|
|
||||||
|
|
||||||
def sum_numbers(location):
|
def sum_numbers(location):
|
||||||
today, yesterday = get_csv()
|
today, yesterday = get_csv()
|
||||||
try:
|
try:
|
||||||
last_updated, yesterday_sum = query_csv(yesterday, location)
|
last_updated, yesterday_sum = query_csv(yesterday, location)
|
||||||
last_updated, today_sum = query_csv(today, location)
|
last_updated, today_sum = query_csv(today, location)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
return discord.Embed(description="No data for %s. Did you make a typo?" % location, color=0x428bca, type="rich")
|
return discord.Embed(
|
||||||
|
description="No data for %s. Did you make a typo?" % location,
|
||||||
|
color=0x428BCA,
|
||||||
|
type="rich",
|
||||||
|
)
|
||||||
|
|
||||||
|
confirmed = "%s (+%s from yesterday)" % (
|
||||||
|
today_sum["Confirmed"],
|
||||||
|
int(today_sum["Confirmed"]) - int(yesterday_sum["Confirmed"]),
|
||||||
|
)
|
||||||
|
deaths = "%s (+%s from yesterday)" % (
|
||||||
|
today_sum["Deaths"],
|
||||||
|
int(today_sum["Deaths"]) - int(yesterday_sum["Deaths"]),
|
||||||
|
)
|
||||||
|
recovered = "%s (+%s from yesterday)" % (
|
||||||
|
today_sum["Recovered"],
|
||||||
|
int(today_sum["Recovered"]) - int(yesterday_sum["Recovered"]),
|
||||||
|
)
|
||||||
|
|
||||||
confirmed = "%s (+%s from yesterday)" % (today_sum['Confirmed'], int(today_sum['Confirmed']) - int(yesterday_sum['Confirmed']))
|
embed = discord.Embed(
|
||||||
deaths = "%s (+%s from yesterday)" % (today_sum['Deaths'], int(today_sum['Deaths']) - int(yesterday_sum['Deaths']))
|
description="Most recent Covid19 stats for %s\nUpdated once a day\n(Last update was %s)"
|
||||||
recovered = "%s (+%s from yesterday)" % (today_sum['Recovered'], int(today_sum['Recovered']) - int(yesterday_sum['Recovered']))
|
% (location, last_updated),
|
||||||
|
color=0x428BCA,
|
||||||
|
type="rich",
|
||||||
|
)
|
||||||
|
embed.set_author(
|
||||||
|
name="CSSE at Johns Hopkins University",
|
||||||
|
icon_url="https://www.pngitem.com/pimgs/m/27-270528_johns-hopkins-was-a-founding-member-of-the.png",
|
||||||
|
)
|
||||||
|
embed.add_field(
|
||||||
|
name=":rotating_light: Confirmed Cases :rotating_light:",
|
||||||
|
value=confirmed,
|
||||||
|
inline=False,
|
||||||
|
)
|
||||||
|
embed.add_field(
|
||||||
|
name=":hospital: Recovered Cases :hospital:", value=recovered, inline=False
|
||||||
|
)
|
||||||
|
embed.add_field(
|
||||||
|
name=":skull_crossbones: Deaths :skull_crossbones:", value=deaths, inline=False
|
||||||
|
)
|
||||||
|
# if 'Not available' not in get_vaccination_data(location):
|
||||||
|
# embed.add_field(name=':sparkles: :syringe: Percent vaccinated :syringe: :sparkles:', value=get_vaccination_data(location) + "\nVaccination numbers pulled from\nhttps://covidvaxcount.live", inline=False)
|
||||||
|
embed.add_field(name="Source", value="https://github.com/CSSEGISandData/COVID-19")
|
||||||
|
|
||||||
embed = discord.Embed(description="Most recent Covid19 stats for %s\nUpdated once a day\n(Last update was %s)" % (location, last_updated), color=0x428bca, type="rich")
|
return embed
|
||||||
embed.set_author(name="CSSE at Johns Hopkins University", icon_url='https://www.pngitem.com/pimgs/m/27-270528_johns-hopkins-was-a-founding-member-of-the.png')
|
|
||||||
embed.add_field(name=':rotating_light: Confirmed Cases :rotating_light:', value=confirmed, inline=False)
|
|
||||||
embed.add_field(name=':hospital: Recovered Cases :hospital:', value=recovered, inline=False)
|
|
||||||
embed.add_field(name=':skull_crossbones: Deaths :skull_crossbones:', value=deaths, inline=False)
|
|
||||||
# if 'Not available' not in get_vaccination_data(location):
|
|
||||||
# embed.add_field(name=':sparkles: :syringe: Percent vaccinated :syringe: :sparkles:', value=get_vaccination_data(location) + "\nVaccination numbers pulled from\nhttps://covidvaxcount.live", inline=False)
|
|
||||||
embed.add_field(name='Source', value="https://github.com/CSSEGISandData/COVID-19")
|
|
||||||
|
|
||||||
return embed
|
|
||||||
|
|
||||||
# def get_vaccination_data(location):
|
# def get_vaccination_data(location):
|
||||||
# url = requests.get('https://covidvaxcount.live')
|
# url = requests.get('https://covidvaxcount.live')
|
||||||
@ -98,11 +136,12 @@ def sum_numbers(location):
|
|||||||
# return "Not available for %s" % location
|
# return "Not available for %s" % location
|
||||||
# return percent_vaccinated
|
# return percent_vaccinated
|
||||||
|
|
||||||
|
|
||||||
def parse_message(message):
|
def parse_message(message):
|
||||||
try:
|
try:
|
||||||
state = string.capwords(' '.join(message.lstrip('!corona').split()))
|
state = string.capwords(" ".join(message.lstrip("!corona").split()))
|
||||||
if not state:
|
if not state:
|
||||||
state = 'California'
|
state = "California"
|
||||||
except IndexError:
|
except IndexError:
|
||||||
state = 'California'
|
state = "California"
|
||||||
return sum_numbers(state)
|
return sum_numbers(state)
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
import random
|
import random
|
||||||
import help_methods
|
import help_methods
|
||||||
|
|
||||||
|
|
||||||
def decide(message):
|
def decide(message):
|
||||||
choices = message.replace('!decide', '' ).lstrip().split(' or ')
|
choices = message.replace("!decide", "").lstrip().split(" or ")
|
||||||
if '' in choices:
|
if "" in choices:
|
||||||
return help_methods.get_help_message('decide')
|
return help_methods.get_help_message("decide")
|
||||||
elif len(choices) > 1:
|
elif len(choices) > 1:
|
||||||
return random.choice(choices)
|
return random.choice(choices)
|
||||||
else:
|
else:
|
||||||
|
@ -14,24 +14,32 @@ def get_definition(content):
|
|||||||
word = content.split()[1:]
|
word = content.split()[1:]
|
||||||
try:
|
try:
|
||||||
definition = requests.get(
|
definition = requests.get(
|
||||||
"https://api.urbandictionary.com/v0/define?term={}".format('%20'.join(word))
|
"https://api.urbandictionary.com/v0/define?term={}".format(
|
||||||
).json()['list'][0]['definition']
|
"%20".join(word)
|
||||||
site = 'Urban Dictionary'
|
)
|
||||||
|
).json()["list"][0]["definition"]
|
||||||
|
site = "Urban Dictionary"
|
||||||
|
|
||||||
except IndexError:
|
except IndexError:
|
||||||
try:
|
try:
|
||||||
# Try another dictionary
|
# Try another dictionary
|
||||||
definition = requests.get(
|
definition = requests.get(
|
||||||
"http://api.pearson.com/v2/dictionaries/ldoce5/entries?headword={}".format('%20'.join(word))
|
"http://api.pearson.com/v2/dictionaries/ldoce5/entries?headword={}".format(
|
||||||
).json()['results'][0]['senses'][0]['definition'][0]
|
"%20".join(word)
|
||||||
|
)
|
||||||
|
).json()["results"][0]["senses"][0]["definition"][0]
|
||||||
|
|
||||||
site = 'Pearson'
|
site = "Pearson"
|
||||||
except IndexError:
|
except IndexError:
|
||||||
definition = 'No definition found'
|
definition = "No definition found"
|
||||||
|
|
||||||
embed = discord.Embed(description="%s:\n%s" % (' '.join(word), definition), color=0x428bca, type="rich")
|
embed = discord.Embed(
|
||||||
|
description="%s:\n%s" % (" ".join(word), definition),
|
||||||
|
color=0x428BCA,
|
||||||
|
type="rich",
|
||||||
|
)
|
||||||
embed.set_author(name="From %s" % site)
|
embed.set_author(name="From %s" % site)
|
||||||
|
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
return help_methods.get_help_message('define')
|
return help_methods.get_help_message("define")
|
||||||
|
72
app/dice.py
72
app/dice.py
@ -1,39 +1,53 @@
|
|||||||
import discord
|
import discord
|
||||||
from random import randint
|
from random import randint
|
||||||
|
|
||||||
|
|
||||||
def roll_logic(sides):
|
def roll_logic(sides):
|
||||||
return randint(1, sides)
|
return randint(1, sides)
|
||||||
|
|
||||||
|
|
||||||
def roll(number_of_die, sides, number_to_add=None):
|
def roll(number_of_die, sides, number_to_add=None):
|
||||||
results = list(tuple(roll_logic(int(sides)) for _ in range(int(number_of_die))))
|
results = list(tuple(roll_logic(int(sides)) for _ in range(int(number_of_die))))
|
||||||
|
|
||||||
# blue
|
# blue
|
||||||
embed_color = 3447003
|
embed_color = 3447003
|
||||||
if sum(results) == 1:
|
if sum(results) == 1:
|
||||||
# Red
|
# Red
|
||||||
embed_color = 15158332
|
embed_color = 15158332
|
||||||
if sum(results) >= 10:
|
if sum(results) >= 10:
|
||||||
# Green
|
# Green
|
||||||
embed_color = 3066993
|
embed_color = 3066993
|
||||||
if sum(results) >= 15:
|
if sum(results) >= 15:
|
||||||
# Gold
|
# Gold
|
||||||
embed_color = 15844367
|
embed_color = 15844367
|
||||||
|
|
||||||
|
embed = discord.Embed(description=None, color=embed_color, type="rich")
|
||||||
|
embed.set_author(name="Rolling %s %s sided die" % (number_of_die, sides))
|
||||||
|
embed.add_field(name="Rolls", value=results, inline=False)
|
||||||
|
if number_to_add:
|
||||||
|
embed.add_field(
|
||||||
|
name="**Total**",
|
||||||
|
value=":game_die: %s+%s = %s"
|
||||||
|
% (sum(results), number_to_add, (sum(results) + number_to_add)),
|
||||||
|
inline=False,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
embed.add_field(
|
||||||
|
name="**Total**", value=":game_die: %s" % sum(results), inline=False
|
||||||
|
)
|
||||||
|
return embed
|
||||||
|
|
||||||
embed = discord.Embed(description=None, color=embed_color, type="rich")
|
|
||||||
embed.set_author(name="Rolling %s %s sided die" % (number_of_die, sides))
|
|
||||||
embed.add_field(name='Rolls', value=results, inline=False)
|
|
||||||
if number_to_add:
|
|
||||||
embed.add_field(name="**Total**", value=":game_die: %s+%s = %s" % (sum(results), number_to_add, (sum(results) + number_to_add)), inline=False)
|
|
||||||
else:
|
|
||||||
embed.add_field(name="**Total**", value=":game_die: %s" % sum(results), inline=False)
|
|
||||||
return embed
|
|
||||||
|
|
||||||
def parse_message(message):
|
def parse_message(message):
|
||||||
message = ' '.join(message.split()[1:])
|
message = " ".join(message.split()[1:])
|
||||||
if '+' in message:
|
if "+" in message:
|
||||||
try:
|
try:
|
||||||
number_to_add = int(message.split('+')[-1])
|
number_to_add = int(message.split("+")[-1])
|
||||||
return roll(message.split('d')[0], message.split('d')[1].split('+')[0], number_to_add)
|
return roll(
|
||||||
except ValueError:
|
message.split("d")[0],
|
||||||
return "Could not add that number to the total roll"
|
message.split("d")[1].split("+")[0],
|
||||||
return roll(message.split('d')[0], message.split('d')[1])
|
number_to_add,
|
||||||
|
)
|
||||||
|
except ValueError:
|
||||||
|
return "Could not add that number to the total roll"
|
||||||
|
return roll(message.split("d")[0], message.split("d")[1])
|
||||||
|
@ -3,6 +3,7 @@ import sys
|
|||||||
|
|
||||||
import help_methods
|
import help_methods
|
||||||
|
|
||||||
|
|
||||||
def check_8ball(question):
|
def check_8ball(question):
|
||||||
"""
|
"""
|
||||||
check_8ball(question)
|
check_8ball(question)
|
||||||
@ -14,37 +15,35 @@ def check_8ball(question):
|
|||||||
question = question.split()[1:]
|
question = question.split()[1:]
|
||||||
|
|
||||||
positive_responses = [
|
positive_responses = [
|
||||||
'As I see it, yes',
|
"As I see it, yes",
|
||||||
'It is certain',
|
"It is certain",
|
||||||
'It is decidedly so',
|
"It is decidedly so",
|
||||||
'Most likely',
|
"Most likely",
|
||||||
'Oh for sure brother',
|
"Oh for sure brother",
|
||||||
'Outlook good',
|
"Outlook good",
|
||||||
'Signs point to yes',
|
"Signs point to yes",
|
||||||
'Without a doubt',
|
"Without a doubt",
|
||||||
'Yes, definitely',
|
"Yes, definitely",
|
||||||
'Yes',
|
"Yes",
|
||||||
'You can count on it',
|
"You can count on it",
|
||||||
]
|
]
|
||||||
negative_responses = [
|
negative_responses = [
|
||||||
'Dont count on it',
|
"Dont count on it",
|
||||||
'My sources say no',
|
"My sources say no",
|
||||||
'My thoughts are.....no',
|
"My thoughts are.....no",
|
||||||
'Outlook not so good',
|
"Outlook not so good",
|
||||||
'Very doubtful',
|
"Very doubtful",
|
||||||
]
|
]
|
||||||
noncommittal_responses = [
|
noncommittal_responses = [
|
||||||
'Ask again later',
|
"Ask again later",
|
||||||
'Better not tell you now',
|
"Better not tell you now",
|
||||||
'Can\'t answer that right now',
|
"Can't answer that right now",
|
||||||
'Concentrate and ask again',
|
"Concentrate and ask again",
|
||||||
'Reply hazy try again',
|
"Reply hazy try again",
|
||||||
]
|
]
|
||||||
|
|
||||||
return random.choice(
|
return random.choice(
|
||||||
positive_responses +
|
positive_responses + negative_responses + noncommittal_responses
|
||||||
negative_responses +
|
|
||||||
noncommittal_responses
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return help_methods.get_help_message('8ball')
|
return help_methods.get_help_message("8ball")
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
def get_excuse():
|
|
||||||
url = requests.get('http://www.devexcuses.com')
|
|
||||||
soup = BeautifulSoup(url.content, features="html.parser")
|
|
||||||
|
|
||||||
return "```{}```".format(str(soup.find("p", {"class": "excuse"}).contents[0]).split(">")[1].split("</a")[0])
|
def get_excuse():
|
||||||
|
url = requests.get("http://www.devexcuses.com")
|
||||||
|
soup = BeautifulSoup(url.content, features="html.parser")
|
||||||
|
|
||||||
|
return "```{}```".format(
|
||||||
|
str(soup.find("p", {"class": "excuse"}).contents[0])
|
||||||
|
.split(">")[1]
|
||||||
|
.split("</a")[0]
|
||||||
|
)
|
||||||
|
183
app/ffxiv.py
183
app/ffxiv.py
@ -2,94 +2,113 @@ import requests
|
|||||||
import os
|
import os
|
||||||
import discord
|
import discord
|
||||||
|
|
||||||
if os.getenv('ffxiv_token'):
|
if os.getenv("ffxiv_token"):
|
||||||
token = "&private_key=%s" % os.getenv('ffxiv_token')
|
token = "&private_key=%s" % os.getenv("ffxiv_token")
|
||||||
else:
|
else:
|
||||||
token = ''
|
token = ""
|
||||||
|
|
||||||
|
|
||||||
def parse_message(message):
|
def parse_message(message):
|
||||||
name = message.split()[1] + '+' + message.split()[2]
|
name = message.split()[1] + "+" + message.split()[2]
|
||||||
server = message.split()[3]
|
server = message.split()[3]
|
||||||
|
|
||||||
return make_request(name=name, server=server)
|
return make_request(name=name, server=server)
|
||||||
|
|
||||||
|
|
||||||
def make_request(name, server):
|
def make_request(name, server):
|
||||||
player_search = "https://xivapi.com/character/search?name=%s&server=%s%s" % (name, server, token)
|
player_search = "https://xivapi.com/character/search?name=%s&server=%s%s" % (
|
||||||
# print(player_search)
|
name,
|
||||||
player_id = list(filter(
|
server,
|
||||||
lambda x: server.lower() in x['Server'].lower(),
|
token,
|
||||||
requests.get(player_search).json()['Results']
|
|
||||||
))[0]['ID']
|
|
||||||
import pprint
|
|
||||||
pp = pprint.PrettyPrinter(indent=2, compact=True)
|
|
||||||
|
|
||||||
# if adding extended=1 to the query, you'll see some image files, eg. /cj/1/blackmage.png
|
|
||||||
# prepend these with https://xivapi.com/ to get a useable url
|
|
||||||
# https://xivapi.com//cj/1/blackmage.png
|
|
||||||
request_url = "https://xivapi.com/character/%s?extended=1&data=CJ,FC%s" % (player_id, token)
|
|
||||||
# print(request_url)
|
|
||||||
player_blob = requests.get(request_url).json()
|
|
||||||
character = player_blob['Character']
|
|
||||||
# pp.pprint(player_blob)
|
|
||||||
# pp.pprint(character)
|
|
||||||
|
|
||||||
current_class = character['ActiveClassJob']
|
|
||||||
current_class_name = current_class['Job']['Name']
|
|
||||||
current_class_level = character['ActiveClassJob']['Level']
|
|
||||||
xp_to_level_up = current_class['ExpLevelTogo']
|
|
||||||
job_icon = "https://xivapi.com/%s" % current_class['Job']['Icon']
|
|
||||||
|
|
||||||
if character['GrandCompany']['Company']:
|
|
||||||
grand_company = character['GrandCompany']
|
|
||||||
|
|
||||||
if player_blob['FreeCompany']:
|
|
||||||
free_company = player_blob['FreeCompany']
|
|
||||||
fc_member_count = free_company['ActiveMemberCount']
|
|
||||||
fc_name = free_company['Name']
|
|
||||||
fc_slogan = free_company['Slogan']
|
|
||||||
fc_tag = free_company['Tag']
|
|
||||||
fc_rank = free_company['Rank']
|
|
||||||
fc_estate = free_company['Estate']
|
|
||||||
fc_plot = fc_estate['Plot']
|
|
||||||
|
|
||||||
|
|
||||||
embed = discord.Embed(description=character['Name'], color=0x428bca, type="rich")
|
|
||||||
embed.set_author(name="FFXIV API bullshit for %s\nPlayer ID: %s" % (character['Name'], character['ID']), icon_url="http://na.lodestonenews.com/images/thumbnail.png")
|
|
||||||
embed.set_thumbnail(url=job_icon)
|
|
||||||
embed.add_field(name="Current Class", value="%s - Lvl: %s" % (current_class_name, current_class_level), inline=True)
|
|
||||||
embed.add_field(name="XP to level up", value=xp_to_level_up, inline=True)
|
|
||||||
embed.add_field(name="Race", value=character['Race']['Name'], inline=True)
|
|
||||||
if character['GrandCompany']['Company']:
|
|
||||||
embed.add_field(
|
|
||||||
name="Grand Company",
|
|
||||||
value="%s of the %s" % (
|
|
||||||
grand_company['Rank']['Name'],
|
|
||||||
grand_company['Company']['Name']),
|
|
||||||
inline=False
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
embed.add_field(name="Grand Company", value="Not in a Grand Company", inline=False)
|
|
||||||
if player_blob['FreeCompany']:
|
|
||||||
embed.add_field(
|
|
||||||
name="Free Company: %s (%s)" % (fc_name, fc_tag),
|
|
||||||
value="\nActive Members: %s\nFC Rank: %s\nFC Estate: %s" % (
|
|
||||||
fc_member_count, fc_rank, fc_plot
|
|
||||||
),
|
|
||||||
inline=False
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
embed.add_field(name="Free Company", value="Not in a Free Company", inline=False)
|
|
||||||
|
|
||||||
embed.set_image(url=character['Portrait'])
|
|
||||||
embed.add_field(name="All other classes", value="-----", inline=False)
|
|
||||||
all_classes = character['ClassJobs']
|
|
||||||
for job in all_classes:
|
|
||||||
job_icon = "https://xivapi.com%s" % job['Job']['Icon']
|
|
||||||
embed.add_field(
|
|
||||||
name=job['Job']['Abbreviation'],
|
|
||||||
value=job['Level'], inline=True
|
|
||||||
)
|
)
|
||||||
|
# print(player_search)
|
||||||
|
player_id = list(
|
||||||
|
filter(
|
||||||
|
lambda x: server.lower() in x["Server"].lower(),
|
||||||
|
requests.get(player_search).json()["Results"],
|
||||||
|
)
|
||||||
|
)[0]["ID"]
|
||||||
|
import pprint
|
||||||
|
|
||||||
#embed.set_footer(text='Feel free to use my refer a friend code: P9CQ9JUT')
|
pp = pprint.PrettyPrinter(indent=2, compact=True)
|
||||||
return embed
|
|
||||||
|
# if adding extended=1 to the query, you'll see some image files, eg. /cj/1/blackmage.png
|
||||||
|
# prepend these with https://xivapi.com/ to get a useable url
|
||||||
|
# https://xivapi.com//cj/1/blackmage.png
|
||||||
|
request_url = "https://xivapi.com/character/%s?extended=1&data=CJ,FC%s" % (
|
||||||
|
player_id,
|
||||||
|
token,
|
||||||
|
)
|
||||||
|
# print(request_url)
|
||||||
|
player_blob = requests.get(request_url).json()
|
||||||
|
character = player_blob["Character"]
|
||||||
|
# pp.pprint(player_blob)
|
||||||
|
# pp.pprint(character)
|
||||||
|
|
||||||
|
current_class = character["ActiveClassJob"]
|
||||||
|
current_class_name = current_class["Job"]["Name"]
|
||||||
|
current_class_level = character["ActiveClassJob"]["Level"]
|
||||||
|
xp_to_level_up = current_class["ExpLevelTogo"]
|
||||||
|
job_icon = "https://xivapi.com/%s" % current_class["Job"]["Icon"]
|
||||||
|
|
||||||
|
if character["GrandCompany"]["Company"]:
|
||||||
|
grand_company = character["GrandCompany"]
|
||||||
|
|
||||||
|
if player_blob["FreeCompany"]:
|
||||||
|
free_company = player_blob["FreeCompany"]
|
||||||
|
fc_member_count = free_company["ActiveMemberCount"]
|
||||||
|
fc_name = free_company["Name"]
|
||||||
|
fc_slogan = free_company["Slogan"]
|
||||||
|
fc_tag = free_company["Tag"]
|
||||||
|
fc_rank = free_company["Rank"]
|
||||||
|
fc_estate = free_company["Estate"]
|
||||||
|
fc_plot = fc_estate["Plot"]
|
||||||
|
|
||||||
|
embed = discord.Embed(description=character["Name"], color=0x428BCA, type="rich")
|
||||||
|
embed.set_author(
|
||||||
|
name="FFXIV API bullshit for %s\nPlayer ID: %s"
|
||||||
|
% (character["Name"], character["ID"]),
|
||||||
|
icon_url="http://na.lodestonenews.com/images/thumbnail.png",
|
||||||
|
)
|
||||||
|
embed.set_thumbnail(url=job_icon)
|
||||||
|
embed.add_field(
|
||||||
|
name="Current Class",
|
||||||
|
value="%s - Lvl: %s" % (current_class_name, current_class_level),
|
||||||
|
inline=True,
|
||||||
|
)
|
||||||
|
embed.add_field(name="XP to level up", value=xp_to_level_up, inline=True)
|
||||||
|
embed.add_field(name="Race", value=character["Race"]["Name"], inline=True)
|
||||||
|
if character["GrandCompany"]["Company"]:
|
||||||
|
embed.add_field(
|
||||||
|
name="Grand Company",
|
||||||
|
value="%s of the %s"
|
||||||
|
% (grand_company["Rank"]["Name"], grand_company["Company"]["Name"]),
|
||||||
|
inline=False,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
embed.add_field(
|
||||||
|
name="Grand Company", value="Not in a Grand Company", inline=False
|
||||||
|
)
|
||||||
|
if player_blob["FreeCompany"]:
|
||||||
|
embed.add_field(
|
||||||
|
name="Free Company: %s (%s)" % (fc_name, fc_tag),
|
||||||
|
value="\nActive Members: %s\nFC Rank: %s\nFC Estate: %s"
|
||||||
|
% (fc_member_count, fc_rank, fc_plot),
|
||||||
|
inline=False,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
embed.add_field(
|
||||||
|
name="Free Company", value="Not in a Free Company", inline=False
|
||||||
|
)
|
||||||
|
|
||||||
|
embed.set_image(url=character["Portrait"])
|
||||||
|
embed.add_field(name="All other classes", value="-----", inline=False)
|
||||||
|
all_classes = character["ClassJobs"]
|
||||||
|
for job in all_classes:
|
||||||
|
job_icon = "https://xivapi.com%s" % job["Job"]["Icon"]
|
||||||
|
embed.add_field(
|
||||||
|
name=job["Job"]["Abbreviation"], value=job["Level"], inline=True
|
||||||
|
)
|
||||||
|
|
||||||
|
# embed.set_footer(text='Feel free to use my refer a friend code: P9CQ9JUT')
|
||||||
|
return embed
|
||||||
|
@ -2,6 +2,7 @@ import random
|
|||||||
import string
|
import string
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
|
||||||
def get_image(boards, nsfw=False):
|
def get_image(boards, nsfw=False):
|
||||||
"""
|
"""
|
||||||
get_image(boards, nsfw=False)
|
get_image(boards, nsfw=False)
|
||||||
@ -14,36 +15,34 @@ def get_image(boards, nsfw=False):
|
|||||||
boards = random.choice(boards)
|
boards = random.choice(boards)
|
||||||
|
|
||||||
domains = [
|
domains = [
|
||||||
'cdn.awwni.m',
|
"cdn.awwni.m",
|
||||||
'gfycat.com',
|
"gfycat.com",
|
||||||
'i.imgur.com',
|
"i.imgur.com",
|
||||||
'i.redd.it',
|
"i.redd.it",
|
||||||
'i.reddituploads.com',
|
"i.reddituploads.com",
|
||||||
'i3.kym-cdn.com',
|
"i3.kym-cdn.com",
|
||||||
'imgur.com',
|
"imgur.com",
|
||||||
'media.giphy.com',
|
"media.giphy.com",
|
||||||
]
|
]
|
||||||
request_string = "https://reddit.com/r/{}/random.json".format(boards)
|
request_string = "https://reddit.com/r/{}/random.json".format(boards)
|
||||||
|
|
||||||
if not nsfw:
|
if not nsfw:
|
||||||
# Append this header to the request. Tells the API to only return SFW results
|
# Append this header to the request. Tells the API to only return SFW results
|
||||||
request_string += '?obey_over18=true'
|
request_string += "?obey_over18=true"
|
||||||
|
|
||||||
# Spoof our user agent with each request so we dont get rate limited
|
# Spoof our user agent with each request so we dont get rate limited
|
||||||
random_user_agent = ''.join(
|
random_user_agent = "".join(
|
||||||
random.SystemRandom().choice(
|
random.SystemRandom().choice(string.ascii_uppercase + string.digits)
|
||||||
string.ascii_uppercase + string.digits
|
for _ in range(5)
|
||||||
) for _ in range(5)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
response = requests.get(
|
response = requests.get(
|
||||||
request_string,
|
request_string, headers={"User-agent": random_user_agent}
|
||||||
headers = {'User-agent':random_user_agent}
|
).json()[0]["data"]["children"][0]
|
||||||
).json()[0]['data']['children'][0]
|
|
||||||
|
|
||||||
if response['data']['domain'] not in domains:
|
if response["data"]["domain"] not in domains:
|
||||||
# If we dont find an approved domain, re-try the request
|
# If we dont find an approved domain, re-try the request
|
||||||
return get_image(boards, nsfw=nsfw)
|
return get_image(boards, nsfw=nsfw)
|
||||||
image_url = response['data']['url'].replace('http://', 'https://')
|
image_url = response["data"]["url"].replace("http://", "https://")
|
||||||
|
|
||||||
return image_url
|
return image_url
|
||||||
|
@ -7,35 +7,28 @@ import role_check
|
|||||||
|
|
||||||
def create_issue(title, description):
|
def create_issue(title, description):
|
||||||
|
|
||||||
post_args = {
|
post_args = {"title": title, "description": description}
|
||||||
'title': title,
|
|
||||||
'description': description
|
|
||||||
}
|
|
||||||
|
|
||||||
headers = {
|
headers = {"PRIVATE-TOKEN": os.getenv("gitlab_token")}
|
||||||
'PRIVATE-TOKEN': os.getenv('gitlab_token')
|
|
||||||
}
|
|
||||||
|
|
||||||
r = requests.post(
|
r = requests.post(
|
||||||
'https://git.luker.gq/api/v4/projects/1/issues',
|
"https://git.luker.gq/api/v4/projects/1/issues", data=post_args, headers=headers
|
||||||
data=post_args,
|
|
||||||
headers=headers
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return(r.json()['web_url'])
|
return r.json()["web_url"]
|
||||||
|
|
||||||
|
|
||||||
def parse_message(message):
|
def parse_message(message):
|
||||||
if len(message.content.split()) == 1:
|
if len(message.content.split()) == 1:
|
||||||
return help_methods.get_help_message(method='issue')
|
return help_methods.get_help_message(method="issue")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
message = ' '.join(message.content.split()[1:])
|
message = " ".join(message.content.split()[1:])
|
||||||
title, description = message.split(';')
|
title, description = message.split(";")
|
||||||
except Exception:
|
except Exception:
|
||||||
return help_methods.get_help_message(method='issue')
|
return help_methods.get_help_message(method="issue")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return create_issue(title=title, description=description)
|
return create_issue(title=title, description=description)
|
||||||
except Exception:
|
except Exception:
|
||||||
return help_methods.get_help_message(method='issue')
|
return help_methods.get_help_message(method="issue")
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import discord
|
import discord
|
||||||
|
|
||||||
|
|
||||||
def get_help_message(method):
|
def get_help_message(method):
|
||||||
"""
|
"""
|
||||||
get_help_message(method)
|
get_help_message(method)
|
||||||
@ -9,187 +11,160 @@ def get_help_message(method):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
supported_methods = {
|
supported_methods = {
|
||||||
'8ball': [
|
"8ball": [
|
||||||
'Ask dale bot a question and it will give you an 8ball response',
|
"Ask dale bot a question and it will give you an 8ball response",
|
||||||
'\nUsage: !8ball Will I win the lottery tomorrow?'
|
"\nUsage: !8ball Will I win the lottery tomorrow?",
|
||||||
],
|
],
|
||||||
'ask': [
|
"ask": [
|
||||||
'Submits your query to wolfram alpha. If that cannot be answered, tries wikipedia\n',
|
"Submits your query to wolfram alpha. If that cannot be answered, tries wikipedia\n",
|
||||||
'\nUsage: !ask 100lbs to KG'
|
"\nUsage: !ask 100lbs to KG",
|
||||||
],
|
],
|
||||||
'avatar': [
|
"avatar": [
|
||||||
'Returns the avatar for the mentioned user',
|
"Returns the avatar for the mentioned user",
|
||||||
'\nUsage: !avatar @somebody'
|
"\nUsage: !avatar @somebody",
|
||||||
],
|
],
|
||||||
'birb': [
|
"birb": ["Returns a random bird photo", "\nUsage: !birb"],
|
||||||
'Returns a random bird photo',
|
"bf5": [
|
||||||
'\nUsage: !birb'
|
"Returns some API stats about a battlefield 5 character",
|
||||||
],
|
"\nUsage: !bf5 <your origin account name>",
|
||||||
'bf5': [
|
],
|
||||||
'Returns some API stats about a battlefield 5 character',
|
"dale": ["Posts a photo or video of Dale, the goodest boy.", "\nUsage: !dale"],
|
||||||
'\nUsage: !bf5 <your origin account name>'
|
"redpanda": ["Returns a random red panda photo", "\nUsage: !redpanda"],
|
||||||
],
|
"panda": ["Returns a random panda photo", "\nUsage: !panda"],
|
||||||
'dale': [
|
"koala": ["Returns a random koala photo", "\nUsage: !koala"],
|
||||||
'Posts a photo or video of Dale, the goodest boy.',
|
"clap": [
|
||||||
'\nUsage: !dale'
|
"Returns the shittiest meme created by sassy girls on twitter this century",
|
||||||
],
|
"Usage: !clap some text to be meme'mt",
|
||||||
'redpanda': [
|
],
|
||||||
'Returns a random red panda photo',
|
"simp": [
|
||||||
'\nUsage: !redpanda'
|
"Returns a license to be a simp",
|
||||||
],
|
"Usage: !simp https://some.photo.jpg",
|
||||||
'panda': [
|
],
|
||||||
'Returns a random panda photo',
|
"horny": [
|
||||||
'\nUsage: !panda'
|
"Returns a license to be horny",
|
||||||
],
|
"Usage: !horny https://some.photo.jpg",
|
||||||
'koala': [
|
],
|
||||||
'Returns a random koala photo',
|
"wasted": [
|
||||||
'\nUsage: !koala'
|
"Overlays the GTAV wasted text over the image you link",
|
||||||
],
|
"Usage: !wasted https://some.photo.jpg",
|
||||||
'clap': [
|
],
|
||||||
'Returns the shittiest meme created by sassy girls on twitter this century',
|
"cleanup": [
|
||||||
'Usage: !clap some text to be meme\'mt'
|
"Admin use only. Deletes dale bot's messages from the channel",
|
||||||
],
|
"Usage: !cleanup",
|
||||||
'simp': [
|
],
|
||||||
'Returns a license to be a simp',
|
"corona": [
|
||||||
'Usage: !simp https://some.photo.jpg'
|
"Pulls the latest corona virus stats per state from Johns Hopkins data",
|
||||||
],
|
"Usage: !corona <some US state>\neg: !corona Colorado",
|
||||||
'horny': [
|
],
|
||||||
'Returns a license to be horny',
|
"decide": [
|
||||||
'Usage: !horny https://some.photo.jpg'
|
"dale-bot will help make the tough decisions for you",
|
||||||
],
|
" If there is only one option, it will give you a yes or no",
|
||||||
'wasted': [
|
"\nUsage: !decide cake or pie\n!decide should I do my homework",
|
||||||
'Overlays the GTAV wasted text over the image you link',
|
],
|
||||||
'Usage: !wasted https://some.photo.jpg'
|
"ffxiv": [
|
||||||
],
|
"Pulls a characters data from the lodestone API\n",
|
||||||
'cleanup': [
|
"Usage: !ffxiv <First name> <last name> <server>\n",
|
||||||
'Admin use only. Deletes dale bot\'s messages from the channel',
|
"eg: !ffxiv Slamsong Bardley Adamantoise\n\n",
|
||||||
'Usage: !cleanup'
|
"Did you know that the critically acclaimed MMORPG Final Fantasy XIV has a free trial,\n",
|
||||||
],
|
"and includes the entirety of A Realm Reborn AND the award-winning Heavensward expansion\n",
|
||||||
'corona': [
|
"up to level 60 with no restrictions on playtime? Sign up, and enjoy Eorzea today!",
|
||||||
'Pulls the latest corona virus stats per state from Johns Hopkins data',
|
],
|
||||||
'Usage: !corona <some US state>\neg: !corona Colorado'
|
"define": [
|
||||||
],
|
"Returns a definiton of a word from urban dictionary",
|
||||||
'decide': [
|
"\nUsage: !define loli",
|
||||||
'dale-bot will help make the tough decisions for you',
|
],
|
||||||
' If there is only one option, it will give you a yes or no',
|
"dog": ["Returns the URL to a G O O D B O Y E or G I R L", "\nUsage: !dog"],
|
||||||
'\nUsage: !decide cake or pie\n!decide should I do my homework'
|
"emoji": [
|
||||||
],
|
"Uploads the passed in URL to the server as an emoji.",
|
||||||
'ffxiv': [
|
"\nDiscord does not support GIFS. It will throw an error if you try."
|
||||||
'Pulls a characters data from the lodestone API\n',
|
"\nUsage: !emoji http://pictures.com/some_image.png my_new_emoji\n",
|
||||||
'Usage: !ffxiv <First name> <last name> <server>\n',
|
"or `!emoji del some_emoji` to delete",
|
||||||
'eg: !ffxiv Slamsong Bardley Adamantoise\n\n',
|
],
|
||||||
'Did you know that the critically acclaimed MMORPG Final Fantasy XIV has a free trial,\n',
|
"excuse": [
|
||||||
'and includes the entirety of A Realm Reborn AND the award-winning Heavensward expansion\n',
|
"Generates a random excuse you can give your boss",
|
||||||
'up to level 60 with no restrictions on playtime? Sign up, and enjoy Eorzea today!'
|
"\nUsage: !excuse",
|
||||||
],
|
],
|
||||||
'define': [
|
"greentext": [
|
||||||
'Returns a definiton of a word from urban dictionary',
|
"Grabs a greentext story from redditchat so you can laugh at the misfortune of others",
|
||||||
'\nUsage: !define loli'
|
"\nUsage: !greentext",
|
||||||
],
|
],
|
||||||
'dog': [
|
"help": ["Shows you this message"],
|
||||||
'Returns the URL to a G O O D B O Y E or G I R L',
|
"homepage": [
|
||||||
'\nUsage: !dog'
|
"This function now outputs the SWEET-ASS picture of the day.",
|
||||||
],
|
" Note this picture only changes once a day.",
|
||||||
'emoji': [
|
"\nUsage: !homepage",
|
||||||
'Uploads the passed in URL to the server as an emoji.',
|
],
|
||||||
'\nDiscord does not support GIFS. It will throw an error if you try.'
|
"invite": [
|
||||||
'\nUsage: !emoji http://pictures.com/some_image.png my_new_emoji\n',
|
"Generates a one time use invite to the voice channel you are currently in.\n",
|
||||||
'or `!emoji del some_emoji` to delete'
|
"if you are not in a voice channel, the invite will be for whatever channel !invite was typed in.\n"
|
||||||
],
|
"You can also specify if you want it to be a temporary invite by adding `temp` to the end\n",
|
||||||
'excuse': [
|
"Usage: !invite or !invite temp",
|
||||||
'Generates a random excuse you can give your boss',
|
],
|
||||||
'\nUsage: !excuse'
|
"issue": [
|
||||||
],
|
"Creates an issue on gitlab with the passed in parameters\n",
|
||||||
'greentext': [
|
"Usage: !issue <issue title>; <issue description>",
|
||||||
'Grabs a greentext story from redditchat so you can laugh at the misfortune of others',
|
],
|
||||||
'\nUsage: !greentext'
|
"icon": [
|
||||||
],
|
"Returns the server's icon URL\n",
|
||||||
'help': [
|
"Usage: !icon",
|
||||||
'Shows you this message'
|
],
|
||||||
],
|
"info": [
|
||||||
'homepage': [
|
"Returns a blurb with information about the discord server\n",
|
||||||
'This function now outputs the SWEET-ASS picture of the day.',
|
"Usage: !info",
|
||||||
' Note this picture only changes once a day.',
|
],
|
||||||
'\nUsage: !homepage'
|
"lewd": [
|
||||||
],
|
"Returns a URL for a lewd image.",
|
||||||
'invite': [
|
"Can only be used in NSFW channels.",
|
||||||
'Generates a one time use invite to the voice channel you are currently in.\n',
|
"\nUsage: !lewd",
|
||||||
'if you are not in a voice channel, the invite will be for whatever channel !invite was typed in.\n'
|
],
|
||||||
'You can also specify if you want it to be a temporary invite by adding `temp` to the end\n',
|
"purge": [
|
||||||
'Usage: !invite or !invite temp'
|
"By default, will delete your last 20 messages. You can override this",
|
||||||
],
|
" with your own number. \nUsage: !purge or !purge 15",
|
||||||
'issue': [
|
],
|
||||||
'Creates an issue on gitlab with the passed in parameters\n',
|
"roles": [
|
||||||
'Usage: !issue <issue title>; <issue description>',
|
"dale bot will PM you a message with all the roles you have on the server"
|
||||||
],
|
],
|
||||||
'icon': [
|
"wallpaper": [
|
||||||
'Returns the server\'s icon URL\n',
|
"Returns the URL for a 4k wallpaper. You can enter",
|
||||||
'Usage: !icon',
|
"a search term as well. Supports multiple search terms as well",
|
||||||
],
|
"\nUsage: !wallpaper flowers or !wallpaper mountain flowers sky ",
|
||||||
'info': [
|
],
|
||||||
'Returns a blurb with information about the discord server\n',
|
"message": [
|
||||||
'Usage: !info',
|
"You can ask me a question directly and I will do my best to answer it.",
|
||||||
],
|
"\nUsage: @dale-bot what is the capital of France?",
|
||||||
'lewd': [
|
],
|
||||||
'Returns a URL for a lewd image.',
|
"meme": [
|
||||||
'Can only be used in NSFW channels.',
|
"Generates a meme on the fly!",
|
||||||
'\nUsage: !lewd'
|
"\nExamples of all templates can be seen here https://memegen.link/examples"
|
||||||
],
|
"\n\nUsage: !meme doge top text; bottom text",
|
||||||
'purge': [
|
],
|
||||||
'By default, will delete your last 20 messages. You can override this',
|
"nft": [
|
||||||
' with your own number. \nUsage: !purge or !purge 15'
|
"Polls opensea and gets a random monkey from bored ape yacht club",
|
||||||
],
|
"\nUsage: !nft",
|
||||||
'roles': [
|
],
|
||||||
'dale bot will PM you a message with all the roles you have on the server'
|
"owo": [
|
||||||
],
|
"Returns some fucky wucky text\n",
|
||||||
'wallpaper': [
|
"Usage: !owo what the fuck did you just fucking say about me you little shit?",
|
||||||
'Returns the URL for a 4k wallpaper. You can enter',
|
],
|
||||||
'a search term as well. Supports multiple search terms as well',
|
"pout": [
|
||||||
'\nUsage: !wallpaper flowers or !wallpaper mountain flowers sky '
|
"Returns the URL for an anime girl pouting you filthy weeb\n",
|
||||||
],
|
"Usage: !pout",
|
||||||
'message': [
|
],
|
||||||
'You can ask me a question directly and I will do my best to answer it.',
|
"rat": ["Returns a random rat photo", "\nUsage: !rat"],
|
||||||
'\nUsage: @dale-bot what is the capital of France?'
|
"roll": [
|
||||||
],
|
"Rolls N number of Y sided die\n",
|
||||||
'meme': [
|
"Usage: !roll 3d20\n",
|
||||||
'Generates a meme on the fly!',
|
"You can also add a modifier on the end with a +",
|
||||||
'\nExamples of all templates can be seen here https://memegen.link/examples'
|
"Usage: !roll 2d20+5",
|
||||||
'\n\nUsage: !meme doge top text; bottom text'
|
],
|
||||||
],
|
"smug": ["Returns the URL for smug anime girl"],
|
||||||
'nft': [
|
"source": ["Links you to the git repo with dale-bot's source code"],
|
||||||
'Polls opensea and gets a random monkey from bored ape yacht club',
|
"stock": [
|
||||||
'\nUsage: !nft'
|
"Returns basic stock information for the stock you entered.",
|
||||||
],
|
"\nUsage: !stock AAPL TSLA",
|
||||||
'owo': [
|
],
|
||||||
'Returns some fucky wucky text\n',
|
"trackdays": [
|
||||||
'Usage: !owo what the fuck did you just fucking say about me you little shit?'
|
"Returns the track schedule for the tracks we frequent (buttonwillow and thunderhill).\n",
|
||||||
],
|
|
||||||
'pout': [
|
|
||||||
'Returns the URL for an anime girl pouting you filthy weeb\n',
|
|
||||||
'Usage: !pout'
|
|
||||||
],
|
|
||||||
'rat': [
|
|
||||||
'Returns a random rat photo',
|
|
||||||
'\nUsage: !rat'
|
|
||||||
],
|
|
||||||
'roll': [
|
|
||||||
'Rolls N number of Y sided die\n',
|
|
||||||
'Usage: !roll 3d20\n',
|
|
||||||
'You can also add a modifier on the end with a +',
|
|
||||||
'Usage: !roll 2d20+5'
|
|
||||||
],
|
|
||||||
'smug': [
|
|
||||||
'Returns the URL for smug anime girl'
|
|
||||||
],
|
|
||||||
'source': [
|
|
||||||
"Links you to the git repo with dale-bot's source code"
|
|
||||||
],
|
|
||||||
'stock': [
|
|
||||||
'Returns basic stock information for the stock you entered.',
|
|
||||||
'\nUsage: !stock AAPL TSLA'
|
|
||||||
],
|
|
||||||
'trackdays': [
|
|
||||||
'Returns the track schedule for the tracks we frequent (buttonwillow and thunderhill).\n',
|
|
||||||
# 'Use abbreviations to reference the tracks, as follows\n',
|
# 'Use abbreviations to reference the tracks, as follows\n',
|
||||||
# 'bw = Buttonwillow Raceway\n',
|
# 'bw = Buttonwillow Raceway\n',
|
||||||
# 'willow = Willow Springs\n',
|
# 'willow = Willow Springs\n',
|
||||||
@ -198,57 +173,110 @@ def get_help_message(method):
|
|||||||
# 'thill = Thunderhill Raceway Park\n',
|
# 'thill = Thunderhill Raceway Park\n',
|
||||||
# 'sonoma = Sonoma Raceway\n',
|
# 'sonoma = Sonoma Raceway\n',
|
||||||
# 'acs = Auto Club Speedway\n',
|
# 'acs = Auto Club Speedway\n',
|
||||||
'Usage: !trackdays'
|
"Usage: !trackdays",
|
||||||
],
|
],
|
||||||
'tts': [
|
"tts": [
|
||||||
'Uploads a file with the specified text as an MP3.\nThis is advanced shitposting',
|
"Uploads a file with the specified text as an MP3.\nThis is advanced shitposting",
|
||||||
'\nUsage: !tts who watches the watchmen?',
|
"\nUsage: !tts who watches the watchmen?",
|
||||||
'\nTo list all languages, you can type `!tts langs`'
|
"\nTo list all languages, you can type `!tts langs`",
|
||||||
],
|
],
|
||||||
'youtube': [
|
"youtube": [
|
||||||
'Searches youtube for the query string and returns the first result',
|
"Searches youtube for the query string and returns the first result",
|
||||||
'\nUsage: !youtube sick bmx tricks'
|
"\nUsage: !youtube sick bmx tricks",
|
||||||
],
|
],
|
||||||
'wink': [
|
"wink": ["returns a anime girl winking at you", "\nUsage: !wink"],
|
||||||
'returns a anime girl winking at you',
|
"verify": [
|
||||||
'\nUsage: !wink'
|
"Adds the twitter blue check mark to the previous message\n",
|
||||||
],
|
"\nLiterally thats all it does\n" "\nUsage: !verify",
|
||||||
'verify': [
|
],
|
||||||
'Adds the twitter blue check mark to the previous message\n',
|
|
||||||
'\nLiterally thats all it does\n'
|
|
||||||
'\nUsage: !verify'
|
|
||||||
],
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return "```css\n{}: {}\n```".format(method, ' '.join(supported_methods[method]))
|
return "```css\n{}: {}\n```".format(method, " ".join(supported_methods[method]))
|
||||||
|
|
||||||
|
|
||||||
def get_help_embed(bot):
|
def get_help_embed(bot):
|
||||||
categories = {
|
categories = {
|
||||||
'fun': ['nft', 'bf5', 'ffxiv', 'clap', 'youtube', 'excuse', 'greentext', 'lewd', 'message', 'meme', 'homepage', 'pout', 'roll', 'smug', 'owo', 'wink', 'verify', 'horny', 'wasted', 'simp', 'trackdays'],
|
"fun": [
|
||||||
'util': ['ask', 'corona', 'emoji', '8ball', 'decide', 'info', 'icon', 'wallpaper', 'stock', 'tts', 'issue'],
|
"nft",
|
||||||
'users': ['help', 'invite', 'purge', 'roles', 'source'],
|
"bf5",
|
||||||
'pictures of animals': ['birb', 'redpanda', 'dale', 'dog', 'rat', 'koala', 'panda', 'raccoon', 'fox', 'cat', 'kangaroo'],
|
"ffxiv",
|
||||||
'admin': ['cleanup']
|
"clap",
|
||||||
|
"youtube",
|
||||||
|
"excuse",
|
||||||
|
"greentext",
|
||||||
|
"lewd",
|
||||||
|
"message",
|
||||||
|
"meme",
|
||||||
|
"homepage",
|
||||||
|
"pout",
|
||||||
|
"roll",
|
||||||
|
"smug",
|
||||||
|
"owo",
|
||||||
|
"wink",
|
||||||
|
"verify",
|
||||||
|
"horny",
|
||||||
|
"wasted",
|
||||||
|
"simp",
|
||||||
|
"trackdays",
|
||||||
|
],
|
||||||
|
"util": [
|
||||||
|
"ask",
|
||||||
|
"corona",
|
||||||
|
"emoji",
|
||||||
|
"8ball",
|
||||||
|
"decide",
|
||||||
|
"info",
|
||||||
|
"icon",
|
||||||
|
"wallpaper",
|
||||||
|
"stock",
|
||||||
|
"tts",
|
||||||
|
"issue",
|
||||||
|
],
|
||||||
|
"users": ["help", "invite", "purge", "roles", "source"],
|
||||||
|
"pictures of animals": [
|
||||||
|
"birb",
|
||||||
|
"redpanda",
|
||||||
|
"dale",
|
||||||
|
"dog",
|
||||||
|
"rat",
|
||||||
|
"koala",
|
||||||
|
"panda",
|
||||||
|
"raccoon",
|
||||||
|
"fox",
|
||||||
|
"cat",
|
||||||
|
"kangaroo",
|
||||||
|
],
|
||||||
|
"admin": ["cleanup"],
|
||||||
}
|
}
|
||||||
|
|
||||||
description = "\nBelow you can see all the commands I know.\n\n**Have a nice day!**"
|
description = "\nBelow you can see all the commands I know.\n\n**Have a nice day!**"
|
||||||
embed = discord.Embed(description=description, color=0x428bca, type="rich")
|
embed = discord.Embed(description=description, color=0x428BCA, type="rich")
|
||||||
embed.set_author(name="Hello! I'm {}".format(bot.user.name), icon_url=bot.user.default_avatar_url)
|
embed.set_author(
|
||||||
|
name="Hello! I'm {}".format(bot.user.name), icon_url=bot.user.default_avatar_url
|
||||||
|
)
|
||||||
|
|
||||||
for category in categories:
|
for category in categories:
|
||||||
command_list = []
|
command_list = []
|
||||||
for command in categories[category]:
|
for command in categories[category]:
|
||||||
command_list.append("`{}`".format(command))
|
command_list.append("`{}`".format(command))
|
||||||
embed.add_field(name="**%s**" % str(category).upper(), value=', '.join(command_list), inline=False)
|
embed.add_field(
|
||||||
|
name="**%s**" % str(category).upper(),
|
||||||
|
value=", ".join(command_list),
|
||||||
|
inline=False,
|
||||||
|
)
|
||||||
|
|
||||||
description2 = "**Use `!help <Command>` for more information about a command.** \n\n" + \
|
description2 = (
|
||||||
"**Examples:** \n `!help dog` for detailed help for the dog command \n\n" + \
|
"**Use `!help <Command>` for more information about a command.** \n\n"
|
||||||
"**Useful links:** [My source code](https://git.luker.gq/ldooks/dragon-bot), [Donate](https://cash.me/$ldooks) \n\n" + \
|
+ "**Examples:** \n `!help dog` for detailed help for the dog command \n\n"
|
||||||
"**Invite me to another server:** [Click here](https://discord.com/oauth2/authorize?client_id=%s&scope=bot&permissions=8)" % bot.user.id
|
+ "**Useful links:** [My source code](https://git.luker.gq/ldooks/dragon-bot), [Donate](https://cash.me/$ldooks) \n\n"
|
||||||
|
+ "**Invite me to another server:** [Click here](https://discord.com/oauth2/authorize?client_id=%s&scope=bot&permissions=8)"
|
||||||
|
% bot.user.id
|
||||||
|
)
|
||||||
|
|
||||||
embed.add_field(name="\u200b", value=description2, inline=False)
|
embed.add_field(name="\u200b", value=description2, inline=False)
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
def parse_message(message):
|
def parse_message(message):
|
||||||
method = message.split()[1]
|
method = message.split()[1]
|
||||||
try:
|
try:
|
||||||
|
78
app/lewds.py
78
app/lewds.py
@ -12,31 +12,25 @@ def get_from_danbooru(boards, nsfw=True):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
request = requests.get(
|
request = requests.get(
|
||||||
'https://danbooru.donmai.us/posts/random.json?tags=rating%3Aexplicit'
|
"https://danbooru.donmai.us/posts/random.json?tags=rating%3Aexplicit"
|
||||||
).json()
|
).json()
|
||||||
|
|
||||||
# List of tags we dont want images from
|
# List of tags we dont want images from
|
||||||
undesired_tags = [
|
undesired_tags = ["bestiality", "pee", "futa", "futanari", "yaoi"]
|
||||||
'bestiality',
|
|
||||||
'pee',
|
|
||||||
'futa',
|
|
||||||
'futanari',
|
|
||||||
'yaoi'
|
|
||||||
]
|
|
||||||
# If any undesired tags show up in the request, try again
|
# If any undesired tags show up in the request, try again
|
||||||
if not set(request['tag_string'].split()).isdisjoint(undesired_tags):
|
if not set(request["tag_string"].split()).isdisjoint(undesired_tags):
|
||||||
return get_from_danbooru(boards)
|
return get_from_danbooru(boards)
|
||||||
|
|
||||||
# Return the large firl url if available
|
# Return the large firl url if available
|
||||||
if 'large_file_url' in request.keys():
|
if "large_file_url" in request.keys():
|
||||||
if request['large_file_url'].startswith('/data/'):
|
if request["large_file_url"].startswith("/data/"):
|
||||||
return "https://danbooru.donmai.us{}".format(request['large_file_url'])
|
return "https://danbooru.donmai.us{}".format(request["large_file_url"])
|
||||||
return request['large_file_url']
|
return request["large_file_url"]
|
||||||
|
|
||||||
if 'file_url' in request.keys():
|
if "file_url" in request.keys():
|
||||||
if request['file_url'].startswith('/data/'):
|
if request["file_url"].startswith("/data/"):
|
||||||
return "https://danbooru.donmai.us{}".format(request['file_url'])
|
return "https://danbooru.donmai.us{}".format(request["file_url"])
|
||||||
return request['file_url']
|
return request["file_url"]
|
||||||
|
|
||||||
return get_from_danbooru(boards)
|
return get_from_danbooru(boards)
|
||||||
|
|
||||||
@ -51,30 +45,32 @@ def get_lewd():
|
|||||||
"""
|
"""
|
||||||
# List of subreddits that have the lewds we seek
|
# List of subreddits that have the lewds we seek
|
||||||
boards = [
|
boards = [
|
||||||
'2Booty',
|
"2Booty",
|
||||||
'ahegao',
|
"ahegao",
|
||||||
'bakunyuu_hentai',
|
"bakunyuu_hentai",
|
||||||
'BigAnimeTiddies',
|
"BigAnimeTiddies",
|
||||||
'hentaibreeding',
|
"hentaibreeding",
|
||||||
'hentaiclevage',
|
"hentaiclevage",
|
||||||
'oppailove',
|
"oppailove",
|
||||||
'ecchi',
|
"ecchi",
|
||||||
'fitdrawngirls',
|
"fitdrawngirls",
|
||||||
'musclegirlart',
|
"musclegirlart",
|
||||||
'fitmoe',
|
"fitmoe",
|
||||||
'hentai',
|
"hentai",
|
||||||
'rule34',
|
"rule34",
|
||||||
'rule34lol',
|
"rule34lol",
|
||||||
'WesternHentai',
|
"WesternHentai",
|
||||||
'doujinshi',
|
"doujinshi",
|
||||||
'hentai_gif',
|
"hentai_gif",
|
||||||
'muchihentai',
|
"muchihentai",
|
||||||
'Paizuri',
|
"Paizuri",
|
||||||
'chiisaihentai',
|
"chiisaihentai",
|
||||||
'dekaihentai',
|
"dekaihentai",
|
||||||
'WaifusGonewild',
|
"WaifusGonewild",
|
||||||
'thighdeology'
|
"thighdeology",
|
||||||
]
|
]
|
||||||
|
|
||||||
# This is really bad practice but pass boards to get_from_reddit AND danbooru so it doesnt error
|
# This is really bad practice but pass boards to get_from_reddit AND danbooru so it doesnt error
|
||||||
return random.choice([get_from_reddit.get_image, get_from_danbooru])(boards=boards, nsfw=True)
|
return random.choice([get_from_reddit.get_image, get_from_danbooru])(
|
||||||
|
boards=boards, nsfw=True
|
||||||
|
)
|
||||||
|
@ -3,19 +3,36 @@ import requests
|
|||||||
|
|
||||||
import help_methods
|
import help_methods
|
||||||
|
|
||||||
supported_templates = sorted(list(map(lambda x: x['id'], requests.get('https://api.memegen.link/templates/').json())))
|
supported_templates = sorted(
|
||||||
|
list(
|
||||||
|
map(
|
||||||
|
lambda x: x["id"],
|
||||||
|
requests.get("https://api.memegen.link/templates/").json(),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def parse_message(message):
|
def parse_message(message):
|
||||||
if len(message.split()) <= 2:
|
if len(message.split()) <= 2:
|
||||||
return get_meme_help()
|
return get_meme_help()
|
||||||
|
|
||||||
escaped_chars = {'_' : '__', ' ' : '_', '-' : '--', '?' : '~q', '%' : '~p', '#' : '~h', '/' : '~s', '\'\'' : '\"'}
|
escaped_chars = {
|
||||||
|
"_": "__",
|
||||||
|
" ": "_",
|
||||||
|
"-": "--",
|
||||||
|
"?": "~q",
|
||||||
|
"%": "~p",
|
||||||
|
"#": "~h",
|
||||||
|
"/": "~s",
|
||||||
|
"''": '"',
|
||||||
|
}
|
||||||
|
|
||||||
# Unwrap message from discord
|
# Unwrap message from discord
|
||||||
template = message.split()[1]
|
template = message.split()[1]
|
||||||
text = message.replace('!meme {}'.format(template), '').lstrip().split(',')
|
text = message.replace("!meme {}".format(template), "").lstrip().split(",")
|
||||||
upper = text[0].split(';')[0].lstrip()
|
upper = text[0].split(";")[0].lstrip()
|
||||||
lower = text[0].split(';')[1].lstrip()
|
lower = text[0].split(";")[1].lstrip()
|
||||||
|
|
||||||
# Escape special characters in upper/lower text
|
# Escape special characters in upper/lower text
|
||||||
for char, escaped in escaped_chars.items():
|
for char, escaped in escaped_chars.items():
|
||||||
@ -23,27 +40,30 @@ def parse_message(message):
|
|||||||
lower = lower.replace(char, escaped)
|
lower = lower.replace(char, escaped)
|
||||||
|
|
||||||
usesTemplate = True
|
usesTemplate = True
|
||||||
if template.startswith('http'):
|
if template.startswith("http"):
|
||||||
usesTemplate = False
|
usesTemplate = False
|
||||||
elif template not in supported_templates:
|
elif template not in supported_templates:
|
||||||
return 'Template not supported!'
|
return "Template not supported!"
|
||||||
|
|
||||||
return get_meme_url(template, upper, lower, usesTemplate)
|
return get_meme_url(template, upper, lower, usesTemplate)
|
||||||
|
|
||||||
|
|
||||||
def get_meme_url(template, upper, lower, usesTemplate):
|
def get_meme_url(template, upper, lower, usesTemplate):
|
||||||
#TODO: Implement format as a parameter?
|
# TODO: Implement format as a parameter?
|
||||||
base_URL = 'https://memegen.link'
|
base_URL = "https://memegen.link"
|
||||||
custom_URL = '{}/custom'.format(base_URL)
|
custom_URL = "{}/custom".format(base_URL)
|
||||||
default_format = 'jpg'
|
default_format = "jpg"
|
||||||
|
|
||||||
# Generate meme url
|
# Generate meme url
|
||||||
meme = '{}/{}/{}.{}?alt={}'.format(custom_URL, upper, lower, default_format, template)
|
meme = "{}/{}/{}.{}?alt={}".format(
|
||||||
|
custom_URL, upper, lower, default_format, template
|
||||||
|
)
|
||||||
if usesTemplate:
|
if usesTemplate:
|
||||||
meme = '{}/{}/{}/{}.{}'.format(base_URL, template, upper, lower, default_format)
|
meme = "{}/{}/{}/{}.{}".format(base_URL, template, upper, lower, default_format)
|
||||||
return meme
|
return meme
|
||||||
|
|
||||||
|
|
||||||
def get_meme_help():
|
def get_meme_help():
|
||||||
return "{}\nYou must supply a valid template for the meme. Templates are one of the following: \n```{}```".format(
|
return "{}\nYou must supply a valid template for the meme. Templates are one of the following: \n```{}```".format(
|
||||||
help_methods.get_help_message('meme'),
|
help_methods.get_help_message("meme"), ", ".join(supported_templates)
|
||||||
', '.join(supported_templates)
|
|
||||||
)
|
)
|
||||||
|
@ -3,7 +3,7 @@ import random
|
|||||||
|
|
||||||
|
|
||||||
def get_nft():
|
def get_nft():
|
||||||
url = "https://api.opensea.io/api/v1/bundles?limit=50&asset_contract_address=0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d"
|
url = "https://api.opensea.io/api/v1/bundles?limit=50&asset_contract_address=0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d"
|
||||||
x = requests.get(url).json()['bundles']
|
x = requests.get(url).json()["bundles"]
|
||||||
|
|
||||||
return random.choice(x)['assets'][0]['image_url']
|
return random.choice(x)["assets"][0]["image_url"]
|
||||||
|
429
app/quake.py
429
app/quake.py
@ -3,255 +3,294 @@ import requests
|
|||||||
import discord
|
import discord
|
||||||
import help_methods
|
import help_methods
|
||||||
|
|
||||||
base_url = 'https://stats.quake.com/api/v2/'
|
base_url = "https://stats.quake.com/api/v2/"
|
||||||
|
|
||||||
|
|
||||||
def parse_message(message):
|
def parse_message(message):
|
||||||
"""
|
"""
|
||||||
parse_message(message)
|
parse_message(message)
|
||||||
|
|
||||||
Handles the message and looks for the player's name.
|
Handles the message and looks for the player's name.
|
||||||
"""
|
"""
|
||||||
# Return the player's name
|
# Return the player's name
|
||||||
name = message.content.split()[1]
|
name = message.content.split()[1]
|
||||||
if len(message.content.split()) > 1:
|
if len(message.content.split()) > 1:
|
||||||
name = '%20'.join(message.content.split()[1:])
|
name = "%20".join(message.content.split()[1:])
|
||||||
|
|
||||||
return get_player_stats(player=name)
|
return get_player_stats(player=name)
|
||||||
|
|
||||||
|
|
||||||
def get_player_stats(player):
|
def get_player_stats(player):
|
||||||
"""
|
"""
|
||||||
get_player_stats(player)
|
get_player_stats(player)
|
||||||
|
|
||||||
Makes the request to stats.quake.com and returns an embed object with a
|
Makes the request to stats.quake.com and returns an embed object with a
|
||||||
bunch of data about the player
|
bunch of data about the player
|
||||||
"""
|
"""
|
||||||
player_endpoint = "Player/Stats?name={}".format(player)
|
player_endpoint = "Player/Stats?name={}".format(player)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
request = requests.get("{}{}".format(base_url, player_endpoint)).json()
|
request = requests.get("{}{}".format(base_url, player_endpoint)).json()
|
||||||
return create_embed(stats=request)
|
return create_embed(stats=request)
|
||||||
except Exception:
|
except Exception:
|
||||||
return discord.Embed(
|
return discord.Embed(
|
||||||
description="404, Player not found",
|
description="404, Player not found",
|
||||||
color=discord.Color.dark_red(),
|
color=discord.Color.dark_red(),
|
||||||
type="rich"
|
type="rich",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def create_embed(stats):
|
def create_embed(stats):
|
||||||
"""
|
"""
|
||||||
create_embed(stats)
|
create_embed(stats)
|
||||||
|
|
||||||
Expects a json blob to be passed in and then builds the embed
|
Expects a json blob to be passed in and then builds the embed
|
||||||
object
|
object
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Parse the json and pull out the numbers we want
|
# Parse the json and pull out the numbers we want
|
||||||
champ_name, play_time = get_favorite_champion(stats)
|
champ_name, play_time = get_favorite_champion(stats)
|
||||||
fav_weapon, fav_weapon_kills = get_favorite_weapon(stats)
|
fav_weapon, fav_weapon_kills = get_favorite_weapon(stats)
|
||||||
kd_ratio = get_kd(stats)
|
kd_ratio = get_kd(stats)
|
||||||
|
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
description="**All Time account statistics**",
|
description="**All Time account statistics**",
|
||||||
color=discord.Color.dark_red(),
|
color=discord.Color.dark_red(),
|
||||||
type="rich"
|
type="rich",
|
||||||
)
|
)
|
||||||
embed.set_author(
|
embed.set_author(
|
||||||
name="\nShowing stats for {}".format(stats['name']),
|
name="\nShowing stats for {}".format(stats["name"]),
|
||||||
icon_url="https://stats.quake.com/icons/{}.png".format(stats['playerLoadOut']['iconId'])
|
icon_url="https://stats.quake.com/icons/{}.png".format(
|
||||||
)
|
stats["playerLoadOut"]["iconId"]
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
embed.add_field(name="Current level:", value=stats['playerLevelState']['level'])
|
embed.add_field(name="Current level:", value=stats["playerLevelState"]["level"])
|
||||||
embed.add_field(name="Total XP:", value=stats['playerLevelState']['exp'])
|
embed.add_field(name="Total XP:", value=stats["playerLevelState"]["exp"])
|
||||||
embed.add_field(name="K/D:", value=kd_ratio)
|
embed.add_field(name="K/D:", value=kd_ratio)
|
||||||
|
|
||||||
embed.add_field(name="\u200b", value='\u200b', inline=False)
|
embed.add_field(name="\u200b", value="\u200b", inline=False)
|
||||||
|
|
||||||
embed.add_field(name="Favorite Champion:", value=champ_name)
|
embed.add_field(name="Favorite Champion:", value=champ_name)
|
||||||
embed.add_field(name="Total Playtime:", value="~{} hours".format(play_time))
|
embed.add_field(name="Total Playtime:", value="~{} hours".format(play_time))
|
||||||
|
|
||||||
embed.add_field(name="\u200b", value='\u200b', inline=False)
|
embed.add_field(name="\u200b", value="\u200b", inline=False)
|
||||||
|
|
||||||
embed.add_field(name="Favorite Weapon:", value=fav_weapon)
|
embed.add_field(name="Favorite Weapon:", value=fav_weapon)
|
||||||
embed.add_field(name="Num of kills with it:", value=fav_weapon_kills)
|
embed.add_field(name="Num of kills with it:", value=fav_weapon_kills)
|
||||||
|
|
||||||
embed.add_field(name="\u200b", value='\u200b', inline=False)
|
embed.add_field(name="\u200b", value="\u200b", inline=False)
|
||||||
|
|
||||||
# If they've played a ranked match, show the stats
|
# If they've played a ranked match, show the stats
|
||||||
if len(stats['playerRatings']['tdm']['history']):
|
if len(stats["playerRatings"]["tdm"]["history"]):
|
||||||
match_blob = get_match_stats(stats, stats['name'])
|
match_blob = get_match_stats(stats, stats["name"])
|
||||||
embed.add_field(name="Last Ranked Game:", value=match_blob)
|
embed.add_field(name="Last Ranked Game:", value=match_blob)
|
||||||
|
|
||||||
embed.set_footer(text="Stats pulled from https://stats.quake.com", icon_url='https://stats.quake.com/icons/profile_icon_cbt_participant.png')
|
embed.set_footer(
|
||||||
|
text="Stats pulled from https://stats.quake.com",
|
||||||
|
icon_url="https://stats.quake.com/icons/profile_icon_cbt_participant.png",
|
||||||
|
)
|
||||||
|
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
def get_favorite_champion(blob):
|
def get_favorite_champion(blob):
|
||||||
"""
|
"""
|
||||||
get_favorite_champion(blob)
|
get_favorite_champion(blob)
|
||||||
|
|
||||||
figure out who the players favorite champion is
|
figure out who the players favorite champion is
|
||||||
"""
|
"""
|
||||||
play_times = {}
|
play_times = {}
|
||||||
all_champions = blob['playerProfileStats']['champions']
|
all_champions = blob["playerProfileStats"]["champions"]
|
||||||
|
|
||||||
for champion in all_champions:
|
for champion in all_champions:
|
||||||
for game_mode in blob['playerProfileStats']['champions'][champion]['gameModes']:
|
for game_mode in blob["playerProfileStats"]["champions"][champion]["gameModes"]:
|
||||||
if champion in play_times:
|
if champion in play_times:
|
||||||
play_times[champion] += blob['playerProfileStats']['champions'][champion]['gameModes'][game_mode]['timePlayed']
|
play_times[champion] += blob["playerProfileStats"]["champions"][
|
||||||
play_times[champion] += blob['playerProfileStats']['champions'][champion]['gameModes'][game_mode]['rankedTimePlayed']
|
champion
|
||||||
else:
|
]["gameModes"][game_mode]["timePlayed"]
|
||||||
play_times[champion] = blob['playerProfileStats']['champions'][champion]['gameModes'][game_mode]['timePlayed']
|
play_times[champion] += blob["playerProfileStats"]["champions"][
|
||||||
play_times[champion] = blob['playerProfileStats']['champions'][champion]['gameModes'][game_mode]['rankedTimePlayed']
|
champion
|
||||||
|
]["gameModes"][game_mode]["rankedTimePlayed"]
|
||||||
|
else:
|
||||||
|
play_times[champion] = blob["playerProfileStats"]["champions"][
|
||||||
|
champion
|
||||||
|
]["gameModes"][game_mode]["timePlayed"]
|
||||||
|
play_times[champion] = blob["playerProfileStats"]["champions"][
|
||||||
|
champion
|
||||||
|
]["gameModes"][game_mode]["rankedTimePlayed"]
|
||||||
|
|
||||||
champion_play_time = max(play_times.values()) # maximum value
|
champion_play_time = max(play_times.values()) # maximum value
|
||||||
champion_name = [k for k, v in play_times.items() if v == champion_play_time][0] # getting all keys containing the `maximum`
|
champion_name = [k for k, v in play_times.items() if v == champion_play_time][
|
||||||
|
0
|
||||||
|
] # getting all keys containing the `maximum`
|
||||||
|
|
||||||
# Convert play_time from miliseconds to hours
|
# Convert play_time from miliseconds to hours
|
||||||
champion_play_time = round(float(champion_play_time)/(1000*60*60), 2)
|
champion_play_time = round(float(champion_play_time) / (1000 * 60 * 60), 2)
|
||||||
return(prettify(champion_name), champion_play_time)
|
return (prettify(champion_name), champion_play_time)
|
||||||
|
|
||||||
|
|
||||||
def get_favorite_weapon(blob):
|
def get_favorite_weapon(blob):
|
||||||
"""
|
"""
|
||||||
get_favorite_weapon(blob)
|
get_favorite_weapon(blob)
|
||||||
|
|
||||||
figure out what the players favorite weapon is
|
figure out what the players favorite weapon is
|
||||||
"""
|
"""
|
||||||
weapon_stats = {}
|
weapon_stats = {}
|
||||||
all_champions = blob['playerProfileStats']['champions']
|
all_champions = blob["playerProfileStats"]["champions"]
|
||||||
|
|
||||||
for champion in all_champions:
|
for champion in all_champions:
|
||||||
for weapon in blob['playerProfileStats']['champions'][champion]['damageStatusList']:
|
for weapon in blob["playerProfileStats"]["champions"][champion][
|
||||||
if weapon in weapon_stats:
|
"damageStatusList"
|
||||||
weapon_stats[weapon] += blob['playerProfileStats']['champions'][champion]['damageStatusList'][weapon]['kills']
|
]:
|
||||||
else:
|
if weapon in weapon_stats:
|
||||||
weapon_stats[weapon] = blob['playerProfileStats']['champions'][champion]['damageStatusList'][weapon]['kills']
|
weapon_stats[weapon] += blob["playerProfileStats"]["champions"][
|
||||||
|
champion
|
||||||
|
]["damageStatusList"][weapon]["kills"]
|
||||||
|
else:
|
||||||
|
weapon_stats[weapon] = blob["playerProfileStats"]["champions"][
|
||||||
|
champion
|
||||||
|
]["damageStatusList"][weapon]["kills"]
|
||||||
|
|
||||||
total_kills = max(weapon_stats.values()) # maximum value
|
total_kills = max(weapon_stats.values()) # maximum value
|
||||||
weapon_name = [k for k, v in weapon_stats.items() if v == total_kills][0] # getting all keys containing the `maximum`
|
weapon_name = [k for k, v in weapon_stats.items() if v == total_kills][
|
||||||
|
0
|
||||||
|
] # getting all keys containing the `maximum`
|
||||||
|
|
||||||
return(prettify(weapon_name), total_kills)
|
return (prettify(weapon_name), total_kills)
|
||||||
|
|
||||||
|
|
||||||
def get_kd(blob):
|
def get_kd(blob):
|
||||||
"""
|
"""
|
||||||
get_kd(blob)
|
get_kd(blob)
|
||||||
|
|
||||||
Parses json to find the player's k/d
|
Parses json to find the player's k/d
|
||||||
"""
|
"""
|
||||||
total_kills = 0
|
total_kills = 0
|
||||||
total_deaths = 0
|
total_deaths = 0
|
||||||
all_champions = blob['playerProfileStats']['champions']
|
all_champions = blob["playerProfileStats"]["champions"]
|
||||||
|
|
||||||
for champion in all_champions:
|
for champion in all_champions:
|
||||||
for game_mode in blob['playerProfileStats']['champions'][champion]['gameModes']:
|
for game_mode in blob["playerProfileStats"]["champions"][champion]["gameModes"]:
|
||||||
total_kills += blob['playerProfileStats']['champions'][champion]['gameModes'][game_mode]['kills']
|
total_kills += blob["playerProfileStats"]["champions"][champion][
|
||||||
total_deaths += blob['playerProfileStats']['champions'][champion]['gameModes'][game_mode]['deaths']
|
"gameModes"
|
||||||
|
][game_mode]["kills"]
|
||||||
|
total_deaths += blob["playerProfileStats"]["champions"][champion][
|
||||||
|
"gameModes"
|
||||||
|
][game_mode]["deaths"]
|
||||||
|
|
||||||
|
return round(float(total_kills / total_deaths), 2)
|
||||||
|
|
||||||
return round(float(total_kills/total_deaths), 2)
|
|
||||||
|
|
||||||
|
|
||||||
def get_match_stats(blob, target_player):
|
def get_match_stats(blob, target_player):
|
||||||
"""
|
"""
|
||||||
get_match_stats(blob, target_player)
|
get_match_stats(blob, target_player)
|
||||||
|
|
||||||
Takes the stats blob and a player name (so we know who's K/D we care about).
|
Takes the stats blob and a player name (so we know who's K/D we care about).
|
||||||
Attempts to figure out what the ranked game type was and then pulls stats from that game
|
Attempts to figure out what the ranked game type was and then pulls stats from that game
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Figure out which ranked gametype they last played
|
|
||||||
game_type = 'tdm' if blob['playerRatings']['tdm']['lastUpdated'] < blob['playerRatings']['duel']['lastUpdated'] else 'duel'
|
|
||||||
|
|
||||||
most_recent_match_id = blob['playerRatings'][game_type]['history'][0]['sessionId']
|
# Figure out which ranked gametype they last played
|
||||||
match_endpoint = "Player/Games?id={}".format(most_recent_match_id)
|
game_type = (
|
||||||
match_data = requests.get("{}{}".format(base_url, match_endpoint)).json()
|
"tdm"
|
||||||
fav_weapon = match_data['battleReportPersonalStatistics'][0]['bestWeapon']
|
if blob["playerRatings"]["tdm"]["lastUpdated"]
|
||||||
accuracy = match_data['battleReportPersonalStatistics'][0]['bestWeaponAccuracyPercent']
|
< blob["playerRatings"]["duel"]["lastUpdated"]
|
||||||
score = '-'.join(str(x) for x in match_data['teamScores'])
|
else "duel"
|
||||||
|
)
|
||||||
|
|
||||||
for team_mate in match_data['battleReportPersonalStatistics']:
|
most_recent_match_id = blob["playerRatings"][game_type]["history"][0]["sessionId"]
|
||||||
if team_mate['nickname'].lower() == target_player.lower():
|
match_endpoint = "Player/Games?id={}".format(most_recent_match_id)
|
||||||
earnedXp = team_mate['earnedXp']
|
match_data = requests.get("{}{}".format(base_url, match_endpoint)).json()
|
||||||
earnedFavor = team_mate['earnedFavor']
|
fav_weapon = match_data["battleReportPersonalStatistics"][0]["bestWeapon"]
|
||||||
|
accuracy = match_data["battleReportPersonalStatistics"][0][
|
||||||
|
"bestWeaponAccuracyPercent"
|
||||||
|
]
|
||||||
|
score = "-".join(str(x) for x in match_data["teamScores"])
|
||||||
|
|
||||||
kill_death_ratio = round(float(match_data['battleReportPersonalStatistics'][0]['kills']) / match_data['battleReportPersonalStatistics'][0]['deaths'], 2)
|
for team_mate in match_data["battleReportPersonalStatistics"]:
|
||||||
|
if team_mate["nickname"].lower() == target_player.lower():
|
||||||
return_blob = "Final score: {}\nK/D: {}\nFavorite Weapon: {} | {}% Accuracy\nXP Earned: {} | Favor Earned: {}".format(
|
earnedXp = team_mate["earnedXp"]
|
||||||
score,
|
earnedFavor = team_mate["earnedFavor"]
|
||||||
kill_death_ratio,
|
|
||||||
prettify(fav_weapon),
|
|
||||||
accuracy,
|
|
||||||
earnedXp,
|
|
||||||
earnedFavor,
|
|
||||||
)
|
|
||||||
|
|
||||||
return return_blob
|
kill_death_ratio = round(
|
||||||
|
float(match_data["battleReportPersonalStatistics"][0]["kills"])
|
||||||
|
/ match_data["battleReportPersonalStatistics"][0]["deaths"],
|
||||||
|
2,
|
||||||
|
)
|
||||||
|
|
||||||
|
return_blob = "Final score: {}\nK/D: {}\nFavorite Weapon: {} | {}% Accuracy\nXP Earned: {} | Favor Earned: {}".format(
|
||||||
|
score,
|
||||||
|
kill_death_ratio,
|
||||||
|
prettify(fav_weapon),
|
||||||
|
accuracy,
|
||||||
|
earnedXp,
|
||||||
|
earnedFavor,
|
||||||
|
)
|
||||||
|
|
||||||
|
return return_blob
|
||||||
|
|
||||||
|
|
||||||
def prettify(name):
|
def prettify(name):
|
||||||
"""
|
"""
|
||||||
prettify(name)
|
prettify(name)
|
||||||
|
|
||||||
Takes in an items name and returns a cleaned up / readable version
|
Takes in an items name and returns a cleaned up / readable version
|
||||||
"""
|
"""
|
||||||
|
|
||||||
item_map = {
|
item_map = {
|
||||||
'UNKNOWN_DAMAGE_TYPE' : 'Unknown Damage Type',
|
"UNKNOWN_DAMAGE_TYPE": "Unknown Damage Type",
|
||||||
'GAUNTLET' : 'Gauntlet',
|
"GAUNTLET": "Gauntlet",
|
||||||
'MACHINEGUN' : 'Machinegun',
|
"MACHINEGUN": "Machinegun",
|
||||||
'MACHINEGUN_GRADE1' : 'Heavy Machinegun',
|
"MACHINEGUN_GRADE1": "Heavy Machinegun",
|
||||||
'SHOTGUN' : 'Basic Shotgun',
|
"SHOTGUN": "Basic Shotgun",
|
||||||
'SHOTGUN_GRADE1' : 'Super Shotgun',
|
"SHOTGUN_GRADE1": "Super Shotgun",
|
||||||
'NAILGUN' : 'Nailgun',
|
"NAILGUN": "Nailgun",
|
||||||
'NAILGUN_GRADE1' : 'Super Nailgun',
|
"NAILGUN_GRADE1": "Super Nailgun",
|
||||||
'ROCKET_LAUNCHER' : 'Rocket Launcher',
|
"ROCKET_LAUNCHER": "Rocket Launcher",
|
||||||
'LIGHTNING_GUN' : 'Lightning Gun',
|
"LIGHTNING_GUN": "Lightning Gun",
|
||||||
'RAILGUN' : 'Railgun',
|
"RAILGUN": "Railgun",
|
||||||
'LAGBOLT' : 'TriBolt',
|
"LAGBOLT": "TriBolt",
|
||||||
'ACID_DOMAIN' : 'Environmental Acid Death',
|
"ACID_DOMAIN": "Environmental Acid Death",
|
||||||
'DAMAGE_DOMAIN' : 'Environmental Damage Death',
|
"DAMAGE_DOMAIN": "Environmental Damage Death",
|
||||||
'KILL_DOMAIN' : 'Environmental Kill Death',
|
"KILL_DOMAIN": "Environmental Kill Death",
|
||||||
'DIRE_ORB' : 'Dire Orb',
|
"DIRE_ORB": "Dire Orb",
|
||||||
'DIRE_ORB_EXPLOSION' : 'Dire Orb Explosion',
|
"DIRE_ORB_EXPLOSION": "Dire Orb Explosion",
|
||||||
'DIRE_ORB_TELEFRAG' : 'Dire Orb Telefrag',
|
"DIRE_ORB_TELEFRAG": "Dire Orb Telefrag",
|
||||||
'UNHOLY' : 'Galena\'s Totem',
|
"UNHOLY": "Galena's Totem",
|
||||||
'TELEFRAG' : 'Telefrag',
|
"TELEFRAG": "Telefrag",
|
||||||
'FALL_DAMAGE' : 'Fall Damage',
|
"FALL_DAMAGE": "Fall Damage",
|
||||||
'PLASMA_TRAIL' : 'Slash\'s Plasma Trail',
|
"PLASMA_TRAIL": "Slash's Plasma Trail",
|
||||||
'PLASMA_TRAIL_EXPLOSION' : 'Slash\'s Plasma Trail Explosion',
|
"PLASMA_TRAIL_EXPLOSION": "Slash's Plasma Trail Explosion",
|
||||||
'MINING_LASER' : 'Mining Laser',
|
"MINING_LASER": "Mining Laser",
|
||||||
'ABILITY_BERSERK' : 'Doom Slayer\'s Berserk Mode',
|
"ABILITY_BERSERK": "Doom Slayer's Berserk Mode",
|
||||||
'SWARM_GRENADE' : 'Keel\'s Swarm Grenade',
|
"SWARM_GRENADE": "Keel's Swarm Grenade",
|
||||||
'SB_DASH' : 'Scalbarer\'s Rush',
|
"SB_DASH": "Scalbarer's Rush",
|
||||||
'SB_STOMP' : 'Scalbarer\'s Stomp',
|
"SB_STOMP": "Scalbarer's Stomp",
|
||||||
'ACID_SPIT_DIRECT' : 'Acid Spit Direct',
|
"ACID_SPIT_DIRECT": "Acid Spit Direct",
|
||||||
'VENDETTA_TELEFRAG' : 'Vendetta Telefrag',
|
"VENDETTA_TELEFRAG": "Vendetta Telefrag",
|
||||||
'ACID_DOT' : 'Sorlag\'s Acid DOT',
|
"ACID_DOT": "Sorlag's Acid DOT",
|
||||||
'FLAME_DOT' : 'Flame DOT',
|
"FLAME_DOT": "Flame DOT",
|
||||||
'FLAME' : 'Flame',
|
"FLAME": "Flame",
|
||||||
'ACID' : 'Acid',
|
"ACID": "Acid",
|
||||||
'DRONE_KAMIKAZE_EXPLOSION' : 'Drone Kamikaze Explosion',
|
"DRONE_KAMIKAZE_EXPLOSION": "Drone Kamikaze Explosion",
|
||||||
'RECON_DRONE' : 'Recon Drone',
|
"RECON_DRONE": "Recon Drone",
|
||||||
'RECON_DRONE_EXPLOSION' : 'Recon Drone Explosion',
|
"RECON_DRONE_EXPLOSION": "Recon Drone Explosion",
|
||||||
'ANARKI': 'Anarki',
|
"ANARKI": "Anarki",
|
||||||
'ATHENA': 'Athena',
|
"ATHENA": "Athena",
|
||||||
'BJ_BLAZKOWICZ': 'BJ Blazkowicz',
|
"BJ_BLAZKOWICZ": "BJ Blazkowicz",
|
||||||
'CLUTCH': 'Clutch',
|
"CLUTCH": "Clutch",
|
||||||
'DEATH_KNIGHT': 'Death Knight',
|
"DEATH_KNIGHT": "Death Knight",
|
||||||
'DOOM_SLAYER': 'Doom Slayer',
|
"DOOM_SLAYER": "Doom Slayer",
|
||||||
'EISEN': 'Eisen',
|
"EISEN": "Eisen",
|
||||||
'GALENA': 'Galena',
|
"GALENA": "Galena",
|
||||||
'KEEL': 'Keel',
|
"KEEL": "Keel",
|
||||||
'NYX': 'Nyx',
|
"NYX": "Nyx",
|
||||||
'RANGER': 'Ranger',
|
"RANGER": "Ranger",
|
||||||
'SCALEBEARER': 'Scalebearer',
|
"SCALEBEARER": "Scalebearer",
|
||||||
'SLASH': 'Slash',
|
"SLASH": "Slash",
|
||||||
'SORLAG': 'Sorlag',
|
"SORLAG": "Sorlag",
|
||||||
'STROGG': 'Strogg',
|
"STROGG": "Strogg",
|
||||||
'VISOR': 'Visor',
|
"VISOR": "Visor",
|
||||||
}
|
}
|
||||||
|
|
||||||
return item_map[name]
|
return item_map[name]
|
||||||
|
@ -3,6 +3,7 @@ import wolframalpha
|
|||||||
|
|
||||||
import help_methods
|
import help_methods
|
||||||
|
|
||||||
|
|
||||||
def answer_question(message):
|
def answer_question(message):
|
||||||
"""
|
"""
|
||||||
answer_question(question)
|
answer_question(question)
|
||||||
@ -12,8 +13,8 @@ def answer_question(message):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if len(message.split()) > 1:
|
if len(message.split()) > 1:
|
||||||
client = wolframalpha.Client('2LU2Y7-YJQTA7TL8E')
|
client = wolframalpha.Client("2LU2Y7-YJQTA7TL8E")
|
||||||
question = ' '.join(message.split()[1:])
|
question = " ".join(message.split()[1:])
|
||||||
try:
|
try:
|
||||||
res = client.query(question)
|
res = client.query(question)
|
||||||
return next(res.results).text
|
return next(res.results).text
|
||||||
@ -21,6 +22,6 @@ def answer_question(message):
|
|||||||
try:
|
try:
|
||||||
return wikipedia.summary(question, sentences=5)
|
return wikipedia.summary(question, sentences=5)
|
||||||
except Exception:
|
except Exception:
|
||||||
return "Sorry, I\'m unable to answer that"
|
return "Sorry, I'm unable to answer that"
|
||||||
|
|
||||||
return help_methods.get_help_message('message')
|
return help_methods.get_help_message("message")
|
||||||
|
@ -5,37 +5,42 @@ import threading
|
|||||||
|
|
||||||
results = {}
|
results = {}
|
||||||
|
|
||||||
def get_river_stats(river_id):
|
|
||||||
url = requests.get("https://waterdata.usgs.gov/usa/nwis/uv?" + river_id)
|
|
||||||
|
|
||||||
soup = BeautifulSoup(url.content, "lxml")
|
|
||||||
river_name = ' '.join(soup.find('h2').text.split()[2:])
|
|
||||||
table = soup.find('table', border=1, align='left')
|
|
||||||
title = table.find('caption').text.strip().split('--')[0].strip()
|
|
||||||
|
|
||||||
for rows in table.findAll('tr'):
|
def get_river_stats(river_id):
|
||||||
flow_value = rows.findAll('td',{'class': 'highlight2'})
|
url = requests.get("https://waterdata.usgs.gov/usa/nwis/uv?" + river_id)
|
||||||
results[river_name] = flow_value[0].text
|
|
||||||
|
soup = BeautifulSoup(url.content, "lxml")
|
||||||
|
river_name = " ".join(soup.find("h2").text.split()[2:])
|
||||||
|
table = soup.find("table", border=1, align="left")
|
||||||
|
title = table.find("caption").text.strip().split("--")[0].strip()
|
||||||
|
|
||||||
|
for rows in table.findAll("tr"):
|
||||||
|
flow_value = rows.findAll("td", {"class": "highlight2"})
|
||||||
|
results[river_name] = flow_value[0].text
|
||||||
|
|
||||||
|
|
||||||
def get_stats():
|
def get_stats():
|
||||||
river_ids = [
|
river_ids = [
|
||||||
'06752260',
|
"06752260",
|
||||||
'07091200',
|
"07091200",
|
||||||
'06719505',
|
"06719505",
|
||||||
]
|
]
|
||||||
threads = []
|
threads = []
|
||||||
for river in river_ids:
|
for river in river_ids:
|
||||||
t = threading.Thread(target=get_river_stats, args=(river,))
|
t = threading.Thread(target=get_river_stats, args=(river,))
|
||||||
threads.append(t)
|
threads.append(t)
|
||||||
t.start()
|
t.start()
|
||||||
|
|
||||||
for x in threads:
|
for x in threads:
|
||||||
x.join()
|
x.join()
|
||||||
|
|
||||||
final_string = ''
|
final_string = ""
|
||||||
embed = discord.Embed(description=":man_rowing_boat: Flows :man_rowing_boat:", color=0x428bca, type="rich")
|
embed = discord.Embed(
|
||||||
embed.set_author(name="River stats")
|
description=":man_rowing_boat: Flows :man_rowing_boat:",
|
||||||
for key, value in results.items():
|
color=0x428BCA,
|
||||||
embed.add_field(name=key, value=value, inline=False)
|
type="rich",
|
||||||
return embed
|
)
|
||||||
|
embed.set_author(name="River stats")
|
||||||
|
for key, value in results.items():
|
||||||
|
embed.add_field(name=key, value=value, inline=False)
|
||||||
|
return embed
|
||||||
|
@ -5,6 +5,7 @@ This module's purpose is to handle permissions for interacting with the bot.
|
|||||||
The end goal is to be able to lock certain actions down to certain roles
|
The end goal is to be able to lock certain actions down to certain roles
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def check_permissions(user, roles_to_check):
|
def check_permissions(user, roles_to_check):
|
||||||
"""
|
"""
|
||||||
check_permissions(user)
|
check_permissions(user)
|
||||||
@ -26,7 +27,7 @@ def is_admin(user):
|
|||||||
|
|
||||||
Returns true if the user contains the ADMIN role
|
Returns true if the user contains the ADMIN role
|
||||||
"""
|
"""
|
||||||
return check_permissions(user, ['ADMIN'])
|
return check_permissions(user, ["ADMIN"])
|
||||||
|
|
||||||
|
|
||||||
def is_mod(user):
|
def is_mod(user):
|
||||||
@ -35,7 +36,7 @@ def is_mod(user):
|
|||||||
|
|
||||||
Returns true if the user contains the Moderator role
|
Returns true if the user contains the Moderator role
|
||||||
"""
|
"""
|
||||||
return check_permissions(user, ['Moderator'])
|
return check_permissions(user, ["Moderator"])
|
||||||
|
|
||||||
|
|
||||||
def docker_permissions(user):
|
def docker_permissions(user):
|
||||||
|
@ -3,15 +3,16 @@ import requests
|
|||||||
import core_utils
|
import core_utils
|
||||||
import get_from_reddit
|
import get_from_reddit
|
||||||
|
|
||||||
|
|
||||||
def change_bots_avatar():
|
def change_bots_avatar():
|
||||||
image = None
|
image = None
|
||||||
while not image:
|
while not image:
|
||||||
image = get_from_reddit.get_image(boards='smuganimegirls')
|
image = get_from_reddit.get_image(boards="smuganimegirls")
|
||||||
extension = image.split('.')[-1]
|
extension = image.split(".")[-1]
|
||||||
local_smug = "/tmp/smug.{}".format(extension)
|
local_smug = "/tmp/smug.{}".format(extension)
|
||||||
|
|
||||||
if extension.lower() in ['png', 'jpg']:
|
if extension.lower() in ["png", "jpg"]:
|
||||||
# save an image locally
|
# save an image locally
|
||||||
return open(core_utils.download_image(image, local_smug), 'rb').read()
|
return open(core_utils.download_image(image, local_smug), "rb").read()
|
||||||
else:
|
else:
|
||||||
image = None
|
image = None
|
||||||
|
89
app/stock.py
89
app/stock.py
@ -2,48 +2,87 @@ import discord
|
|||||||
import os
|
import os
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
|
||||||
def parse_message(msg):
|
def parse_message(msg):
|
||||||
if len(msg.split()) > 1:
|
if len(msg.split()) > 1:
|
||||||
try:
|
try:
|
||||||
res = ''
|
res = ""
|
||||||
for s in msg.split()[1:]:
|
for s in msg.split()[1:]:
|
||||||
res = get_stock(s)
|
res = get_stock(s)
|
||||||
except:
|
except:
|
||||||
res = '```Please input valid shares: !stock [share_name]```'
|
res = "```Please input valid shares: !stock [share_name]```"
|
||||||
return res
|
return res
|
||||||
return '```Please input at least one valid share: !stock [share_name]```'
|
return "```Please input at least one valid share: !stock [share_name]```"
|
||||||
|
|
||||||
|
|
||||||
def get_stock(share_name):
|
def get_stock(share_name):
|
||||||
share_name = share_name.upper()
|
share_name = share_name.upper()
|
||||||
# Fake headers to make yahoo happy
|
# Fake headers to make yahoo happy
|
||||||
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'}
|
headers = {
|
||||||
request_string = "https://query1.finance.yahoo.com/v7/finance/quote?lang=en-US®ion=US&corsDomain=finance.yahoo.com&symbols=%s" % share_name
|
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"
|
||||||
request = requests.get(request_string, headers=headers).json()['quoteResponse']['result'][0]
|
}
|
||||||
|
request_string = (
|
||||||
|
"https://query1.finance.yahoo.com/v7/finance/quote?lang=en-US®ion=US&corsDomain=finance.yahoo.com&symbols=%s"
|
||||||
|
% share_name
|
||||||
|
)
|
||||||
|
request = requests.get(request_string, headers=headers).json()["quoteResponse"][
|
||||||
|
"result"
|
||||||
|
][0]
|
||||||
|
|
||||||
change_symbol = '+'
|
change_symbol = "+"
|
||||||
embed_color = 2067276
|
embed_color = 2067276
|
||||||
meme_url = 'https://i.ytimg.com/vi/if-2M3K1tqk/hqdefault.jpg'
|
meme_url = "https://i.ytimg.com/vi/if-2M3K1tqk/hqdefault.jpg"
|
||||||
# If stock price has gone down since open, use red and a sad stonk meme
|
# If stock price has gone down since open, use red and a sad stonk meme
|
||||||
if float(request['bid']) < float(request['regularMarketOpen']):
|
if float(request["bid"]) < float(request["regularMarketOpen"]):
|
||||||
change_symbol = '-'
|
change_symbol = "-"
|
||||||
embed_color = 15158332
|
embed_color = 15158332
|
||||||
meme_url = 'https://i.ytimg.com/vi/E_XlA_IEzwM/hqdefault.jpg'
|
meme_url = "https://i.ytimg.com/vi/E_XlA_IEzwM/hqdefault.jpg"
|
||||||
|
|
||||||
embed = discord.Embed(description='-------', color=embed_color, type="rich")
|
embed = discord.Embed(description="-------", color=embed_color, type="rich")
|
||||||
embed.set_thumbnail(url=meme_url)
|
embed.set_thumbnail(url=meme_url)
|
||||||
embed.set_author(name=request['longName'])
|
embed.set_author(name=request["longName"])
|
||||||
embed.add_field(name='Current Price', value="$%s" % request['bid'], inline=False)
|
embed.add_field(name="Current Price", value="$%s" % request["bid"], inline=False)
|
||||||
embed.add_field(name='Previous Close', value="$%s" % request['regularMarketPreviousClose'], inline=False)
|
embed.add_field(
|
||||||
embed.add_field(name='Opening price', value="$%s" % request['regularMarketOpen'], inline=False)
|
name="Previous Close",
|
||||||
embed.add_field(name='Change', value="$%s" % request['regularMarketChange'], inline=False)
|
value="$%s" % request["regularMarketPreviousClose"],
|
||||||
embed.add_field(name='Change percent', value="%s%%" % request['regularMarketChangePercent'], inline=False)
|
inline=False,
|
||||||
embed.add_field(name='Day Low', value="$%s" % request['regularMarketDayLow'], inline=False)
|
)
|
||||||
embed.add_field(name='Day High', value="$%s" % request['regularMarketDayHigh'], inline=False)
|
embed.add_field(
|
||||||
embed.add_field(name='Day\'s Range', value=request['regularMarketDayRange'], inline=False)
|
name="Opening price", value="$%s" % request["regularMarketOpen"], inline=False
|
||||||
embed.add_field(name='Market Cap', value="{:,}".format(request['marketCap']), inline=False)
|
)
|
||||||
embed.add_field(name='Shares Outstanding', value="{:,}".format(request['sharesOutstanding']), inline=False)
|
embed.add_field(
|
||||||
embed.add_field(name='Link to stock price', value="https://finance.yahoo.com/quote/%s" % share_name, inline=False)
|
name="Change", value="$%s" % request["regularMarketChange"], inline=False
|
||||||
embed.set_footer(text="Pulled from https://finance.yahoo.com\nRemember, stocks can go up 100000%, but they can only go down 100%", icon_url='https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/emojidex/112/chart-with-downwards-trend_1f4c9.png')
|
)
|
||||||
|
embed.add_field(
|
||||||
|
name="Change percent",
|
||||||
|
value="%s%%" % request["regularMarketChangePercent"],
|
||||||
|
inline=False,
|
||||||
|
)
|
||||||
|
embed.add_field(
|
||||||
|
name="Day Low", value="$%s" % request["regularMarketDayLow"], inline=False
|
||||||
|
)
|
||||||
|
embed.add_field(
|
||||||
|
name="Day High", value="$%s" % request["regularMarketDayHigh"], inline=False
|
||||||
|
)
|
||||||
|
embed.add_field(
|
||||||
|
name="Day's Range", value=request["regularMarketDayRange"], inline=False
|
||||||
|
)
|
||||||
|
embed.add_field(
|
||||||
|
name="Market Cap", value="{:,}".format(request["marketCap"]), inline=False
|
||||||
|
)
|
||||||
|
embed.add_field(
|
||||||
|
name="Shares Outstanding",
|
||||||
|
value="{:,}".format(request["sharesOutstanding"]),
|
||||||
|
inline=False,
|
||||||
|
)
|
||||||
|
embed.add_field(
|
||||||
|
name="Link to stock price",
|
||||||
|
value="https://finance.yahoo.com/quote/%s" % share_name,
|
||||||
|
inline=False,
|
||||||
|
)
|
||||||
|
embed.set_footer(
|
||||||
|
text="Pulled from https://finance.yahoo.com\nRemember, stocks can go up 100000%, but they can only go down 100%",
|
||||||
|
icon_url="https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/emojidex/112/chart-with-downwards-trend_1f4c9.png",
|
||||||
|
)
|
||||||
|
|
||||||
return embed
|
return embed
|
||||||
|
120
app/trackdays.py
120
app/trackdays.py
@ -3,68 +3,76 @@ import json
|
|||||||
import requests
|
import requests
|
||||||
import xmltodict
|
import xmltodict
|
||||||
|
|
||||||
|
|
||||||
def get_msreg():
|
def get_msreg():
|
||||||
base_url = 'https://api.motorsportreg.com/rest/calendars/organization'
|
base_url = "https://api.motorsportreg.com/rest/calendars/organization"
|
||||||
orgs = {
|
orgs = {
|
||||||
'speeddistrict': '2E22740B-E8C9-9FB9-21406A496429A28B',
|
"speeddistrict": "2E22740B-E8C9-9FB9-21406A496429A28B",
|
||||||
'ongrid' : '06277C99-00C9-23EB-FD08FE5275BCC0C5',
|
"ongrid": "06277C99-00C9-23EB-FD08FE5275BCC0C5",
|
||||||
'speedsf' : '072A885E-AD68-6F64-E88C19E4D0D21DFB',
|
"speedsf": "072A885E-AD68-6F64-E88C19E4D0D21DFB",
|
||||||
'turn8' : 'F3469266-BEFF-E329-4FD6C4B189ACE2A8',
|
"turn8": "F3469266-BEFF-E329-4FD6C4B189ACE2A8",
|
||||||
'speedventures': 'DF7453ED-BF33-DC17-2C9BFD84C1F05E86',
|
"speedventures": "DF7453ED-BF33-DC17-2C9BFD84C1F05E86",
|
||||||
'nextlevel' : 'CC23AEA4-AAB1-D087-4A10818D229DAFD2',
|
"nextlevel": "CC23AEA4-AAB1-D087-4A10818D229DAFD2",
|
||||||
# 'corsaclub' : 'CE6E69CF-BAEC-DBB6-303EE7D3EC69B8A3',
|
"corsaclub": "CE6E69CF-BAEC-DBB6-303EE7D3EC69B8A3",
|
||||||
}
|
}
|
||||||
events = {}
|
events = {}
|
||||||
for org_name, org_id in orgs.items():
|
for org_name, org_id in orgs.items():
|
||||||
xml_blob = requests.get("%s/%s?exclude_cancelled=true&postalcode=95035&radius=500" % (base_url, org_id)).text
|
xml_blob = requests.get(
|
||||||
json_blob = json.loads(json.dumps(xmltodict.parse(xml_blob)['response']['events']))
|
"%s/%s?exclude_cancelled=true&postalcode=94549&radius=500"
|
||||||
|
% (base_url, org_id)
|
||||||
|
).text
|
||||||
|
json_blob = json.loads(
|
||||||
|
json.dumps(xmltodict.parse(xml_blob)["response"]["events"])
|
||||||
|
)
|
||||||
|
|
||||||
for event in json_blob['event']:
|
for event in json_blob["event"]:
|
||||||
tracks_we_care_about = ["buttonwillow", "thunderhill"]
|
tracks_we_care_about = ["buttonwillow", "thunderhill"]
|
||||||
try:
|
try:
|
||||||
if any(x in event['name'].lower() for x in tracks_we_care_about):
|
if any(x in event["name"].lower() for x in tracks_we_care_about):
|
||||||
event_object = {
|
event_object = {
|
||||||
'event_name': event['name'],
|
"event_name": event["name"],
|
||||||
'event_url': event['detailuri'].split('?utm')[0],
|
"event_url": event["detailuri"].split("?utm")[0],
|
||||||
'event_date': event['start'],
|
"event_date": event["start"],
|
||||||
}
|
}
|
||||||
track = event['venue']['name']
|
track = event["venue"]["name"]
|
||||||
if track not in events:
|
if track not in events:
|
||||||
events[track] = []
|
events[track] = []
|
||||||
events[track].append(event_object)
|
events[track].append(event_object)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
pass
|
pass
|
||||||
# sort track events by date
|
# sort track events by date
|
||||||
def date_to_datetime(input):
|
def date_to_datetime(input):
|
||||||
return datetime.strptime(input['event_date'], '%Y-%m-%d')
|
return datetime.strptime(input["event_date"], "%Y-%m-%d")
|
||||||
for races in events.values():
|
|
||||||
sorted(races, key=date_to_datetime)
|
|
||||||
|
|
||||||
return events
|
for races in events.values():
|
||||||
|
sorted(races, key=date_to_datetime)
|
||||||
|
|
||||||
|
return events
|
||||||
|
|
||||||
|
|
||||||
def get_corsa_club():
|
def get_corsa_club():
|
||||||
base_url = 'https://corsa.club'
|
base_url = "https://corsa.club"
|
||||||
events = {}
|
events = {}
|
||||||
products_blob = requests.get(base_url + '/products.json').json()['products']
|
products_blob = requests.get(base_url + "/products.json").json()["products"]
|
||||||
for event in products_blob:
|
for event in products_blob:
|
||||||
# Filter out hoodies and what not, only care about track days that list run-groups as the options
|
# Filter out hoodies and what not, only care about track days that list run-groups as the options
|
||||||
if any('Intermediate' in s for s in event['options'][0]['values']):
|
if any("Intermediate" in s for s in event["options"][0]["values"]):
|
||||||
# pp.pprint(event)
|
# pp.pprint(event)
|
||||||
event_object = {
|
event_object = {
|
||||||
'event_name': event['title'],
|
"event_name": event["title"],
|
||||||
'event_url': base_url + '/products/' + event['handle'],
|
"event_url": base_url + "/products/" + event["handle"],
|
||||||
'event_date': event['title'].split()[-1],
|
"event_date": event["title"].split()[-1],
|
||||||
}
|
}
|
||||||
track = ' '.join(event['title'].split()[0:-1])
|
track = " ".join(event["title"].split()[0:-1])
|
||||||
try:
|
try:
|
||||||
if track not in events:
|
if track not in events:
|
||||||
events[track] = []
|
events[track] = []
|
||||||
events[track].append(event_object)
|
events[track].append(event_object)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
return events
|
||||||
|
|
||||||
return events
|
|
||||||
|
|
||||||
# if __name__ == '__main__':
|
# if __name__ == '__main__':
|
||||||
# get_corsa_club()
|
# get_corsa_club()
|
||||||
|
23
app/tts.py
23
app/tts.py
@ -1,6 +1,7 @@
|
|||||||
from gtts import gTTS, lang
|
from gtts import gTTS, lang
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
|
||||||
def text_to_speech(input):
|
def text_to_speech(input):
|
||||||
"""
|
"""
|
||||||
text_to_speech(input)
|
text_to_speech(input)
|
||||||
@ -10,27 +11,24 @@ def text_to_speech(input):
|
|||||||
robot
|
robot
|
||||||
"""
|
"""
|
||||||
file, file_path = tempfile.mkstemp()
|
file, file_path = tempfile.mkstemp()
|
||||||
message = ' '.join(input.split()[1:])
|
message = " ".join(input.split()[1:])
|
||||||
|
|
||||||
language = 'en'
|
language = "en"
|
||||||
# check for another language denoted at the end of the message
|
# check for another language denoted at the end of the message
|
||||||
if ';' in message:
|
if ";" in message:
|
||||||
print(message.split(';'))
|
print(message.split(";"))
|
||||||
language = message.split(';')[1].strip()
|
language = message.split(";")[1].strip()
|
||||||
message = message.split(';')[0]
|
message = message.split(";")[0]
|
||||||
|
|
||||||
gTTS(
|
gTTS(text=message, lang=language, slow=False).save(file_path)
|
||||||
text=message,
|
|
||||||
lang=language,
|
|
||||||
slow=False
|
|
||||||
).save(file_path)
|
|
||||||
|
|
||||||
return file_path
|
return file_path
|
||||||
|
|
||||||
|
|
||||||
def get_all_langs():
|
def get_all_langs():
|
||||||
"""
|
"""
|
||||||
get_all_langs()
|
get_all_langs()
|
||||||
|
|
||||||
returns a dictionary with all supported languages
|
returns a dictionary with all supported languages
|
||||||
"""
|
"""
|
||||||
blob = ""
|
blob = ""
|
||||||
@ -38,4 +36,3 @@ def get_all_langs():
|
|||||||
blob += "{}: {}\n".format(key, value)
|
blob += "{}: {}\n".format(key, value)
|
||||||
|
|
||||||
return "```css\n{}```".format(blob)
|
return "```css\n{}```".format(blob)
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ from urllib.parse import urlparse
|
|||||||
import requests
|
import requests
|
||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
|
|
||||||
def get_wall(message):
|
def get_wall(message):
|
||||||
"""
|
"""
|
||||||
get_wall(message)
|
get_wall(message)
|
||||||
@ -17,7 +18,7 @@ def get_wall(message):
|
|||||||
search_terms = message.split()[1:]
|
search_terms = message.split()[1:]
|
||||||
|
|
||||||
# Turn search_terms into strings separated by commas
|
# Turn search_terms into strings separated by commas
|
||||||
joined_terms = ','.join(search_terms)
|
joined_terms = ",".join(search_terms)
|
||||||
|
|
||||||
# Add those comma separated strings onto the end of the URL variable
|
# Add those comma separated strings onto the end of the URL variable
|
||||||
url = unsplash_url + joined_terms
|
url = unsplash_url + joined_terms
|
||||||
@ -31,11 +32,12 @@ def get_wall(message):
|
|||||||
|
|
||||||
response = requests.get(url).url
|
response = requests.get(url).url
|
||||||
|
|
||||||
if 'photo-1446704477871-62a4972035cd' in response:
|
if "photo-1446704477871-62a4972035cd" in response:
|
||||||
return "Could not find an image for those tags."
|
return "Could not find an image for those tags."
|
||||||
else:
|
else:
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
def fcking_homepage():
|
def fcking_homepage():
|
||||||
"""
|
"""
|
||||||
fcking_homepage()
|
fcking_homepage()
|
||||||
@ -46,8 +48,8 @@ def fcking_homepage():
|
|||||||
soup = BeautifulSoup(url.content)
|
soup = BeautifulSoup(url.content)
|
||||||
|
|
||||||
for pic in soup.find_all("p"):
|
for pic in soup.find_all("p"):
|
||||||
if 'SWEET-ASS PICTURE' in ''.join(pic.findAll(text=True)):
|
if "SWEET-ASS PICTURE" in "".join(pic.findAll(text=True)):
|
||||||
link = pic.find_next_sibling('p')
|
link = pic.find_next_sibling("p")
|
||||||
if "http://" or "https://" in link.get('href', ''):
|
if "http://" or "https://" in link.get("href", ""):
|
||||||
link = link.find('small').find_next('a', href=True)['href']
|
link = link.find("small").find_next("a", href=True)["href"]
|
||||||
return urllib.parse.unquote(link.split('=')[1].split('&')[0])
|
return urllib.parse.unquote(link.split("=")[1].split("&")[0])
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import re
|
import re
|
||||||
from urllib import parse, request
|
from urllib import parse, request
|
||||||
|
|
||||||
def parse_message(message):
|
|
||||||
query_string = parse.urlencode({'search_query': message.split()[1:]})
|
|
||||||
html_content = request.urlopen('http://www.youtube.com/results?' + query_string)
|
|
||||||
search_results = re.findall('\/watch\?v=(.{11})', html_content.read().decode())
|
|
||||||
|
|
||||||
return 'https://www.youtube.com/watch?v=' + search_results[0]
|
def parse_message(message):
|
||||||
|
query_string = parse.urlencode({"search_query": message.split()[1:]})
|
||||||
|
html_content = request.urlopen("http://www.youtube.com/results?" + query_string)
|
||||||
|
search_results = re.findall("\/watch\?v=(.{11})", html_content.read().decode())
|
||||||
|
|
||||||
|
return "https://www.youtube.com/watch?v=" + search_results[0]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user