mirror of
https://github.com/onyx-and-iris/streamlabs-socketio-py
synced 2025-01-30 14:50:48 +00:00
re-run through ruff formatter
This commit is contained in:
parent
0b67bcd832
commit
3555d5fe6c
22
__main__.py
22
__main__.py
@ -2,30 +2,30 @@ import streamlabsio
|
||||
|
||||
|
||||
def on_youtube_event(event, data):
|
||||
print(f"{event}: {data.attrs()}")
|
||||
print(f'{event}: {data.attrs()}')
|
||||
|
||||
|
||||
def on_twitch_event(event, data):
|
||||
if event == "follow":
|
||||
print(f"Received follow from {data.name}")
|
||||
elif event == "bits":
|
||||
print(f"{data.name} donated {data.amount} bits! With message: {data.message}")
|
||||
elif event == "donation":
|
||||
if event == 'follow':
|
||||
print(f'Received follow from {data.name}')
|
||||
elif event == 'bits':
|
||||
print(f'{data.name} donated {data.amount} bits! With message: {data.message}')
|
||||
elif event == 'donation':
|
||||
print(
|
||||
f"{data.name} donated {data.formatted_amount}! With message: {data.message}"
|
||||
f'{data.name} donated {data.formatted_amount}! With message: {data.message}'
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
# read token from config.toml
|
||||
with streamlabsio.connect() as client:
|
||||
client.obs.on("streamlabs", on_twitch_event)
|
||||
client.obs.on("twitch_account", on_twitch_event)
|
||||
client.obs.on("youtube_account", on_youtube_event)
|
||||
client.obs.on('streamlabs', on_twitch_event)
|
||||
client.obs.on('twitch_account', on_twitch_event)
|
||||
client.obs.on('youtube_account', on_youtube_event)
|
||||
|
||||
# run for 30 seconds then disconnect client from server
|
||||
client.sio.sleep(30)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
@ -4,47 +4,53 @@ import streamlabsio
|
||||
|
||||
config.dictConfig(
|
||||
{
|
||||
"version": 1,
|
||||
"formatters": {
|
||||
"standard": {
|
||||
"format": "%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s"
|
||||
'version': 1,
|
||||
'disable_existing_loggers': False,
|
||||
'loggers': {
|
||||
'streamlabsio.client': {
|
||||
'level': 'DEBUG',
|
||||
'handlers': ['console'],
|
||||
'propagate': False,
|
||||
}
|
||||
},
|
||||
"handlers": {
|
||||
"stream": {
|
||||
"level": "DEBUG",
|
||||
"class": "logging.StreamHandler",
|
||||
"formatter": "standard",
|
||||
'handlers': {
|
||||
'console': {
|
||||
'class': 'logging.StreamHandler',
|
||||
'level': 'DEBUG',
|
||||
'formatter': 'simple',
|
||||
'stream': 'ext://sys.stdout',
|
||||
}
|
||||
},
|
||||
"loggers": {"streamlabsio.client": {"handlers": ["stream"], "level": "DEBUG"}},
|
||||
'formatters': {
|
||||
'simple': {'format': '%(asctime)s - %(name)s - %(levelname)s - %(message)s'}
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def on_youtube_event(event, data):
|
||||
print(f"{event}: {data.attrs()}")
|
||||
print(f'{event}: {data.attrs()}')
|
||||
|
||||
|
||||
def on_twitch_event(event, data):
|
||||
if event == "follow":
|
||||
print(f"Received follow from {data.name}")
|
||||
elif event == "bits":
|
||||
print(f"{data.name} donated {data.amount} bits! With message: {data.message}")
|
||||
elif event == "donation":
|
||||
if event == 'follow':
|
||||
print(f'Received follow from {data.name}')
|
||||
elif event == 'bits':
|
||||
print(f'{data.name} donated {data.amount} bits! With message: {data.message}')
|
||||
elif event == 'donation':
|
||||
print(
|
||||
f"{data.name} donated {data.formatted_amount}! With message: {data.message}"
|
||||
f'{data.name} donated {data.formatted_amount}! With message: {data.message}'
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
with streamlabsio.connect() as client:
|
||||
client.obs.on("streamlabs", on_twitch_event)
|
||||
client.obs.on("twitch_account", on_twitch_event)
|
||||
client.obs.on("youtube_account", on_youtube_event)
|
||||
client.obs.on('streamlabs', on_twitch_event)
|
||||
client.obs.on('twitch_account', on_twitch_event)
|
||||
client.obs.on('youtube_account', on_youtube_event)
|
||||
|
||||
client.sio.sleep(30)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
@ -4,5 +4,5 @@ from pathlib import Path
|
||||
|
||||
|
||||
def ex_debug():
|
||||
scriptpath = Path.cwd() / "examples" / "debug" / "."
|
||||
scriptpath = Path.cwd() / 'examples' / 'debug' / '.'
|
||||
subprocess.run([sys.executable, str(scriptpath)])
|
||||
|
@ -3,7 +3,7 @@ from dataclasses import dataclass
|
||||
|
||||
|
||||
def to_snake_case(s):
|
||||
return re.sub(r"(?<!^)(?=[A-Z])", "_", s).lower()
|
||||
return re.sub(r'(?<!^)(?=[A-Z])', '_', s).lower()
|
||||
|
||||
|
||||
def as_dataclass(identifier, data):
|
||||
@ -12,10 +12,10 @@ def as_dataclass(identifier, data):
|
||||
|
||||
return dataclass(
|
||||
type(
|
||||
f"{identifier.capitalize()}Dataclass",
|
||||
f'{identifier.capitalize()}Dataclass',
|
||||
(),
|
||||
{
|
||||
"attrs": attrs,
|
||||
'attrs': attrs,
|
||||
**{to_snake_case(k): v for k, v in data.items()},
|
||||
},
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user