Skip to content

Commit

Permalink
Merge pull request #9 from hhollenstain/re-write
Browse files Browse the repository at this point in the history
Adding Overwatch stats plugin
  • Loading branch information
hhollenstain authored Oct 14, 2018
2 parents e11ad71 + 66bf892 commit 572c058
Show file tree
Hide file tree
Showing 13 changed files with 491 additions and 28 deletions.
152 changes: 152 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import json
import over_stats

# Initialize a player profile by providing the player tag and the platform.
# the platform is optional and by default it is 'pc'. Other valid values are
# 'xbl' and 'psn'
player_data = over_stats.PlayerProfile('Cyrus#1852')
# or
# player_data = over_stats.PlayerProfile('acesarramsan', over_stats.PLAT_PSN)

# Ther is a bug in the boto3 library that causes it not to be able to handle
# floats. To get around this issue there is flag that you can use to wrap floats
# into a Decimal. Be careful that Decimals cannot be dumped to json.
# player_data = over_stats.PlayerProfile('acesarramsan', over_stats.PLAT_PSN, True)

# Download and parse the profile's data
player_data.load_data()

# Print the entire profile's data in JSON format
# print (json.dumps(player_data.raw_data, indent=4))

# You can also use the helper methods to access the data you want
for mode in over_stats.MODES:
# mode will be 'quickplay' or 'competitive'
# print (f"Game Mode: {mode}")
# print ("Comparison Types Available: " + str(player_data.comparison_types(mode)))
# for comparison_type in player_data.comparison_types(mode):
# # A comparison type will be one of the options in the 'Top Heroes' section, 'Times Played', 'Games Won',
# # 'Weapon Accuracy', etc
# print (f" - Comparison Type: {comparison_type}")
# print (" - Heroes available to compare: " + str(player_data.comparison_heroes(mode, comparison_type)))
# for comparison_hero in player_data.comparison_heroes(mode, comparison_type):
# # The comparison_hero be each hero in this list. The comparisons() method will return the value linked to each hero
# print (" - " + comparison_hero + ": " + str(player_data.comparisons(mode, comparison_type, comparison_hero)))

# This data belongs to the 'career_stats'. The values for hero will be 'All Heroes', 'Reaper', 'Tracer', etc.
print ("Heroes with Stats Available: " + str(player_data.stat_heroes(mode)))
for hero in player_data.stat_heroes(mode):
print (f" - Hero: {hero}")
# The category represents each card in for the selected hero, for example 'Combat', 'Assists', etc.
print (" - Categories available for stats " + str(player_data.stat_categories(mode, hero)))
for category in player_data.stat_categories(mode, hero):
print (f" - Category: {category}")
print (" - Stats available: " + str(player_data.stat_names(mode, hero, category)))
# for stat_name in player_data.stat_names(mode, hero, category):
# # This will print each stat from each category along with it's value
# print (" - " + stat_name + ": " + str(player_data.stats(mode, hero, category, stat_name)))

# # Achievements do not depend on game mode and instead they use categories like 'General', 'Offence', 'Defense', etc
# print ("Achievemet Types Available: " + str(player_data.achievement_types()))
# for achievement_type in player_data.achievement_types():
# print (f"Achievement Type: {achievement_type}")
# # Each achievement category contains two lists, one with acquired achievements and one for missing achievements.
# print (f" - {over_stats.ACH_EARNED}")
# for achievement in player_data.achievements(achievement_type, over_stats.ACH_EARNED):
# # Print each earned achievements
# print (f" - {achievement}")
# print (f" - {over_stats.ACH_MISSING}")
# for achievement in player_data.achievements(achievement_type, over_stats.ACH_MISSING):
# # Print each achievement that this player does not yet have
# print (f" - {achievement}")
35 changes: 35 additions & 0 deletions kwargs_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
KWARGS = { 'pc': 'platform',
'psn': 'platform',
'xbox': 'platform',
'comp': 'mode',
'competitive': 'mode',
'qp': 'mode',
'quickplay': 'mode',
}

KWARGS_DEFAULT =

def kwarg_generator(kwargs_map, args):
kwargs = {}
for arg in args:
if arg in kwargs_map:
kwargs[kwargs_map[arg]] = arg
if arg.isdigit()
kwargs['top'] = arg

if 'top' not in kwargs:
kwargs['top'] =
return kwargs


def test_kwargs(kwargs):
print(kwargs['mode'])
print(kwargs['platform'])



test_args=['qp', 'pc',]

kwargs = kwarg_generator(KWARGS, test_args)

test_kwargs(kwargs)
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
'aiomeasures',
'coloredlogs',
'over_stats',
'oyaml',
'PyNaCl',
'pyowm',
'python-overwatch',
'pyyaml',
'youtube_dl'
]

Expand Down
2 changes: 1 addition & 1 deletion tamago/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
init - version info
"""
VERSION_INFO = (0, 1, 0)
VERSION_INFO = (0, 1, 1)
VERSION = '.'.join(str(c) for c in VERSION_INFO)
4 changes: 2 additions & 2 deletions tamago/lib/plugins/fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ async def eight_ball(self, ctx):
'It is quite possible',
'Definitely',
]
await self.tamago.say('{}, {}'.format(random.choice(possible_responses),
ctx.message.author.mention))
await ctx.send('{}, {}'.format(random.choice(possible_responses),
ctx.message.author.mention))

@commands.command(pass_context=True)
async def hello(self, ctx):
Expand Down
21 changes: 18 additions & 3 deletions tamago/lib/plugins/mod_tools.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import discord
import logging
from discord.ext import commands
from tamago.lib import utils

LOG = logging.getLogger(__name__)

Expand All @@ -11,12 +12,26 @@ def __init__(self, client):
@commands.command(pass_context=True)
@commands.has_permissions(manage_messages=True, administrator=True)
async def clear(self, ctx, amount=5):
"""
Clears messages by !clear #ofmessages [@user]
:param class self: tamago bot client
:param context ctx: context of the message sent
"""
channel = ctx.message.channel
messages = []
async for message in channel.history(limit=int(amount) + 1):
messages.append(message)
if ctx.message.mentions:
mentions = []
for member in ctx.message.mentions:
mentions.append(member.id)
async for message in channel.history(limit=int(amount) + 1):
if message.author.id in mentions:
messages.append(message)
else:
async for message in channel.history(limit=int(amount) + 1):
messages.append(message)

await channel.delete_messages(messages)
await ctx.send('%s messages purged' % amount)
await ctx.send('{} messages purged'.format(len(messages)))

@commands.command(name='getid', aliases=['id'], pass_context=True)
@commands.has_permissions(manage_messages=True, administrator=True)
Expand Down
Loading

0 comments on commit 572c058

Please sign in to comment.