Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/henry232323/spectrum.py
spectrum.py is a discord.py style proof-of-concept library for making chatbots for Star Citizen's Spectrum chat
https://github.com/henry232323/spectrum.py
star-citizen
Last synced: 25 days ago
JSON representation
spectrum.py is a discord.py style proof-of-concept library for making chatbots for Star Citizen's Spectrum chat
- Host: GitHub
- URL: https://github.com/henry232323/spectrum.py
- Owner: henry232323
- License: mit
- Created: 2023-11-29T15:20:05.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-04-01T07:10:14.000Z (7 months ago)
- Last Synced: 2024-08-10T23:15:58.356Z (3 months ago)
- Topics: star-citizen
- Language: Python
- Homepage:
- Size: 83 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# spectrum.py
spectrum.py is a [discord.py](https://github.com/Rapptz/discord.py) style proof-of-concept library for making chatbots
for Star Citizen's [Spectrum](https://robertsspaceindustries.com/spectrum/community/SC) chat client. It also offers HTTP clients for interacting
with both Spectrum's REST API and the Community Hub's GraphQL API.## Installation
```shell
# Latest Release
python -m pip install spectrum.py
# Latest in Github
python -m pip install git+https://github.com/henry232323/spectrum.py
```## Examples
### With Gateway
```python
import asyncio
from spectrum import Client, Messageclass MyClient(Client):
async def on_message(self, message: Message):
print(message)async def on_ready(self):
print("We're ready!")async def run():
myclient = MyClient(
rsi_token=...,
device_id=...,
)asyncio.ensure_future(myclient.run())
await asyncio.Event().wait()asyncio.run(run())
```### HTTP Only
```python
import asyncio
from spectrum import HTTPClientasync def run():
client = HTTPClient(
rsi_token=...,
device_id=...,
)await client.identify()
member = await client.fetch_member_by_handle("Khuzdul")
print(member)await client.close()
asyncio.run(run())
```### Community Hub
```python
import asyncio
from spectrum import CommunityHubClientasync def run():
client = CommunityHubClient()
print(await client.fetch_user_profile("Khuzdul"))asyncio.run(run())
```## Authentication
The bot can be run in a read only state without any authentication.
If you want to be able to send messages or read private messages (and eventually do other things),
you'll need to provide credentials for an RSI account. These can be found in the cookies sent
with any request to [RSI](https://robertsspaceindustries.com/) when logged in.