GithubHelp home page GithubHelp logo

icewind1991 / mx-puppet-steam Goto Github PK

View Code? Open in Web Editor NEW
41.0 7.0 11.0 518 KB

Matrix <-> Steam puppeting bridge based on mx-puppet-bridge

License: Apache License 2.0

TypeScript 97.77% Dockerfile 1.00% Shell 0.62% Nix 0.61%

mx-puppet-steam's Introduction

mx-puppet-steam

Matrix <-> Steam puppeting bridge based on mx-puppet-bridge.

This bridge uses puppeting to bridge your steam messages into a matrix server, this means that the bridge logs into your steam account using the same api as the regular steam account and forwards any incoming steam message to a matrix chatroom and any message you send in the matrix chatroom back to steam.

Status

  • login with steam guard support
  • 1<->1 messaging
  • group messaging
  • steam <-> matrix typing notifications
  • online/offline status
  • retrieve nickname and avatar from steam
  • listing of steam users
  • listing of steam group chats
  • listing of members within group chat
  • bridging embedded images in 1<->1 chats
  • receiving embedded images from steam in group chats
  • sending embedded images to steam in group chats
  • steam -> matrix emotes

Setup

You need at least node 12 to be able to run this!

Clone the repo and install the dependencies:

git clone https://github.com/icewind1991/mx-puppet-steam
cd mx-puppet-steam
npm install

Copy and edit the configuration file to your liking:

cp sample.config.yaml config.yaml
... edit config.yaml ...

Generate an appservice registration file. Optional parameters are shown in brackets with default values:

npm run start -- -r [-c config.yaml] [-f steam-registration.yaml]

Then add the path to the registration file to your synapse homeserver.yaml under app_service_config_files, and restart synapse.

Finally, run the bridge:

npm run start

Docker

