コード例 #1
0
ファイル: shawarma_bot.py プロジェクト: ICQ-BOTS/shawerma_bot
DEV = config.has_option("main", "dev") and config.getboolean("main", "dev")
state.TRASH_CHAT = config.get("icq_bot", "trash_chat")
bot_db.load_admins(json.loads(config.get("icq_bot", "admins")))

DB_HOST = config.get("tarantool", "host")
DB_PORT = config.get("tarantool", "port")

PUT_FACES_IP = config.get("put_faces_service", "host")
PUT_FACES_PORT = config.get("put_faces_service", "port")

loop = asyncio.get_event_loop()
bot = Bot(
    token=TOKEN,
    version=VERSION,
    name=NAME,
    poll_time_s=POLL_TIMEOUT_S,
    request_timeout_s=REQUEST_TIMEOUT_S,
    task_max_len=TASK_MAX_LEN,
    task_timeout_s=TASK_TIMEOUT_S,
)

bot.dispatcher.add_handler(
    DefaultHandler(callback=EventHandlers.handle_session_start, multiline=True)
)


bot_states.init(PUT_FACES_IP, PUT_FACES_PORT, DB_HOST, int(DB_PORT))

# ---------------------------------------------------------------------

コード例 #2
0
ファイル: fate_bot.py プロジェクト: ICQ-BOTS/fate_bot
if len(sys.argv) > 1:
    configs_path = sys.argv[1]

# Check exists config
if not os.path.isfile(os.path.join(configs_path, "logging.ini")):
    raise FileExistsError(f"File logging.ini not found in path {configs_path}")

logging.config.fileConfig(os.path.join(configs_path, "logging.ini"),
                          disable_existing_loggers=False)
log = logging.getLogger(__name__)

NAME = "ball_of_fate2"
TOKEN = "***.**********.**********:*********"

loop = asyncio.get_event_loop()
bot = Bot(token=TOKEN, name=NAME)

# Register your handlers here
# ---------------------------------------------------------------------
bot.dispatcher.add_handler(StartCommandHandler(callback=start))
bot.dispatcher.add_handler(
    MessageHandler(callback=rand_color, filters=Filter.regexp('(?i)цвет')))
bot.dispatcher.add_handler(
    MessageHandler(
        callback=rand_number,
        filters=Filter.regexp(
            '(?i)(ск(о|а)льк(о|а)|как мн(о|а)г(о|а)|цифра|числ(о|а))')))
bot.dispatcher.add_handler(MessageHandler(callback=media,
                                          filters=Filter.media))
bot.dispatcher.add_handler(
    MessageHandler(callback=media, filters=Filter.sticker))