temporary support for adaas + remove bundled tor
This commit is contained in:
parent
848c5b70b2
commit
40145ae3da
@ -4,12 +4,10 @@ WORKDIR /v6
|
||||
ENV v6root=/v6data
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y libopus0 opus-tools ffmpeg
|
||||
RUN apt-get install -y tor
|
||||
COPY requirements.txt requirements.txt
|
||||
RUN pip install -r requirements.txt
|
||||
RUN apt-get install -y tor obfs4proxy
|
||||
COPY v6d3music v6d3music
|
||||
RUN printf "\nClientTransportPlugin obfs4 exec /usr/bin/obfs4proxy\nBridge obfs4 185.177.207.210:11210 044DEFCA9726828CAE0F880DFEDB6D957006087A cert=mLCpY31wGw9Vs1tQdCXGIyZaAQ6RCdWvw50klpDAk/4mZvA+wekmLZQRqatcbuMp2y36TQ iat-mode=1\nUseBridges 1\n" >> "/etc/tor/torrc"
|
||||
ENV v6host=0.0.0.0
|
||||
EXPOSE 5930
|
||||
ENV v6port=5930
|
||||
CMD ["python3", "-m", "v6d3music.run-bot"]
|
||||
|
@ -1,5 +1,6 @@
|
||||
aiohttp~=3.7.4.post0
|
||||
discord.py[voice]~=1.7.3
|
||||
git+https://gitea.parrrate.ru/PTV/v6d1tokens.git@c4c6cf43b1082c666e6891f73df825acee6ae86d
|
||||
git+https://gitea.parrrate.ru/PTV/v6d2ctx.git@096314b9bbb6153a9a75afcc16ddf7833384df18
|
||||
youtube_dl~=2021.12.17
|
||||
git+https://gitea.parrrate.ru/PTV/v6d1tokens.git@d382a0aa59525c40009bc9e6c30aaec3e506062a
|
||||
git+https://gitea.parrrate.ru/PTV/v6d2ctx.git@096314b9bbb6153a9a75afcc16ddf7833384df18
|
||||
git+https://gitea.parrrate.ru/PTV/adaas.git@2052448b19f895dee5cec9eaec470243d130d253
|
||||
|
@ -13,6 +13,7 @@ from v6d3music.utils.presets import allowed_effects
|
||||
async def create_ytaudio(
|
||||
ctx: Context, info: dict[str, Any], effects: Optional[str], already_read: int, tor: bool
|
||||
) -> YTAudio:
|
||||
assert ctx.member is not None
|
||||
if effects:
|
||||
if effects not in allowed_effects:
|
||||
assert_admin(ctx.member)
|
||||
|
@ -72,7 +72,10 @@ class FFmpegNormalAudio(discord.FFmpegAudio):
|
||||
return chunk
|
||||
|
||||
def droppable(self) -> bool:
|
||||
return self._loaded and time.time() - self.loaded_at < 600
|
||||
if self.loaded_at is None:
|
||||
return False
|
||||
else:
|
||||
return self._loaded and time.time() - self.loaded_at < 600
|
||||
|
||||
def read(self):
|
||||
ret = self._raw_read()
|
||||
|
@ -10,18 +10,20 @@ mainasrcs: dict[discord.Guild, MainAudio] = {}
|
||||
async def raw_vc_for(ctx: Context) -> discord.VoiceClient:
|
||||
if ctx.guild is None:
|
||||
raise Explicit('not in a guild')
|
||||
vc: discord.VoiceProtocol = ctx.guild.voice_client
|
||||
assert ctx.member is not None
|
||||
vc: discord.VoiceProtocol | None = ctx.guild.voice_client
|
||||
if vc is None or isinstance(vc, discord.VoiceClient) and not vc.is_connected():
|
||||
vs: discord.VoiceState = ctx.member.voice
|
||||
vs: discord.VoiceState | None = ctx.member.voice
|
||||
if vs is None:
|
||||
raise Explicit('not connected')
|
||||
vch: discord.VoiceChannel = vs.channel
|
||||
vch: discord.VoiceChannel | None = vs.channel # type: ignore
|
||||
if vch is None:
|
||||
raise Explicit('not connected')
|
||||
try:
|
||||
vc: discord.VoiceProtocol = await vch.connect()
|
||||
vc = await vch.connect()
|
||||
except discord.ClientException:
|
||||
vc: discord.VoiceProtocol = ctx.guild.voice_client
|
||||
vc = ctx.guild.voice_client
|
||||
assert vc is not None
|
||||
await ctx.guild.fetch_channels()
|
||||
await vc.disconnect(force=True)
|
||||
raise Explicit('try again later')
|
||||
|
@ -1,6 +1,7 @@
|
||||
import asyncio
|
||||
import subprocess
|
||||
from typing import Optional
|
||||
from adaas.cachedb import RemoteCache
|
||||
|
||||
from v6d2ctx.context import Benchmark
|
||||
|
||||
@ -10,6 +11,8 @@ from v6d3music.utils.tor_prefix import tor_prefix
|
||||
|
||||
|
||||
async def real_url(url: str, override: bool, tor: bool) -> str:
|
||||
if not tor:
|
||||
return await RemoteCache().real_url(url, override, tor)
|
||||
hurl: str = bytes_hash(url.encode())
|
||||
if not override:
|
||||
curl: Optional[str] = cache_db.get(f'url:{hurl}', None)
|
||||
@ -33,6 +36,7 @@ async def real_url(url: str, override: bool, tor: bool) -> str:
|
||||
code = await loop.run_in_executor(None, p.wait)
|
||||
if code:
|
||||
raise RuntimeError(code)
|
||||
assert p.stdout is not None
|
||||
rurl: str = p.stdout.readline().decode()[:-1]
|
||||
loop.create_task(cache_url(hurl, rurl, override, tor))
|
||||
return rurl
|
||||
|
@ -61,7 +61,7 @@ async def restore_vcs():
|
||||
async with lock_for(guild, 'not in a guild'):
|
||||
channels = await guild.fetch_channels()
|
||||
channel: discord.VoiceChannel
|
||||
channel, = [ch for ch in channels if ch.id == vccid]
|
||||
channel, = [ch for ch in (chc for chc in channels if isinstance(chc, discord.VoiceChannel)) if ch.id == vccid]
|
||||
vp: discord.VoiceProtocol = await channel.connect()
|
||||
assert isinstance(vp, discord.VoiceClient)
|
||||
vc = vp
|
||||
@ -105,7 +105,7 @@ async def save_vcs(delay: bool):
|
||||
if vcs_restored:
|
||||
vcs = []
|
||||
vc: discord.VoiceClient
|
||||
for vc in list(client.voice_clients):
|
||||
for vc in (vcc for vcc in client.voice_clients if isinstance(vcc, discord.VoiceClient)):
|
||||
if delay:
|
||||
await asyncio.sleep(0.01)
|
||||
if vc.is_playing():
|
||||
|
Loading…
Reference in New Issue
Block a user