If you prefer to use a docker based setup an image is available at icewind1991/mx-puppet-steam (Note that I do longer use the docker image myself so it's mostly untested).

Linking

Start a chat with @_steampuppet_bot:yourserver.com

link <username> <password>

If a steam guard (mobile or email) code is required, you will be asked for the code.

Ephemeral events

To enable bridging ephemeral events from matrix to steam (typing notification, read markers and presence) you'll need to enable the experimental support in synapse for pushing these events to the bridge by setting

"de.sorunome.msc2409.push_ephemeral": true

in your registration file.

Credits

This project would not be possible without the great work of (among others) the following projects:

mx-puppet-steam's People

Contributors

icewind1991 avatar dependabot[bot] avatar plantroon avatar jokergermany avatar tilosp avatar

Stargazers

 avatar  avatar Alex Hall avatar Amy/Atius avatar LoicLM avatar Blake avatar Carl Richard Theodor Schneider avatar  avatar Kyle Davis avatar  avatar Tiago R avatar Ashik avatar  avatar Andzejs Poprockis avatar yun avatar  avatar Robin Loose avatar  avatar nodiscc avatar Luke Simmons avatar  avatar RayManD avatar Scott Weldon avatar  avatar  avatar Peter R avatar  avatar Nicholas Brackley avatar  avatar Gruber avatar Jonathan de Jong avatar  avatar Tilo Brueckner avatar Katia Esposito avatar xcesiv avatar  avatar Dominic Schubert avatar  avatar lolisamurai avatar Daniel Løvbrøtte Olsen avatar Nathan Pennie avatar

Watchers

James Cloos avatar Daniel Løvbrøtte Olsen avatar  avatar Dominic Schubert avatar  avatar  avatar  avatar

mx-puppet-steam's Issues

Docker compose quick start?

Hi, i cant figure out how to make this work with docker compose.

My matrix is runing on separate compose file

I created new folder:
mx-puppet-steam/
./docker-compose.yml

version: "3.4"
services:
  mx-puppet-steam:
    hostname: mx-puppet-steam
    image: icewind1991/mx-puppet-steam
    restart: always
    volumes:
      - ./config.yaml:/data/config.yaml
     
    networks:
      - internal
networks:
  internal:

./config.yaml

bridge:
  # Port to host the bridge on which your homeserver will connect to
  port: 6000
  # Address for the bridge to bind to; if running as a Docker container, you
  # probably want 0.0.0.0 here
  bindAddress: 0.0.0.0
  # Name of your homeserver
  domain: matrix.example2.com
  # URL where the bridge can connect to your homeserver
  homeserverUrl: https://matrix.example2.com

provisioning:
  # Which users are allowed to issue commands to @_steampuppet_bot
  # whitelist:
  #  - "@*:matrix.example.com"
  # A blacklist can be used instead:
  # blacklist:
  #   - "@username:matrix\\.myhomeserver\\.com"

  # Shared secret for the provisioning API for use by integration managers.
  # If this is not set, the provisioning API will not be enabled.
  #sharedSecret: random string
  # Path prefix for the provisioning API. /v1 will be appended to the prefix automatically.
  apiPrefix: /_matrix/provision

presence:
  # Bridge Steam online/offline status
  enabled: true

  # How often to send status to the homeserver in milliseconds
  interval: 5000

Then i run: docker compose up -d

It runs, but logs say it cant connect to my matrix. Ok, so now i have to register the bridge with my matrix homeserver.yaml.

But how? Where can i get the registration file? How to expose it from docker container? What lines do i need to add to my homeserver.yaml ???

EDIT:

I got it to run and kinda connect to my matrix.

Had to do the following:

Instead of creating ./config.yaml - > ./data/config.yaml and then bind the folder data. Also removed the network thing and added ports.

./docker-compose.yml

version: "3.4"
services:
  mx-puppet-steam:
    hostname: mx-puppet-steam
    image: icewind1991/mx-puppet-steam
    restart: always
    volumes:
      - ./data/config.yaml:/data/config.yaml
      - ./data:/data
    ports:
      - "6000:6000"

Then in the data folder the registration file was generated.
./data/steam-registration.yaml

Then i copied the registration file to the same folder as my matrix homeserver.yaml (dendrite.yaml) and added the path to the:
homeserver.yaml (dendrite.yaml)

# Configuration for the Appservice API.
app_service_api:
  # Disable the validation of TLS certificates of appservices. This is
  # not recommended in production since it may allow appservice traffic
  # to be sent to an insecure endpoint.
  disable_tls_validation: false

  # Appservice configuration files to load into this homeserver.
  config_files:
    - ./steam-registration.yaml

After reloading both composes, the mx container shows me this:


Sep-13 19:07:59.619 [Store] info: Starting DB Init
Sep-13 19:07:59.621 [Store] info: Filename present in config, using sqlite
Sep-13 19:07:59.621 [SQLite3] info: Opening database.db
Sep-13 19:07:59.626 [Store] info: Database schema version is 16, latest version is 16
Sep-13 19:07:59.627 [PuppetBridge] info: Starting application service....
Sep-13 19:07:59.630 [bot-sdk-MatrixHttpClient] info: (REQ-1) POST https://matrix.example2.com/_matrix/client/r0/register
Sep-13 19:07:59.662 [PuppetBridge] info: Application service started!
Sep-13 19:07:59.662 [PuppetBridge] info: Setting bridge user data...
Sep-13 19:07:59.662 [bot-sdk-MatrixHttpClient] info: (REQ-2) GET https://matrix.example2.com/_matrix/client/r0/profile/%40_steampuppet_bot%3Aexample2.com
Sep-13 19:07:59.688 [PuppetBridge] info: Activating users...
Sep-13 19:07:59.689 [PresenceHandler] info: Starting presence handler with new interval 5000ms
matrix@matrix:~/mx-puppet-steam$ 

Now how do i control it from my element app?

I created private space, private room, and then i sent a message:

@_steampuppet_bot:matrix.matrix.example2.com

but nothing happened.

What am i missing?

EDIT

So i invited the bot to my private room but it shows offline (the bot is offline) and when i mention the bot nothing happens

Thanks in andvance!

Can't link user

I have tried to link my Steam user to the puppet, but I get the following message:

Dec-30 16:08:48.753 [bot-sdk-Appservice] info: Processing event of type m.room.message
127.0.0.1 - - [30/Dec/2020:15:08:48 +0000] "PUT /transactions/44?access_token=0b34f58f-d41e-4623-9691-091aafc105f5 HTTP/1.1" 200 2 "-" "Synapse/1.24.0"
Dec-30 16:08:48.765 [BotProvisioner] info: Got message to process with arg=link
Dec-30 16:08:48.767 [MatrixEventHandler] error: Error handling appservice room.event TypeError ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
at validateString (internal/validators.js:120:11)
at Object.join (path.js:1039:7)
at userData (/usr/lib/node_modules/mx-puppet-steam/node_modules/appdirectory/lib/appdirectory.js:21:29)
at AppDirectory._setTemplates (/usr/lib/node_modules/mx-puppet-steam/node_modules/appdirectory/lib/appdirectory.js:134:34)
at new AppDirectory (/usr/lib/node_modules/mx-puppet-steam/node_modules/appdirectory/lib/appdirectory.js:129:10)
at new SteamUser (/usr/lib/node_modules/mx-puppet-steam/node_modules/steam-user/index.js:83:35)
at /usr/lib/node_modules/mx-puppet-steam/index.js:115:28
at Generator.next ()
at /usr/lib/node_modules/mx-puppet-steam/index.js:8:71
at new Promise () {
code: 'ERR_INVALID_ARG_TYPE'
}

More descriptive invite to play a game info

While testing the bridge I've been faced with a little problem with game invites.
The contents of an invite messages are as follows:

Invited you to play a game!

And that's it. No mention of which game it is, nor there is a link to join his game.

Error 401 when using with matrix-docker-ansible-deploy

I've deployed this bridge using matrix-docker-ansible-deploy, which has a config variable that takes care of everything (builds the docker image, sets up roles, db tables, starts the container). The bot is online and I can start a chat/room with it, however it responds to no command. Checking journalctl -fu matrix-mx-puppet-steam.service the only log I have is:

Sep 09 09:17:47 matrix matrix-mx-puppet-steam[273606]: 172.18.0.4 - - [09/Sep/2023:09:17:47 +0000] "PUT /_matrix/app/v1/transactions/13779 HTTP/1.1" 401 57 "-" "Synapse/1.91.2"

The container seems to be healthy:
78244275fbe1 localhost/icewind1991/mx-puppet-steam:latest "/opt/mx-puppet-stea…" 24 hours ago Up 24 hours matrix-mx-puppet-steam

Is there any extra troubleshooting I can do to check what's wrong?
I've also created an issue on the playbook's repo in case it's a problem with the integration itself.

Quick get started guide?

I installed this with the matrix-ansible-docker script, logged in, aparantly without issue, logs don't seem to have an issue.

Sep 07 04:10:18 synapse matrix-mx-puppet-steam[373977]: 172.18.0.4 - - [07/Sep/2022:12:10:18 +0000] "PUT /transactions/19527?access_token=TOKEN HTTP/1.1" 200 2 "-" "Synapse/1.66.0"

happens frequently, but I haven't the foggiest on how to get started with it, none of the commands spits out any of my matrix friends, or anything I can see/understand.

listusers
S
4:12AM
1: Steam:

list

Links:
1: Steam

I can't see what I'm missing...

Steam refuses to comply with the bridge

Within less than a few minutes of using the bridge, I get this error from @_steampuppet_bot:myserver

[Status] 1: Steam: disconnected!: failed to connect. Error: LogonSessionReplaced

Any way to mitigate this?

Nicer game invites

Pretty much continuation of #6

Currently, the message you get when someone invites you is:

[lobbyinvite ="" appid="730" lobbyid="109775241107229798"]

I'd love it to be:

{{username}} invited you to play {{app name}}:
<a href="steam://joinlobby/{{app id}}/{{lobby id}}/{{inviter profile id}}">Join lobby</a>

If there are clients that wouldn't open the steam:// url then instead of sending Join lobby simply send the same as href attr

`Invited you to play a game!` sent by my steam puppet when inviting others

This seems kind of strange, as when I invite someone to play a game, my own puppet enters the room and sends Invited you to play a game!.

I know it is probably a message that is received from steam but it is still confusing.

Hardcoding You invited friend to play a game! is kind of bad in my opinion, so making the message configurable would be some kind of workaround if you can't get any other message from steam.

Error generating an appservice registration file !!

[email protected] build /root/mx-puppet-steam
tsc

/root/mx-puppet-steam/node_modules/command-line-args/dist/index.js:1345
throw err
^

UNKNOWN_VALUE: Unknown value: [-c
at commandLineArgs (/root/mx-puppet-steam/node_modules/command-line-args/dist/index.js:1342:21)
at Object. (/root/mx-puppet-steam/build/index.js:33:4)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)
at internal/main/run_main_module.js:17:47 {
value: '[-c'
}

My node version its 14.19.1

Relink or reconnection?

Currently I have the Problem there is often disconnect me with the info Password wrong and I have to create a fully new Link so my puppets do not work anymore and have to be reinvite, any workaround for my issue?

User ID already taken

Hi,
first of all, thank you for this. I can´t get it running but I am thankful it exists.

I followed the readme to set this puppet up. First i used nodejs v16 wat did not worked at all. Then i switched to the latest nodejs v12 and i was able to compile. I generadet a registration.yaml and edited my homeserver.yaml. When i start the puppet this is the log i get:
Jun-15 17:30:15.986 [Store] info: Starting DB Init Jun-15 17:30:15.988 [Store] info: Filename present in config, using sqlite Jun-15 17:30:15.988 [SQLite3] info: Opening database.db Jun-15 17:30:15.991 [Store] info: Database schema version is 16, latest version is 16 Jun-15 17:30:15.993 [PuppetBridge] info: Starting application service.... Jun-15 17:30:15.999 [bot-sdk-MatrixHttpClient] info: (REQ-1) POST http://localhost:8008/_matrix/client/r0/register Jun-15 17:30:16.025 [PuppetBridge] info: Application service started! Jun-15 17:30:16.026 [PuppetBridge] info: Setting bridge user data... Jun-15 17:30:16.026 [bot-sdk-MatrixHttpClient] info: (REQ-2) GET http://localhost:8008/_matrix/client/r0/profile/%40_steampuppet_bot%3Achat.north-industries.com Jun-15 17:30:16.036 [PuppetBridge] info: Activating users... Jun-15 17:30:16.038 [PresenceHandler] info: Starting presence handler with new interval 5000ms

looking all good, right?
here is the log from synapse:
2022-06-15 00:48:24,644 - synapse.http.server - 95 - INFO - POST-83 - <XForwardedForRequest at 0x7fc1a832c240 method='POST' uri='/_matrix/client/r0/register' clientproto='HTTP/1.1' site='8008'> SynapseError: 400 - User ID already taken. 2022-06-15 00:48:24,645 - synapse.access.http.8008 - 448 - INFO - POST-83 - 127.0.0.1 - 8008 - {@_steampuppet_bot:mydomain.com} Processed request: 0.002sec/0.000sec (0.000sec, 0.000sec) (0.000sec/0.000sec/1) 60B 400 "POST /_matrix/client/r0/register HTTP/1.1" "got (https://github.com/sindresorhus/got)" [0 dbevts] 2022-06-15 00:48:24,661 - synapse.access.http.8008 - 448 - INFO - GET-84 - 127.0.0.1 - 8008 - {None} Processed request: 0.001sec/0.000sec (0.002sec, 0.000sec) (0.000sec/0.000sec/2) 34B 200 "GET /_matrix/client/r0/profile/%40_steampuppet_bot%3Amydomain.com HTTP/1.1" "got (https://github.com/sindresorhus/got)" [0 dbevts]
I changed the user id in the registration.yaml and restarted matrix synapse, but still get the same message. I've repeated the generating regestration.yaml serveral times but i always get "User ID already taken" from synapse. I also can't find any user named "@_steampuppet_bot:mydomain.com"

mx-puppet-steam config.yaml:
`bridge:

Port to host the bridge on which your homeserver will connect to

port: 6000

Address for the bridge to bind to; if running as a Docker container, you

probably want 0.0.0.0 here

bindAddress: localhost

Name of your homeserver

domain: mydomain.com

URL where the bridge can connect to your homeserver

homeserverUrl: http://localhost:8008

provisioning:

Which users are allowed to issue commands to @_steampuppet_bot

whitelist:
- "@*"

A blacklist can be used instead:

blacklist:

- "@username:matrix\.myhomeserver\.com"

Shared secret for the provisioning API for use by integration managers.

If this is not set, the provisioning API will not be enabled.

sharedSecret: AlahaslDSDLJlj#fsda

Path prefix for the provisioning API. /v1 will be appended to the prefix automatically.

apiPrefix: /_matrix/provision

presence:

Bridge Steam online/offline status

enabled: true

How often to send status to the homeserver in milliseconds

interval: 5000
`

(note i removed my domainname from logs and examples)
Matrix synapse is running on localhost:8008 and connected with nginx proxy to my domain

Documentation for using docker image

I'm trying to get this up and running using the docker image, however, there seems to be a lack of documentation on how to use this. Currently I'm running it with:

docker run icewind1991/mx-puppet-steam -e CONFIG_PATH=/config/config.yaml -e REGISTRATION_PATH=/config/registration.yaml -v /opt/mx-puppet-steam/config:/config -v /opt/mx-puppet-steam/data:/data

After creating the file /opt/mx-puppet-steam/config/config.yaml however, the docker image just returns No config found any documentation on using the docker image?

Possible to define custom user display name format?

In my Matrix setup I use many different bridges to combine chats from different platforms.
But I sometimes use different platforms to communicate with a single user and would like to be able to differentiate between platforms by adding a suffix to each chat name.

For example, I have DMs with "Alice (Signal)" and "Alice (WA)" for Signal and WhatsApp conversations.

As far as I can see, mx-puppet-steam does not provide the possibility to define custom username templates,
so "Alice" from Steam will always show up as "Alice" in my DMs instead of e.g. "Alice (Steam)".

Would it be possible to add this feature in the future?

User documentation?

Hi, firstly thanks for your work.
Now, what brings me here is that I don't understand how I am supposed to use this bridge.

Please note that I am new to matrix and the bridging concept, maybe I missed something but your readme explains how to link a steam account and that I did correctly.

What is missing now is: how do I initiate communication with a steam user? I tried the help command but I am quite lost.

Is there some guide explaining how to proceed please?

Unable to Login with spaces in username

I have a really old steam account that has spaces in the username.

Continually returns invalid password when I try to login. Have tried to encase the username with ' and " to no avail.

Any ideas?

note: on the Steam website, if I try to login without the spaces in the username, it fails. Can only log in with spaces.

How to debug?

I installed it and added 2 steam accounts, but i didn't get any message. How can i debug it?

Can not link; Unhandled Promise Rejection: Error: Already logged on, cannot log on again

Hello
I'm trying to set up mx-puppet-steam but I've been working on it for hours now and I simply can not get it to link to my Steam account. The bot responds to me and I can issue the link command, I have Steam guard enabled on my mobile it pops up the code and I provide the code, but then nothing happens. The bot goes silent for a few moments and then just pretends like nothing happened / not linked. The console spits the error below if I send the bot any messages during the silent duration.

Errors in the mx-puppet-steam console output:

Mar-13 06:43:39.002 [PuppetBridge] error: Unhandled Promise Rejection: Error: Already logged on, cannot log on again
    at /opt/mx-puppet-steam/node_modules/steam-user/components/logon.js:23:10
    at processTicksAndRejections (node:internal/process/task_queues:76:11)

Mar-13 06:43:39.002 [PuppetBridge] error: Promise {
  <rejected> Error: Already logged on, cannot log on again
      at /opt/mx-puppet-steam/node_modules/steam-user/components/logon.js:23:10
      at processTicksAndRejections (node:internal/process/task_queues:76:11)
}

As well as several of these all the time:
Mar-13 06:46:46.011 [MatrixEventHandler] error: Puppet not found. Something is REALLY wrong!!!!

But what is confusing to me is that I don't seem to be getting any log messages from the src/steam.ts events should be "MatrixPuppet:Steam" but I get none of those in my console output (turned up to silly), at all.. And those seem like they'd be the most useful log entries :(

Any help would be greatly appreciated!

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.