Created
July 17, 2017 07:16
-
-
Save Scrxtchy/ca525e9d92232ac561e59fe0cf164364 to your computer and use it in GitHub Desktop.
ts3 mixer ban
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ts3 | |
import beam_interactive2, asyncio | |
def run(shit): | |
loop = asyncio.get_event_loop() | |
try: | |
loop.run_until_complete(shit.loop()) | |
finally: | |
print('end-prog') | |
loop.stop() | |
class example(): | |
def __init__(self): | |
self.interactive = None | |
async def setup(self): | |
try: | |
with open('auth.txt', 'r') as auth: | |
mixerInteractive = await beam_interactive2.State.connect( | |
authorization="Bearer " + auth.read(), | |
project_version_id=42489, | |
project_sharecode="rheo1hre") | |
except Exception as e: | |
print("Error connecting;", e) | |
return | |
self.interactive = mixerInteractive | |
self.interactive.on('error', lambda e: self.fatal_error(e)) | |
self.interactive.on('giveInput', lambda call: self.keypress(call)) | |
self.interactive.pump_async() | |
print('async started') | |
await self.setupControls() | |
async def setupControls(self): | |
button = beam_interactive2.Button( | |
control_id='b1', | |
text='Oh No', | |
cost=0, | |
position=[ | |
{"size": "large", "x": 30, "y": 3, "width": 20, "height": 15},{ "size": "medium", "width": 20, "height": 15, "x": 13, "y": 5},{ "size": "small", "x": 5, "y": 8, "width": 20, "height": 15} | |
], | |
) | |
button.on('mousedown', lambda call:self.buttonPress(call)) | |
await self.interactive.scenes['default'].create_controls(button) | |
await self.interactive.set_ready() | |
async def buttonPress(self, call): | |
with ts3.query.TS3Connection("192.168.0.206") as ts3conn: | |
try: | |
ts3conn.login( | |
client_login_name="Astrid", | |
client_login_password="#Redacted" | |
) | |
except ts3.query.TS3QueryError as err: | |
print("Login failed:", err.resp.error["msg"]) | |
exit(1) | |
ts3conn.use(sid=1) | |
ts3conn.clientupdate(client_nickname="Astrid") | |
ts3conn.banadd(uid="ykR5DGyS9C2ICKrr8MfB5xBVDdg=", time=1, banreason="Crowdsourced Banned") | |
async def keypress(self, call): | |
pass | |
async def loop(self): | |
print('loop') | |
await self.setup() | |
while True: | |
await asyncio.sleep(1) | |
def fatal_error(self, e): | |
self._running = False | |
raise e | |
run(example()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment