Skip to content

Commit

Permalink
Merge pull request #34 from zeroquinc:remove-trophies
Browse files Browse the repository at this point in the history
chore: remove trophies support
  • Loading branch information
zeroquinc authored May 12, 2024
2 parents 6d04be8 + 5269228 commit 33413c2
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 285 deletions.
26 changes: 1 addition & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
# Retrocord

This bot is designed to keep track of your achievements and share them with your friends on Discord.

Support for:

[RetroAchievements](https://retroachievements.org)

[Sony PSN](https://www.playstation.com)
This bot is designed to keep track of your earned cheevos from [RetroAchievements](https://retroachievements.org) and share them with your friends on Discord.

Some features:

Expand Down Expand Up @@ -38,24 +32,6 @@ Some features:
</tr>
</table>

## Getting your PSN API Key

To get started you need to obtain npsso <64 character code>. You need to follow the following steps

1. Login into your My PlayStation account.

2. In another tab, go to https://ca.account.sony.com/api/v1/ssocookie

3. If you are logged in you should see a text similar to this

```
{"npsso":"<64 character npsso code>"}
```

This npsso code will be used in the api for authentication purposes. The refresh token that is generated from npsso lasts about 2 months.

From: https://psnawp.readthedocs.io/en/latest/additional_resources/README.html#getting-started

## Getting Started

To get started with Retrocord, follow these steps:
Expand Down
23 changes: 2 additions & 21 deletions cogs/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
from discord.ext import tasks, commands
from src.achievements import process_achievements
from src.daily_overview import process_daily_overview
from src.trophies import process_trophies
from src.presence import process_presence
from utils.time_utils import delay_until_next_interval, delay_until_next_midnight
from config.config import users, api_key, api_username, ACHIEVEMENTS_CHANNEL_ID, DAILY_OVERVIEW_CHANNEL_ID, MASTERY_CHANNEL_ID, TROPHIES_CHANNEL_ID, PLATINUM_CHANNEL_ID, RETROACHIEVEMENTS_INTERVAL, PRESENCE_INTERVAL, TROPHIES_INTERVAL, TASK_START_DELAY
from utils.datetime import delay_until_next_interval, delay_until_next_midnight
from config.config import users, api_key, api_username, ACHIEVEMENTS_CHANNEL_ID, DAILY_OVERVIEW_CHANNEL_ID, MASTERY_CHANNEL_ID, RETROACHIEVEMENTS_INTERVAL, PRESENCE_INTERVAL, TASK_START_DELAY
from utils.custom_logger import logger

class TasksCog(commands.Cog):
Expand All @@ -14,30 +13,12 @@ def __init__(self, bot: commands.Bot, start_delay: dict = None) -> None:
self.start_delay = start_delay or {}
self.process_achievements.start() # Always start the task when the cog is loaded
self.process_daily_overview.start() # Always start the task when the cog is loaded
self.process_trophies.start() # Always start the task when the cog is loaded

# Initialize the current_user_index to 0
self.users = users
self.current_user_index = 0
self.process_presence.start()

@tasks.loop(minutes=TROPHIES_INTERVAL)
async def process_trophies(self):
trophies_channel = self.bot.get_channel(TROPHIES_CHANNEL_ID)
platinum_channel = self.bot.get_channel(PLATINUM_CHANNEL_ID)
try:
await process_trophies(trophies_channel, platinum_channel)
except Exception as e:
logger.error(f'Error processing trophies: {e}')

@process_trophies.before_loop
async def before_process_trophies(self):
await self.bot.wait_until_ready() # Wait until the bot has connected to the discord API
if self.start_delay.get('process_trophies', False): # Only delay the start of the task if its value in the start_delay dictionary is True
delay = delay_until_next_interval('trophies') # Calculate the delay
logger.info(f'Waiting {delay} seconds for Trophies task to start')
await asyncio.sleep(delay) # Wait for the specified delay

@tasks.loop(minutes=RETROACHIEVEMENTS_INTERVAL)
async def process_achievements(self):
achievements_channel = self.bot.get_channel(ACHIEVEMENTS_CHANNEL_ID)
Expand Down
7 changes: 1 addition & 6 deletions config/config_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,15 @@
DISCORD_IMAGE = "https://i.postimg.cc/KvSTwcQ0/undefined-Imgur.png"
RETRO_DAILY_IMAGE = "https://i.imgur.com/P0nEGGs.png"

PSNTOKEN = ""
ACHIEVEMENTS_CHANNEL_ID = ""
DAILY_OVERVIEW_CHANNEL_ID = ""
MASTERY_CHANNEL_ID = ""
TROPHIES_CHANNEL_ID = ""
PLATINUM_CHANNEL_ID = ""
RETROACHIEVEMENTS_INTERVAL = 5
TROPHIES_INTERVAL = 60
PRESENCE_INTERVAL = 120

# The delay before starting the tasks, useful for debugging, otherwise it will start within the first 15th minute
TASK_START_DELAY = {
'process_achievements': True,
'process_daily_overview': True,
'process_presence': True,
'process_trophies': True
'process_presence': True
}
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ numpy==1.26.4
Pillow==10.3.0
pytz==2024.1
Requests==2.31.0
psnawp==1.3.3
scikit-learn==1.4.2
2 changes: 1 addition & 1 deletion services/achievement.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from config.config import BASE_URL
from datetime import datetime
import pytz
from utils.achievement_utils import CONSOLE_NAME_MAP
from utils.achievement import CONSOLE_NAME_MAP

class Achievement:
"""
Expand Down
4 changes: 2 additions & 2 deletions services/game.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from config.config import BASE_URL
from utils.achievement_utils import CONSOLE_NAME_MAP
from utils.time_utils import calculate_time_difference
from utils.achievement import CONSOLE_NAME_MAP
from utils.datetime import calculate_time_difference

class Game:
"""
Expand Down
4 changes: 2 additions & 2 deletions src/achievements.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from datetime import datetime

from services.api import UserProgressGameInfo, UserCompletionRecent, UserProfile, UserCompletionProgress, GameUnlocks
from utils.image_utils import get_discord_color
from utils.time_utils import ordinal
from utils.image import get_discord_color
from utils.datetime import ordinal
from config.config import api_key, api_username, DISCORD_IMAGE

from utils.custom_logger import logger
Expand Down
4 changes: 2 additions & 2 deletions src/daily_overview.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import discord

from services.api import UserCompletionByDate, UserProfile
from utils.image_utils import get_discord_color
from utils.time_utils import get_now_and_yesterday_epoch
from utils.image import get_discord_color
from utils.datetime import get_now_and_yesterday_epoch
from config.config import DISCORD_IMAGE, RETRO_DAILY_IMAGE
from utils.custom_logger import logger

Expand Down
136 changes: 0 additions & 136 deletions src/trophies.py

This file was deleted.

File renamed without changes.
20 changes: 0 additions & 20 deletions utils/date_utils.py

This file was deleted.

Loading

0 comments on commit 33413c2

Please sign in to comment.