Giter Site home page Giter Site logo

justtemmie / steam-presence Goto Github PK

View Code? Open in Web Editor NEW
198.0 4.0 11.0 955 KB

A script that takes the game you're playing on steam and displays it on discord

License: MIT License

Python 91.01% Shell 8.99%
discord discord-rich-presence linux python rich-presence steam steam-deck steamdeck games syncronization

steam-presence's Introduction

Hi πŸ‘‹

I tend to go by Twig or Temmie - I'm a norwegian highschool student, and a developer in my free time. I create games, discord bots, websites, and other nifty scripts; i have a tendency to play bad apple on anything i can get my hands on, ranging from minecraft to a lego EV microcontroller

I have a secondary github page for anything i don't want to clutter my main profile with, you might find something nifty on it!

πŸ“Š GitHub Stats

steam-presence's People

Contributors

ahmed-kaid avatar akkornel avatar alba4k avatar ash2x3zb9cy avatar confuzled avatar justtemmie avatar miermontoto avatar noplagiarism avatar radiicall avatar spaceykasey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

steam-presence's Issues

Enhanced Rich Presence not working

Hi, thank you so much for your work on this, it's really cool.

I am not sure if this is an issue with the code, my Steam/Discord or something unique to Paradox games where the rich presence can vary wildly, but it's not showing up for me. I can supply you with more detailed info, but this is what it looks like:
image
image

I did read your issue from March where you were trying to figure this out. I assume that maybe Paradox games, with their many countries and variables such as the year the game is at, might not work the same way. However, something like Baldur's Gate 3, which only has about 4-5 different presence descriptions, also doesn't work. The review and store button do work though (cool features too).

This is what my config file looks like, with the personal stuff removed:

  {
      "STEAM_API_KEY": "key",
      "USER_IDS": "id",
  
      "DISCORD_APPLICATION_ID": "id",
  
      "FETCH_STEAM_RICH_PRESENCE": true,
      "FETCH_STEAM_REVIEWS": false,
      "ADD_STEAM_STORE_BUTTON": false,
  
      "WEB_SCRAPE": false,
      
      "COVER_ART": {
          "STEAM_GRID_DB": {
              "ENABLED": true,
              "STEAM_GRID_API_KEY": "key"
          },
          "USE_STEAM_STORE_FALLBACK": true
      },
  
      "LOCAL_GAMES": {
          "ENABLED": false,
          "LOCAL_DISCORD_APPLICATION_ID": "",
          "GAMES": [
              "processName1",
              "processName2",
              "processName3",
              "so on"
          ]
      },
  
      "GAME_OVERWRITE": {
          "ENABLED": false,
          "NAME": "Breath of the wild, now on Steam!",
          "SECONDS_SINCE_START": 0
      },
  
      "CUSTOM_ICON": {
          "ENABLED": false,
          "URL": "https://raw.githubusercontent.com/JustTemmie/steam-presence/main/readmeimages/defaulticon.png",
          "TEXT": "Steam Presence on Discord"
      }
  }

And here is the log:

[Nov 22 2023 - 21:20:51] found game Stellaris played by -
[Nov 22 2023 - 21:20:52] steam app ID 281990 found for Stellaris
[Nov 22 2023 - 21:20:52] game changed, updating to 'Stellaris'
[Nov 22 2023 - 21:20:52] fetching the Discord game ID for Stellaris
[Nov 22 2023 - 21:20:53] found the discord game ID for stellaris
[Nov 22 2023 - 21:20:53] fetching icon for Stellaris
[Nov 22 2023 - 21:20:53] found icon for Stellaris in cache
[Nov 22 2023 - 21:20:53] creating new rich presence object for Stellaris
[Nov 22 2023 - 21:20:53] pushing presence to Discord

I noticed that it doesn't log the
log(f"setting the details for {gameName} to {gameRichPresence}")
under the setPresenceDetails() function so I'm assuming it satisfying the if check there for some reason?

I can confirm that neither Discord nor Steam are running as admin. I'm not sure if anything obvious is wrong but I will keep trying. Otherwise, would love your help on this. Once again, thanks for the cool script! Awesome work. Sorry if there is an obvious answer or solution to this somewhere and I missed it.

Errors running main.py and installer.sh

When I try to run main.py, it says:
Forbidden, Access to the steam API has been denied, please verify your steam API key

I tried resetting my API key a couple times, and I tried using the domains localhost and 127.0.0.1.

