This repository has been archived by the owner on Oct 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
143 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
.idea/ | ||
log.txt | ||
cogs/avatar/ | ||
cogs/db/ | ||
tokens.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
channels = { | ||
"admin": "176304607172100097", | ||
"news": "179963038781276160", | ||
"private": "179945195280924673", | ||
"public": "176293292865093632", | ||
"rules": "179965419728273408" | ||
"general": "176293292865093632", | ||
"rules": "179965419728273408", | ||
"gaming": "179945195280924673", | ||
"tabletop": "188081332834926592", | ||
"technology": "188085243478147074", | ||
"programming": "188083195470807040", | ||
"giveaways": "188087131070005248" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
from discord.ext import commands | ||
import descriptions as desc | ||
import bs4 | ||
import requests | ||
import asyncio | ||
|
||
|
||
class Overwatch: | ||
def __init__(self, bot): | ||
""" | ||
Edit self.dates with releases we want to track | ||
""" | ||
self.bot = bot | ||
|
||
@commands.command(description=desc.ow, brief=desc.owb) | ||
async def overwatch(self, region: str, battletag: str): | ||
msg = await self.bot.say("Fetching Stats for {}".format(battletag)) | ||
|
||
user = battletag.replace("#", "-") | ||
|
||
reg_eu = ["eu", "euro", "europe"] | ||
reg_us = ["australia", "aussie", "aus", "us", "usa", "na", "america", "au"] | ||
reg_kr = ["asia", "korea", "kr", "as", "china", "japan"] | ||
|
||
if region.lower() in reg_eu: | ||
reg = "eu" | ||
elif region.lower() in reg_us: | ||
reg = "us" | ||
elif region.lower() in reg_kr: | ||
reg = "kr" | ||
else: | ||
self.bot.edit_message(msg, "Unknown region: {}".format(region)) | ||
return | ||
|
||
loop = asyncio.get_event_loop() | ||
future = loop.run_in_executor( | ||
None, requests.get, "https://playoverwatch.com/en-us/career/pc/{}/{}".format(reg, user)) | ||
res = await future | ||
|
||
try: | ||
res.raise_for_status() | ||
except Exception as e: | ||
await self.bot.edit_message(msg, "**Error with request. Please check for mistakes before trying again.**" | ||
".\nError: "+str(e)) | ||
return | ||
|
||
doc = bs4.BeautifulSoup(res.text, "html.parser") | ||
page = doc.select('div') | ||
most_played = page[82].select('div')[2].getText() | ||
most_games = page[82].select('div')[3].getText() | ||
game_swon = int(page[1111].select('div')[0].select('td')[1].getText()) | ||
games_played = int(page[1111].select('div')[0].select('td')[3].getText()) | ||
time_played = page[1111].select('div')[0].select('td')[11].getText() | ||
games_lost = games_played - game_swon | ||
won_lost = "{}/{}".format(game_swon, games_lost) | ||
|
||
await self.bot.edit_message(msg, "**Overwatch Stats for {} - {}**\n\n" | ||
"Time Played: *{}*\n" | ||
"Total Games: *{}*\n" | ||
"Games Won/Lost: *{}*\n" | ||
"Most Played Hero: *{}, {} played*" | ||
"".format(battletag, reg.upper(), time_played, games_played, | ||
won_lost, most_played, most_games)) | ||
|
||
|
||
def setup(bot): | ||
bot.add_cog(Overwatch(bot)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
import sqlite3 | ||
import os | ||
|
||
|
||
class Stats: | ||
def __init__(self, bot): | ||
self.bot = bot | ||
|
Oops, something went wrong.