예제 #1
0
log.setLevel(logging.DEBUG)

if ty.TYPE_CHECKING:
    from flux.context import MessageContext


class Pinbot:
    def __init__(self):
        self.event_router = aurcore.event.EventRouter(name="roombot")
        self.flux = flux.Flux("pinbot",
                              admin_id=TOKENS.ADMIN_ID,
                              parent_router=self.event_router)
        print("init!")

        @self.flux.router.endpoint(":ready")
        def rdy(event: aurcore.event.Event):
            print("Ready!")

    async def startup(self, token: str):
        await self.flux.start(token)

    async def shutdown(self):
        await self.flux.logout()


pinbot = Pinbot()

pinbot.flux.register_cog(PinHandler)
pinbot.flux.register_cog(Interface)
aurcore.aiorun(pinbot.startup(token=TOKENS.PINBOT), pinbot.shutdown())
예제 #2
0
import aurflux

import TOKENS

import cogs

aurcore.log.setup()
if ty.TYPE_CHECKING:
    pass


class UABot(aurcore.AurCore):
    def __init__(self):
        super(UABot, self).__init__(name="uabot")
        self.flux = aurflux.FluxClient(self.__class__.__name__,
                                       admin_id=TOKENS.ADMIN_ID,
                                       parent_router=self.router,
                                       host=self)

    async def startup(self, token: str):
        # await ScrapeEventer(parent_router=self.router, interval=60*60).startup()
        await self.flux.startup(token)

    async def shutdown(self):
        await self.flux.logout()


uabot = UABot()
uabot.flux.register_cog(cogs.Output)
aurcore.aiorun(uabot.startup(token=TOKENS.UABOT), uabot.shutdown())
예제 #3
0
import TOKENS
import aurcore
import aurflux
import stats
import discord

if ty.TYPE_CHECKING:
    from aurflux.command import *


class Statbot:
    def __init__(self):
        self.event_router = aurcore.event.EventRouterHost(
            name=self.__class__.__name__)
        self.flux = aurflux.FluxClient(self.__class__.__name__,
                                       admin_id=TOKENS.ADMIN_ID,
                                       parent_router=self.event_router,
                                       intents=discord.Intents.all())

    async def startup(self, token: str):
        await self.flux.startup(token)

    async def shutdown(self):
        await self.flux.logout()


roombot = Statbot()
roombot.flux.register_cog(stats.MessageScraper)

aurcore.aiorun(roombot.startup(token=TOKENS.STATBOT), roombot.shutdown())
예제 #4
0
if ty.TYPE_CHECKING:
    from aurflux.command import *


class ExtinctBot:
    def __init__(self):
        self.event_router = aurcore.event.EventRouterHost(
            name=self.__class__.__name__)
        self.flux = aurflux.FluxClient(self.__class__.__name__,
                                       admin_id=TOKENS.ADMIN_ID,
                                       parent_router=self.event_router,
                                       intents=discord.Intents.all())

    async def startup(self, token: str):
        await self.flux.startup(token)

    async def shutdown(self):
        await self.flux.logout()


#
# async def startup():
#   ssl_context = ssl.create_default_context()
#   print(ssl.get_default_verify_paths())
#   # ssl_context.load_verify_locations(certifi.where())
#   pool: asyncpg.pool.Pool = await asyncpg.create_pool(TOKENS.PSQL_STRING, ssl=ssl_context)

extinctBot = ExtinctBot()
extinctBot.flux.register_cog(Scheduler)
aurcore.aiorun(extinctBot.startup(token=TOKENS.EXTINCT), extinctBot.shutdown())
# asyncio.run(startup())
예제 #5
0
            print("Tock!")
            for guild in self.flux.guilds:
                async with self.flux.CONFIG.writeable_conf(guild.id) as cfg:
                    if "closing_channels" not in cfg:
                        return
                    channels_to_check = cfg["closing_channels"]

                closed_channels: ty.Set[discord.TextChannel] = set()
                for channel_id in channels_to_check:
                    channel: discord.TextChannel = self.flux.get_channel(channel_id)
                    if not channel:
                        closed_channels.add(channel)

                    if channel_id in self.last_seen_cache:
                        last_seen = self.last_seen_cache[channel_id].created_at
                    else:
                        last_seen = (await channel.history(limit=1).flatten())[0]

                    if last_seen < (datetime.datetime.utcnow() + datetime.timedelta(days=1)):
                        closed_channels.add(channel.id)
                        await channel.delete(reason=f"24 hours since last activity: {last_seen.isoformat(sep=' ')}")

                async with self.flux.CONFIG.writeable_conf(guild.id) as cfg:
                    cfg["closing_channels"] = list(set(cfg["closing_channels"]) - closed_channels)


roombot = Roombot()
roombot.flux.register_cog(RoomHandler)

aurcore.aiorun(roombot.startup(token=TOKENS.AURTEST), roombot.shutdown())
예제 #6
0
파일: aurora.py 프로젝트: Zenith00/lumen
    async def startup(self, aurora_token: str):
        await self.discord.start(aurora_token)
        # await self.webserver.start()

    async def shutdown(self):
        await self.discord.logout()
        # await self.webserver.runner.shutdown()
        # await self.webserver.runner.cleanup()
        # await self.webserver.server.shutdown()


aurora = Aurora()

# @arghify
# @aurora.discord.commandeer()
# async def remindme(ctx: Context, message: str, duration: Arg(names=("-d",), nargs="*", required=True, action=JoinAction)):
#     print(dateparser.parse(duration))
#     return flux.response.Response()

# @aurora.event_router.endpoint("discord:ready")
# def printy(event: flux.event.Event):
#     print(f"ready! {event}")
#
# #
# @aurora.event_router.endpoint("discord")
# def dbg(event: flux.event.Event):
#     print(f"==dbg: {event}")

# aurora.discord.run(TOKENS.AURORA)
aurcore.aiorun(aurora.startup(aurora_token=TOKENS.AURORA), aurora.shutdown())
예제 #7
0
from loguru import logger
logger.add("stdout", backtrace=True, diagnose=True)

# from .. import aurflux
import aurcore as aur
import TOKENS


class TestBot:
    def __init__(self):
        self.event_router = aur.EventRouterHost(name="triviabot")
        self.aurflux = aurflux.FluxClient("testbot",
                                          admin_id=TOKENS.ADMIN_ID,
                                          parent_router=self.event_router,
                                          builtins=True)

        # self.aurflux.router.endpoint(":ready")(lambda ev: print("Ready!"))

    async def startup(self, token: str):
        await self.aurflux.startup(token)

    async def shutdown(self):
        await self.aurflux.shutdown()
        await self.aurflux.aiohttp_session.close()


triviabot = TestBot()

aur.aiorun(triviabot.startup(token=TOKENS.TESTBOT), triviabot.shutdown())