示例#1
0
async def main() -> None:
    """Register logger and components."""
    config = Config()

    handler = TGChannelLogHandler(config.log_bot_token, config.log_channel_id)
    await handler.connect()
    tlog.addHandler(handler)
    client = Client(str(config.session_name), config.api_id, config.api_hash)
    # noinspection PyTypeChecker
    await client.start(config.phone)
    client.config = config
    client.kantek_version = __version__

    client.plugin_mgr = PluginManager(client)
    client.plugin_mgr.register_all()

    logger.info('Connecting to Database')
    client.db = Database()
    await client.db.connect(config)

    tlog.info('Started Kantek v%s [%s]', __version__,
              helpers.link_commit(helpers.get_commit()))
    logger.info('Started Kantek v%s', __version__)

    if config.spamwatch_host and config.spamwatch_token:
        client.sw = SWClient(config.spamwatch_token,
                             host=config.spamwatch_host)
        client.sw_url = config.spamwatch_host

    await client.run_until_disconnected()
示例#2
0
async def main() -> None:
    """Register logger and components."""
    config = Config()

    handler = TGChannelLogHandler(config.log_bot_token, config.log_channel_id)
    await handler.connect()
    tlog.addHandler(handler)

    db = Database()
    await db.connect(config)

    client = Client(str(config.session_name),
                    config.api_id,
                    config.api_hash,
                    request_retries=8,
                    retry_delay=10,
                    auto_reconnect=True,
                    flood_sleep_threshold=60)
    # noinspection PyTypeChecker

    await client.connect()
    if not await client.is_user_authorized():
        await client.start()
    client.config = config
    client.kantek_version = __version__

    client.plugin_mgr = PluginManager(client)
    client.plugin_mgr.register_all()

    logger.info('Connecting to Database')
    client.db = db

    tlog.info('Started Kantek v%s [%s]', __version__,
              helpers.link_commit(helpers.get_commit()))
    logger.info('Started Kantek v%s', __version__)

    if config.spamwatch_host and config.spamwatch_token:
        client.sw = SWClient(config.spamwatch_token,
                             host=config.spamwatch_host)
        try:
            client.swo = SWClient(config.original_spamwatch_token)
        except:
            pass
        client.sw_url = config.spamwatch_host
    ich = await client.get_me()
    if not ich:
        client.self_id = 12345678
    else:
        client.self_id = ich.id

    await client.db.hashlist.add_column(self_id=client.self_id)
    print(config.sudos)
    #await client.catch_up()
    await client.run_until_disconnected()