I am not sure what to make of this error, as I have used my API key in the past for Steam Idler, and it worked successfully.

As for installer.sh, when I try to run it, it says:
Error: config.json file not found. Please make sure it exists in the current directory

This is simply not the case, because I set up the config.json file in the directory in my Home/steam-presence directory.
I was not sure if this was because I have VSCodium open, but closing Codium still yields the same results.

Thank you in advance for any support you can provide!

Script Error Upon running /installer.sh

Trying to get this to work on my arch linux system. Any idea?

Testing if the script works


[Aug 23 2023 - 09:51:25] progam's current folder structure version is up to date...

[Aug 23 2023 - 09:51:25] loading config file
Traceback (most recent call last):
File "/home/phantom/steam-presence/./main.py", line 1058, in
main()
File "/home/phantom/steam-presence/./main.py", line 869, in main
config = getConfigFile()
^^^^^^^^^^^^^^^
File "/home/phantom/steam-presence/./main.py", line 138, in getConfigFile
userSettings = json.load(f)
^^^^^^^^^^^^
File "/usr/lib/python3.11/json/init.py", line 293, in load
return loads(fp.read(),
^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/json/init.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/json/decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
^^^^^^^^^^^^^^^^^^^^^^
json.decoder.JSONDecodeError: Expecting ':' delimiter: line 5 column 6 (char 141)

Here is my config file:
image

Errors while running "installer.sh" on Linux Mint 21.2 Xfce

After i run the installer file in the terminal i get these errors when testing if the script works

ERROR: [Sep 29 2023 - 16:37:11] error encountered whilst trying to update the config-version to version 1, exiting
Error encountered: [Errno 2] No such file or directory: '/home/alex_rainbowman/steam-presence/icons.txt'
/home/alex_rainbowman/steam-presence/installer.sh: line 48: kill: (10908) - No such process
Test might've worked, did it spit out any errors?
Commands executed.
Setting up service file for Linux
sed: can't read /home/alex_rainbowman/steam-presence.service: No such file or directory
Starting service
Failed to enable unit: Unit file /home/alex_rainbowman/.config/systemd/user/steam-presence.service is masked.

Any idea what is happening? (I'm kinda new to Linux)

Icons.txt error

Your code references path to /icons.txt but the file itself is in data/icons.txt. The scripts throws an error because of it.

Detecting the "enhanced rich presence" information of steam games

Certain games on steam support "enhanced rich presence" I.E the same thing discord rich presence does, but thru steam
example:
image
steam's own documentation:
enhanced rich presence

It would be great to be able to detect this as it could be directly forwarded into the discord rich presence, but...

I've spent an unbelievable amount of time trying to find a way to fetch this information, as it's not actually returned by the steam API in any capacity.
The only possible way i can think of making this supported is by getting the user's login token, meaning having the user either writing in their account name, password, and the 2FA seed, or by having the user download the cookies from steam in their browser. then using web scraping to load the chat tab, then scraping the data from there. This is very scuffed and i really don't want to implement it in this way.

If you know any other way of getting this data, please create a comment informing me how so i can add this as a feature

Unable to launch main.py

When I try to launch Main.py through the terminal (Python3 main.py), I get the following error.
Traceback (most recent call last):
File "/home/kiki/steam-presence/main.py", line 1147, in
main()
File "/home/kiki/steam-presence/main.py", line 920, in main
checkForUpdate()
File "/home/kiki/steam-presence/main.py", line 902, in checkForUpdate
if int(new) > int(old):
^^^^^^^^

I have tried to delete and git clone the folder to maybe fix it, but it ended not working
Screenshot_20240103_224047

To specific python version in installer.sh

Hey,

in the file installer.sh I had problems, because in line 65 the command is python3.10 -m venv .
This created errors on my machine as I have Python 3.11.3 installe, so python3.10 isn't working.

Changing the line to python3 -m venv . solved the problem and should be future proof (as long as 3 is the main version).

Unsupported os (opensuse tumbleweed)

when running the installer.sh it will spit out that opensuse isnt supported even tho its linux
no other errors appear

This script is for Linux and macOS, and it's still in testing phases. If you encounter any bugs, please open an issue.
Press the enter key to continue...

Setting up virtual environment
mkdir: cannot create directory β€˜venv’: File exists
Requirement already satisfied: pip in ./lib64/python3.11/site-packages (23.3.1)
Requirement already satisfied: wheel in ./lib64/python3.11/site-packages (0.42.0)
Requirement already satisfied: python-steamgriddb in ./lib64/python3.11/site-packages (from -r ../requirements.txt (line 1)) (1.0.5)
Requirement already satisfied: pypresence in ./lib64/python3.11/site-packages (from -r ../requirements.txt (line 2)) (4.3.0)
Requirement already satisfied: beautifulsoup4 in ./lib64/python3.11/site-packages (from -r ../requirements.txt (line 3)) (4.12.2)
Requirement already satisfied: requests in ./lib64/python3.11/site-packages (from -r ../requirements.txt (line 4)) (2.31.0)
Requirement already satisfied: psutil in ./lib64/python3.11/site-packages (from -r ../requirements.txt (line 5)) (5.9.6)
Requirement already satisfied: soupsieve>1.2 in ./lib64/python3.11/site-packages (from beautifulsoup4->-r ../requirements.txt (line 3)) (2.5)
Requirement already satisfied: charset-normalizer<4,>=2 in ./lib64/python3.11/site-packages (from requests->-r ../requirements.txt (line 4)) (3.3.2)
Requirement already satisfied: idna<4,>=2.5 in ./lib64/python3.11/site-packages (from requests->-r ../requirements.txt (line 4)) (3.6)
Requirement already satisfied: urllib3<3,>=1.21.1 in ./lib64/python3.11/site-packages (from requests->-r ../requirements.txt (line 4)) (2.1.0)
Requirement already satisfied: certifi>=2017.4.17 in ./lib64/python3.11/site-packages (from requests->-r ../requirements.txt (line 4)) (2023.11.17)

Testing if the script works


[Dec 02 2023 - 22:52:41] progam's current folder structure version is up to date...

[Dec 02 2023 - 22:52:41] loading config file
[Dec 02 2023 - 22:52:41] everything is ready!

[Dec 02 2023 - 22:52:42] found game NARAKA: BLADEPOINT played by Pollux
Test might've worked, did it spit out any errors?
Commands executed.
Unsupported OS. This script is designed for Linux and macOS only.

Installation & Slight problem

Am I suppose to install on both my steam deck and my PC windows? Because I currently have it on the steam deck and whenever I try to load the /bin/python and /main.py it says "everything is ready" except it denies my steam API although its correct.

Add support for multiple accounts

Hey, this would be a really useful feature for me as I have multiple Steam accounts and I sometimes switch between them.

The endpoint http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/ mentions support for this:

steamids
    A comma-separated list of 64 bit IDs to retrieve profiles for.

Additional Rich Presence data from games doesn't work

I did a normal install and followed all steps correctly, but it doesn't seem to show additional data from games that support it. I tested on ULTRAKILL and Bloons TD6, both of which behaved like other games and not like in screenshots. Code is unmodified (aside from a simple string change I did but that shouldn't affect anything) and the config looks totally fine.

my_config.json

Changing the RP title to the game name

I've noticed that with some games the title of the rich presence is the actual name of the game I'm playing, and for others it just says 'a game on steam' and shows the name in the description. Is there a way to set the title to always be the game name?

image

image

(also i just wanted to thank you for making this, my games not appearing properly has been unreasonably bugging me for quite a while now)

[Feature request]

NON_STEAM_GAMES
I actually used this feature, and the cookies expiring wasn't a problem - I could always fire up Firefox again and quickly re-export them.

Index Out Of Range

Latest Version 1.10.2 breaks with a list index out of range error when playing non steam games

IMG_6908

Author's name coverImageText?

Im little confused, what library are you using to get author's name to put it on the cover image text? I wanted to change it to game's name but can't find the source. Thanks

Installation doesn't work

Here's the error I got when running install.sh.

Testing if the script works

[Apr 16 2024 - 17:55:28] couldn't find the the meta file, creating new one

[Apr 16 2024 - 17:55:28] updating meta.json's structure-version to 1
[Apr 16 2024 - 17:55:28] importing libraries for meta update
[Apr 16 2024 - 17:55:28] creating /home/user1/Documents/scripts/steam-presence/./data/
[Apr 16 2024 - 17:55:28] moving /home/user1/Documents/scripts/steam-presence/./icons.txt
[Apr 16 2024 - 17:55:28] moving /home/user1/Documents/scripts/steam-presence/./games.txt
[Apr 16 2024 - 17:55:28] moving /home/user1/Documents/scripts/steam-presence/./customGameIDs.json
[Apr 16 2024 - 17:55:28] moving /home/user1/Documents/scripts/steam-presence/./meta.json

[Apr 16 2024 - 17:55:28] loading config file
Traceback (most recent call last):
File "/home/user1/Documents/scripts/steam-presence/./main.py", line 1168, in
main()
File "/home/user1/Documents/scripts/steam-presence/./main.py", line 977, in main
config = getConfigFile()
^^^^^^^^^^^^^^^
File "/home/user1/Documents/scripts/steam-presence/./main.py", line 162, in getConfigFile
userSettings = json.load(f)
^^^^^^^^^^^^
File "/usr/lib/python3.11/json/init.py", line 293, in load
return loads(fp.read(),
^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/json/init.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/json/decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
^^^^^^^^^^^^^^^^^^^^^^
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 5 column 1 (char 97)
./installer.sh: line 48: kill: (31841) - No such process
Test might've worked, did it spit out any errors?
Commands executed.
Setting up service file for Linux
Starting service
If you encountered any errors with this script, please create an issue on the GitHub page

Script completed.

Any help is appreciated!

No longer detects non steam games

Apon running any non steam game the presense manager will not detect its use, even if it is ran through steam, and appears on the steam user profile.

Potential Improvements

Hi, I really like this service you put together. I was initially tempted to fork it and make my own modifications for my own needs, but wanted to check if you were interested in me adding the following features:

  • Make the systemd service listen for new processes rather than polling every cycle. While this might not seem as much of a big deal with computers these days, I'd rather want programs to only execute when they are needed. I was thinking of adding something like pyinotification, or even linux's inotification to watch for new processes spawned under /proc
  • rather than scrape everything online, some information can be obtained from a processes env if its a steam game. The app id for example can be obtained from it. If you are already listening for processes spawning, you can check to see what environment variables the process has set, grab the steam id, and whatever else.
  • build up a cache of previously launched games, why go up online every single time? though the argument could be made against caching if you're running low on storage. Could be something that is configurable.
  • Make a GUI for the configuration file, maybe with Qt, and bundle it with flatpak?

Each of these bullet points could be a separate PR to this repo

Adding custom games

In the old version (which was great, it's the only thing of it's kind that worked for me!), I didn't manage to get this working.

immagine

In the new version (which is even greater! thanks a lot for your work!) I'm even more confused on how the CUSTOM_GAME_OVERWRITE section is supposed to work. I'm not sure if I understood that correctly, how am I supposed to get a custom "game" (code-oss) or any process at all to show up with a name-icon pair (VSCode and ideally the image found here)?

Again, thanks A LOT for your efforts on this process!

Also, I would suggest recreating an install.sh script that installs the systemd service, since that would make everything much easier and automatically set the correct file paths. I can write this if you'd like it :)

Discord needs to run in the background (?)

In the README it says:

in addition to this, there's the Steam Deck, a handheld linux game "console".

having discord constantly run in the background is a terrible idea considering how that's gonna lose you at least half an hour of battery life, in addition to the previous issues with linux.

Which is a valid point, but Discord still needs to run in the background if I understand it correctly, or at least when I launch the project on Deck it says that it needs to.

Am I missing something?

Running without Discord client

Is the Discord client running side by side with steam-presence a hard requirement?

You mentioned we can run steam-presence on a server (which I intended to do with Docker), but that would mean having a GUI running with Discord.

Can you please clarify how would such a setup be viable?
Are there tools that can send RPC data to Discord's servers other than the official client?

RPC randomly disappears, not sure why?

This video should sum things up quite well. No errors locally at all. Tried rebooting and reinstalling steam-presence. I am using the latest Discord from the AUR. I have sanity checked my json file multiple times, and it's accurate.

changing rich presence title?

Is there any way we can change "a game on steam" to "on Steam Deck" so that it says

Playing on Steam Deck
Control Ultimate Edition
The Foundation
04:26 elapsed

instead of "Playing a game on steam, etc"
If that's possible I think it would look a lot better. I know this rich presence isn't intended solely for the Steam Deck but that's what I and many others are using it for, so the ability to customize the RPC title would be great

Discord shows up the normal RPC, but doesn't shows up the steam-presence RPC

This is a question and also a problem i'm having with the script, i run the script but... im not sure what it's supposed to do next...
I have a config.json already set up with my steam id, user id, everything but... Is not showing up in my profile?

I have made sure that the script is running, changed the configs as i needed but nothing is working.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.