Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
2.6 kB
29
Indexable
import requests
import websocket
from threading import Thread
from time import sleep as slp
from time import time as getTime
from json import loads
from hashlib import sha1
from uuid import uuid4
import hmac
import hashlib
from time import sleep 
import base64
from contextlib import suppress
from BotAmino import *

import agorartc

rtc = agorartc.createRtcEngineBridge()
eventHandler = agorartc.RtcEngineEventHandlerBase()
rtc.initEventHandler(eventHandler)
rtc.initialize("d544b053e3e94dd2a8f51c6668522372", None, agorartc.AREA_CODE_GLOB & 0xFFFFFFFF)
rtc.enableAudio()
rtc.setAudioProfile(6, 2)
from pprint import pprint
import time
def c():
    data = uuid4().bytes
    return ("42" + data.hex() + hmac.new(bytes.fromhex("02b258c63559d8804321c5d5065af320358d366f"),bytes.fromhex("42") + data, hashlib.sha1).hexdigest()).upper()
comId = "131186966"
chatId = "af916280-ae76-4c41-8428-a0195267fadc"

sid="AnsiMSI6IG51bGwsICIwIjogMiwgIjMiOiAwLCAiMiI6ICI4ZDY1YzBkNS1iYWQzLTQwYTUtYmEwYS00YmQ0MTJkMWM1ZGUiLCAiNSI6IDE2NjE2OTE3MjYsICI0IjogIjEwMy4xODMuMzMuMTQ3IiwgIjYiOiAxMDB9UILX5vkfTOqs0hA-rHL6sluhFRM"
import threading
deviceId=c()
c = BotAmino(sid=sid)
def sigg(data):
    key='f8e7a61ac3f725941e3ac7cae2d688be97f30b93'
    mac = hmac.new(bytes.fromhex(key), data.encode("utf-8"), sha1)
    digest = bytes.fromhex("42") + mac.digest()
    return base64.b64encode(digest).decode("utf-8")


def play_music(comid: str, chatid: str):
    comid = str(comid)
    data = '{"o":{"ndcId":'+comid+',"threadId":"'+chatid+'","joinRole":1,"id":"2249844"},"t":112}'
    c.send(data)

    data = '{"o":{"ndcId":'+comid+',"threadId":"'+chatid+'","channelType":1,"id":"2250161"},"t":108}'
    c.send(data)

    
    slp(3)
    data = '{"o":{"ndcId":'+comid+',"threadId":'+chatid+',"id":"337496"},"t":200}'
    c.send(data)
    while True:
        try:
            data = '{"o":{"ndcId":'+comid+',"threadId":"'+chatid+'","joinRole":1,"id":"2249844"},"t":112}'
            c.send(data)
            slp(2)
        except Exception:
            pass
@c.event("on_fetch_channel")
def on_chat_invite(data):
    
    token=data.json
    print(token)
    rtc.joinChannel(token['channelKey'], token['channelName'], 'one.mp3', int(token['channelUid']))

    rtc.startAudioMixing("one.mp3", False, True, 1)
@c.command()
def play(data):
    Thread(target=play_music, args=[data.comId, data.chatId]).start()


@c.command()
def stop(data):
    c.end_voice_room(data.comId, data.chatId)


c.launch(True)
print("ready")