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):
|
def on_youtube_event(event, data):
|
||||||
print(f"{event}: {data.attrs()}")
|
print(f'{event}: {data.attrs()}')
|
||||||
|
|
||||||
|
|
||||||
def on_twitch_event(event, data):
|
def on_twitch_event(event, data):
|
||||||
if event == "follow":
|
if event == 'follow':
|
||||||
print(f"Received follow from {data.name}")
|
print(f'Received follow from {data.name}')
|
||||||
elif event == "bits":
|
elif event == 'bits':
|
||||||
print(f"{data.name} donated {data.amount} bits! With message: {data.message}")
|
print(f'{data.name} donated {data.amount} bits! With message: {data.message}')
|
||||||
elif event == "donation":
|
elif event == 'donation':
|
||||||
print(
|
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():
|
def main():
|
||||||
# read token from config.toml
|
# read token from config.toml
|
||||||
with streamlabsio.connect() as client:
|
with streamlabsio.connect() as client:
|
||||||
client.obs.on("streamlabs", on_twitch_event)
|
client.obs.on('streamlabs', on_twitch_event)
|
||||||
client.obs.on("twitch_account", on_twitch_event)
|
client.obs.on('twitch_account', on_twitch_event)
|
||||||
client.obs.on("youtube_account", on_youtube_event)
|
client.obs.on('youtube_account', on_youtube_event)
|
||||||
|
|
||||||
# run for 30 seconds then disconnect client from server
|
# run for 30 seconds then disconnect client from server
|
||||||
client.sio.sleep(30)
|
client.sio.sleep(30)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
@ -4,47 +4,53 @@ import streamlabsio
|
|||||||
|
|
||||||
config.dictConfig(
|
config.dictConfig(
|
||||||
{
|
{
|
||||||
"version": 1,
|
'version': 1,
|
||||||
"formatters": {
|
'disable_existing_loggers': False,
|
||||||
"standard": {
|
'loggers': {
|
||||||
"format": "%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s"
|
'streamlabsio.client': {
|
||||||
|
'level': 'DEBUG',
|
||||||
|
'handlers': ['console'],
|
||||||
|
'propagate': False,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"handlers": {
|
'handlers': {
|
||||||
"stream": {
|
'console': {
|
||||||
"level": "DEBUG",
|
'class': 'logging.StreamHandler',
|
||||||
"class": "logging.StreamHandler",
|
'level': 'DEBUG',
|
||||||
"formatter": "standard",
|
'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):
|
def on_youtube_event(event, data):
|
||||||
print(f"{event}: {data.attrs()}")
|
print(f'{event}: {data.attrs()}')
|
||||||
|
|
||||||
|
|
||||||
def on_twitch_event(event, data):
|
def on_twitch_event(event, data):
|
||||||
if event == "follow":
|
if event == 'follow':
|
||||||
print(f"Received follow from {data.name}")
|
print(f'Received follow from {data.name}')
|
||||||
elif event == "bits":
|
elif event == 'bits':
|
||||||
print(f"{data.name} donated {data.amount} bits! With message: {data.message}")
|
print(f'{data.name} donated {data.amount} bits! With message: {data.message}')
|
||||||
elif event == "donation":
|
elif event == 'donation':
|
||||||
print(
|
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():
|
def main():
|
||||||
with streamlabsio.connect() as client:
|
with streamlabsio.connect() as client:
|
||||||
client.obs.on("streamlabs", on_twitch_event)
|
client.obs.on('streamlabs', on_twitch_event)
|
||||||
client.obs.on("twitch_account", on_twitch_event)
|
client.obs.on('twitch_account', on_twitch_event)
|
||||||
client.obs.on("youtube_account", on_youtube_event)
|
client.obs.on('youtube_account', on_youtube_event)
|
||||||
|
|
||||||
client.sio.sleep(30)
|
client.sio.sleep(30)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
@ -4,5 +4,5 @@ from pathlib import Path
|
|||||||
|
|
||||||
|
|
||||||
def ex_debug():
|
def ex_debug():
|
||||||
scriptpath = Path.cwd() / "examples" / "debug" / "."
|
scriptpath = Path.cwd() / 'examples' / 'debug' / '.'
|
||||||
subprocess.run([sys.executable, str(scriptpath)])
|
subprocess.run([sys.executable, str(scriptpath)])
|
||||||
|
@ -3,7 +3,7 @@ from dataclasses import dataclass
|
|||||||
|
|
||||||
|
|
||||||
def to_snake_case(s):
|
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):
|
def as_dataclass(identifier, data):
|
||||||
@ -12,10 +12,10 @@ def as_dataclass(identifier, data):
|
|||||||
|
|
||||||
return dataclass(
|
return dataclass(
|
||||||
type(
|
type(
|
||||||
f"{identifier.capitalize()}Dataclass",
|
f'{identifier.capitalize()}Dataclass',
|
||||||
(),
|
(),
|
||||||
{
|
{
|
||||||
"attrs": attrs,
|
'attrs': attrs,
|
||||||
**{to_snake_case(k): v for k, v in data.items()},
|
**{to_snake_case(k): v for k, v in data.items()},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user