better __all__

This commit is contained in:
AF 2022-12-28 07:42:57 +00:00
parent e2c07b8586
commit 6dce3758ea
3 changed files with 26 additions and 23 deletions

View File

@ -1,5 +1,5 @@
ptvp35 @ git+https://gitea.parrrate.ru/PTV/ptvp35.git@87ba808c2af1be87f4fbb9d9b3b97ba748cb9fae ptvp35 @ git+https://gitea.parrrate.ru/PTV/ptvp35.git@e760fca39e2070b9959aeb95b53e59e895f1ad57
v6d0auth @ git+https://gitea.parrrate.ru/PTV/v6d0auth.git@324236f435c92756aefe22877a97a906c462ef2c v6d0auth @ git+https://gitea.parrrate.ru/PTV/v6d0auth.git@c718d4d1422945a756213d22d9e26aa24babe0f6
v6d1tokens @ git+https://gitea.parrrate.ru/PTV/v6d1tokens.git@96567a0cb0c3cb60f20647518df5370df6dc6664 v6d1tokens @ git+https://gitea.parrrate.ru/PTV/v6d1tokens.git@9ada50f111bd6e9a49c9c6683fa7504fee030056
v6d2ctx @ git+https://gitea.parrrate.ru/PTV/v6d2ctx.git@4a821aa168a83924934b2ab833d283226eb307bb v6d2ctx @ git+https://gitea.parrrate.ru/PTV/v6d2ctx.git@18001ff3403646db46f36175a824e571c5734fd6
rainbowadn @ git+https://gitea.parrrate.ru/PTV/rainbowadn.git@e9fba7b064902ceedee0dd5578cb47030665a6aa rainbowadn @ git+https://gitea.parrrate.ru/PTV/rainbowadn.git@fc1d11f4b53ac4653ffac1bbcad130855e1b7f10

View File

@ -2,6 +2,8 @@ import os
from v6d0auth.config import root from v6d0auth.config import root
__all__ = ('prefix', 'myroot')
prefix = os.getenv('v6prefix', '??') prefix = os.getenv('v6prefix', '??')
myroot = root / 'v6d3vote' myroot = root / 'v6d3vote'
myroot.mkdir(exist_ok=True) myroot.mkdir(exist_ok=True)

View File

@ -1,17 +1,17 @@
import asyncio import asyncio
import os
from typing import Optional, TypedDict from typing import Optional, TypedDict
import discord import discord
from ptvp35 import Db, KVJson from v6d3vote.config import myroot, prefix
from v6d1tokens.client import request_token
from v6d2ctx.context import Context, at, monitor, Explicit
from v6d2ctx.handle_content import handle_content
from v6d2ctx.lock_for import lock_for
from v6d2ctx.pain import ALog, SLog
from v6d2ctx.serve import serve
from v6d3vote.config import prefix, myroot from ptvp35 import *
from v6d1tokens.client import *
from v6d2ctx.at_of import *
from v6d2ctx.context import *
from v6d2ctx.handle_content import *
from v6d2ctx.lock_for import *
from v6d2ctx.pain import *
from v6d2ctx.serve import *
loop = asyncio.new_event_loop() loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop) asyncio.set_event_loop(loop)
@ -41,7 +41,11 @@ async def on_ready():
) )
@at('commands', 'help') at_of: AtOf[str, command_type] = AtOf()
at, of = at_of()
@at('help')
async def help_(ctx: Context, args: list[str]) -> None: async def help_(ctx: Context, args: list[str]) -> None:
match args: match args:
case []: case []:
@ -88,9 +92,9 @@ class Poll:
for _, option in self.votes.items(): for _, option in self.votes.items():
count[option] = count.get(option, 0) + 1 count[option] = count.get(option, 0) + 1
return ( return (
f'{self.title}\n' f'{self.title}\n'
+ +
'\n'.join(f'{self.emojis[option]} `{count.get(option, 0)}` {option}' for option in self.options) '\n'.join(f'{self.emojis[option]} `{count.get(option, 0)}` {option}' for option in self.options)
) )
async def save(self): async def save(self):
@ -203,7 +207,7 @@ async def poll_options(args: list[str]) -> list[tuple[str, discord.Emoji | str]]
return options return options
@at('commands', 'poll') @at('poll')
async def create_poll(ctx: Context, args: list[str]) -> None: async def create_poll(ctx: Context, args: list[str]) -> None:
match args: match args:
case ['help']: case ['help']:
@ -223,7 +227,7 @@ async def create_poll(ctx: Context, args: list[str]) -> None:
@client.event @client.event
async def on_message(message: discord.Message) -> None: async def on_message(message: discord.Message) -> None:
await handle_content(message, message.content, prefix, client) await handle_content(of, message, message.content, prefix, client)
@client.event @client.event
@ -239,8 +243,6 @@ async def on_raw_reaction_remove(rrae: discord.RawReactionActionEvent) -> None:
async def main(): async def main():
async with vote_db: async with vote_db:
await client.login(token) await client.login(token)
if os.getenv('v6monitor'):
loop.create_task(monitor())
await client.connect() await client.connect()
print('exited') print('exited')
@ -253,7 +255,6 @@ if __name__ == '__main__':
ALog(Db, '__aenter__').enter(es) ALog(Db, '__aenter__').enter(es)
ALog(Db, '__aexit__').enter(es) ALog(Db, '__aexit__').enter(es)
ALog(Db, 'aclose').enter(es) ALog(Db, 'aclose').enter(es)
ALog(Db, '_build_file').enter(es)
SLog(Db, '_build_file_sync').enter(es) SLog(Db, '_build_file_sync').enter(es)
SLog(Db, '_finish_recovery_sync').enter(es) SLog(Db, '_finish_recovery_sync').enter(es)
SLog(Db, '_copy_sync').enter(es) SLog(Db, '_copy_sync').enter(es)