コード例 #1
0
ファイル: bot.py プロジェクト: HeratixX/xenon
    def __init__(self, *args, **kwargs):
        super().__init__(
            command_prefix=self._prefix_callable,
            shard_count=self.config.shard_count,
            fetch_offline_members=False,
            shard_ids=[
                i
                for i in range(self.config.pod_id * self.config.shards_per_pod,
                               (self.config.pod_id + 1) *
                               self.config.shards_per_pod)
            ],
            owner_id=self.config.owner_id,
            disabled_events=[
                "VOICE_STATE_UPDATE", "PRESENCE_UPDATE", "TYPING_START",
                "GUILD_EMOJIS_UPDATE"
            ],
            *args,
            **kwargs)

        logger.setup()
        log.info("Running shards: " +
                 ", ".join([str(shard_id) for shard_id in self.shard_ids]))

        self.session = ClientSession(loop=self.loop)
        db_connection = AsyncIOMotorClient(host=self.config.db_host,
                                           username=self.config.db_user,
                                           password=self.config.db_password)
        self.db = getattr(db_connection, self.config.db_name)
        for ext in self.config.extensions:
            self.load_extension("cogs." + ext)

        log.info(f"Loaded {len(self.cogs)} cogs")
コード例 #2
0
 def __init__(self, base_url: str, headless):
     setup("INFO")
     logger.setLevel("INFO")
     driver_path = ChromeDriverManager().install()
     options = Options()
     if headless:
         options.add_argument("--headless")
     self.wd = webdriver.Chrome(driver_path, options=options)
     self.base_url = base_url
     self.login = LoginPage(self)
     self.currency = CurrencyPage(self)
     self.deposits = DepositsPage(self)
     self.cards = CardsPage(self)
     self.credit = CreditPage(self)
コード例 #3
0
def parse():
    # Get CLI information
    commands = _extract_commands()
    usage, description = _build_usage_and_desc(commands)

    # Build parser
    parser = argparse.ArgumentParser(
        usage=usage,
        description=description,
        formatter_class=argparse.RawTextHelpFormatter)
    parser.add_argument(
        "-v",
        "--verbose",
        action="store_true",
        help="set logging level to DEBUG",
    )
    parser.add_argument("command", help="command to run")

    # Parse arguments
    first_not_option_arg_pos = len(sys.argv)
    for i, arg in enumerate(sys.argv[1:]):
        if arg[0] != "-":
            first_not_option_arg_pos = i + 2
            break

    args = parser.parse_args(sys.argv[1:first_not_option_arg_pos])
    if args.command not in commands:
        print(f"ywc: '{args.command}' is not a ywc command. See 'ywc --help'.")
        exit(1)

    # Set logging level
    logger.setup(args.verbose)

    # Dispatch command call
    cmd_args = commands[args.command]["func_parse"](
        f"{sys.argv[0]} {args.command}", sys.argv[first_not_option_arg_pos:])
    commands[args.command]["func_run"](cmd_args)
コード例 #4
0
from utils import logger

logger.setup()
コード例 #5
0
async def prepare_bot(loop):
    logger.setup()
    return Xenon(loop=loop)
コード例 #6
0
ファイル: mainu.py プロジェクト: mainu4u/MainuTelegramBot
# -*- coding: utf-8 -*-
import telebot
import logging
import requests
import utils.logger as log

ROOT = ''  # ${ROOT_PATH} for production mode

TOKEN = open(ROOT + 'sens_data/token', 'r').read()[:-1]

bot = telebot.TeleBot(TOKEN)

log.setup(ROOT)
logger = logging.getLogger(__name__)

#############################################
# Listener
#############################################


def listener(msgs):
    for m in msgs:
        if m.content_type == 'text':
            logger.info("%s (%d) ha dicho: %s" %
                        (m.chat.first_name, m.chat.id, m.text))
        else:
            logger.info("%s (%d) ha enviado algo que no es texto." %
                        (m.chat.first_name, m.chat.id))


bot.set_update_listener(listener)