Exemplo n.º 1
0
 def __init__(self, total_shards):
     logger.info(f"Number of shards: {total_shards}")
     self.hoarfrost_gen = HoarFrostGenerator()
     self.total_shards = total_shards
     self.registered = [False for _ in range(total_shards)]
     self.last_checkin = {}
     self.store = {}
Exemplo n.º 2
0
    def __init__(self, **kwargs):
        self.session = get_session()
        self.asyncpg_wrapper = AsyncConnWrapper()
        self.deletable_messages = []

        self.hoarfrost_gen = HoarFrostGenerator()

        logger.debug("registering with manager...")
        manager_client = grpc_client.get_blocking_client('manager:50051')
        while True:
            try:
                shard_info = manager_client.register(message.RegisterRequest())
                break
            except Exception:
                logger.info("Trying to get shard id from manager")
                time.sleep(3)
        self.shard_id = shard_info.shard_id
        shard_dict = {
            'shard_id': shard_info.shard_id,
            'shard_count': shard_info.shard_count
        }
        logger.info(f"Got shard_id {self.shard_id}")

        kwargs.update(shard_dict)
        super().__init__(**kwargs)
Exemplo n.º 3
0
 def __init__(self, total_shards):
     """
     Instantiates a new manager server that handles some
     number of shards.
     """
     logger.info(f"Number of shards: {total_shards}")
     self.hoarfrost_gen = HoarFrostGenerator()
     self.total_shards = total_shards
     self.registered = [False for _ in range(total_shards)]
     self.last_checkin = dict()
     self.store = dict()
Exemplo n.º 4
0
    def __init__(self, **kwargs):
        self.user_commands = {}
        self.session = get_session()
        self.deletable_messages = []

        self.hoarfrost_gen = HoarFrostGenerator()

        manager_client = blocking_rpc_client.shardRPC()
        # wait for manager to come up; this is scuffed
        import time
        time.sleep(2)
        logger.debug("asking for shard id")

        shard_info, sc = manager_client.register(routing_key='manager_rpc')
        self.shard_id = shard_info['shard_id']
        logger.info(f"Got shard_id {self.shard_id}")

        kwargs.update(shard_info)
        super().__init__(**kwargs)
Exemplo n.º 5
0
from discord import Emoji

from PIL import ImageChops, Image
from lib.hoar_frost import HoarFrostGenerator
from src.utils import download_emoji
from lib.config import logger

hoarfrost_gen = HoarFrostGenerator()


class ArchitusEmoji:
    @classmethod
    async def from_discord(cls, emoji: Emoji):
        '''creates an architus emoji from a discord emoji'''
        im = Image.open(await download_emoji(emoji))
        return cls(im, emoji.name, None, emoji.id,
                   emoji.user.id if emoji.user is not None else None)

    def __init__(self,
                 im: Image,
                 name: str,
                 id: int = None,
                 discord_id: int = None,
                 author_id: int = None,
                 num_uses: int = 0,
                 priority: float = 0.0):

        self.im = im
        self.name = name

        if id is None: