Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

Commit

Permalink
0.1
Browse files Browse the repository at this point in the history
- Fixed commands
- Fixed for mods to update in monitor if removed or added
- Finished Read me with basic instructions
- Minor fixes
  • Loading branch information
UrekD committed Nov 3, 2021
1 parent 687cefe commit 475c150
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 8 deletions.
62 changes: 60 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,60 @@
# Steam-Workshop-Monitor
Discord bot to monitor collection of mods on the Steam Workshop and notify on update to selected discord server via Nextcordbot API.
# Steam-Workshop-Monitor<br />![GitHub all releases](https://img.shields.io/github/downloads/UrekD/Steam-Workshop-Monitor/total?style=for-the-badge) ![GitHub repo size](https://img.shields.io/github/repo-size/UrekD/Steam-Workshop-Monitor?style=for-the-badge) ![GitHub last commit](https://img.shields.io/github/last-commit/UrekD/Steam-Workshop-Monitor?style=for-the-badge) ![GitHub stars commit](https://img.shields.io/github/stars/UrekD/Steam-Workshop-Monitor?style=for-the-badge)

Discord bot to monitor collection of mods on the Steam Workshop and notify on update to selected Discord channel via Nextcordbot API.
# Requirements

- Python 3.10 or later
- Python pip -> requirements.txt
- Discord bot token
# Setup
**Linux**
```py
git clone https://github.com/UrekD/Steam-Workshop-Monitor/
cd Steam-Workshop-Monitor/
pip3 install -r requirements.txt
#Change vars on lines 10-15 of WorkshopMonitor.py
python3 WorkshopMonitor.py
#Wait till config fills then ctrl+c
#Comment out line 13 and start again
python3 WorkshopMonitor.py
```
**Windows**
```py
Downloadn the repo and extract to an empty folder
Open a CLI ex. CMD,PS,GitBash in the directory
pip3 install -r requirements.txt
#Change vars on lines 10-15 of WorkshopMonitor.py
python3 WorkshopMonitor.py
#Wait till config fills then ctrl+c
#Comment out line 13 and start again
python3 WorkshopMonitor.py
```
Will relocate vars to a separate config file, then a .exe for Windows should be possible.
# Commands
**$ping**

![image](https://user-images.githubusercontent.com/38784343/140180871-9647cb59-8bdd-4af5-bccf-f7864e572628.png)

**$list**

Returns a list of mods in a JSON object, format 'MODID#TIME'.
Time format is in Unix epoch time https://www.epochconverter.com/

![image](https://user-images.githubusercontent.com/38784343/140181008-43802124-4154-461f-ad78-50a2a69f9425.png)

**$remove**

Firstly locate the mod via the ID and copy the whole format and remove it via the command.

![image](https://user-images.githubusercontent.com/38784343/140181570-7d4b4d49-3468-4919-9571-febe9ccd0ad8.png)

**$add**

Add the mod with the following format MODID#000 ex. "$add 450814997#000"
If you use 000 it should not trigger a update notification.

![image](https://user-images.githubusercontent.com/38784343/140181637-731a1a32-6538-406e-8fcc-0e5eb925c143.png)

# Example

![image](https://user-images.githubusercontent.com/38784343/140175801-4395f62c-a4bf-4de5-9f50-59e4909336a2.png)
14 changes: 8 additions & 6 deletions WorkshopMonitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ async def Monitor():
now = datetime.datetime.now()
print (now.strftime(f"{Fore.MAGENTA}[Monitor] Start {Style.RESET_ALL}%H:%M:%S"))
i = 0
mods = config["userdata"].get('workshopid')
for mod in mods:
mod = mod.split('#')
try:
await CheckOne(mod,i)
except:
print(now.strftime(f"{Fore.MAGENTA}[ERROR] {Style.RESET_ALL}%H:%M:%S {mod}"))
await err(mod[0])
i = i+1
print (now.strftime(f"{Fore.MAGENTA}[Monitor] End {Style.RESET_ALL}%H:%M:%S"))
async with aiofiles.open('config.json', mode='w') as jsfile:
Expand All @@ -41,6 +43,10 @@ async def update(uid):
channel = bot.get_channel(where)
await channel.send(f"Mod Updated: https://steamcommunity.com/sharedfiles/filedetails/?id={uid} <@&{nrole}>")

async def err(uid):
channel = bot.get_channel(where)
await channel.send(f"ERROR: https://steamcommunity.com/sharedfiles/filedetails/?id={uid} Unable to retreive!")

async def CheckOne(modC,i):
body = 'itemcount=1&publishedfileids[0]=2638049909'
url = 'https://api.steampowered.com/ISteamRemoteStorage/GetPublishedFileDetails/v1/'
Expand Down Expand Up @@ -92,7 +98,7 @@ async def my_background_task(self,LA):
await Monitor()
await channel.send("Checking finished sleeping...")
event.clear()
await asyncio.sleep(tcheck)
await asyncio.sleep(ctime)

bot = Bot(command_prefix='$')

Expand All @@ -117,9 +123,7 @@ async def remove(ctx,arg):
if ctx.channel.name == cname:
if event.is_set() == False:
try:
async with aiofiles.open('config.json', "rb") as infile:
config = json.load(infile)
idsx = config["userdata"]['workshopid']
idsx = config["userdata"]['workshopid']
idsx.remove(arg)
config["userdata"]['workshopid'] = idsx
async with aiofiles.open('config.json', mode='w') as jsfile:
Expand All @@ -139,8 +143,6 @@ async def add(ctx,arg):
if ctx.channel.name == cname:
if event.is_set() == False:
try:
async with aiofiles.open('config.json', "rb") as infile:
config = json.load(infile)
idsx = config["userdata"]['workshopid']
idsx.append(arg)
config["userdata"]['workshopid'] = idsx
Expand Down

0 comments on commit 475c150

Please sign in to comment.