コード例 #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
    graphyte.init(
        config.get("graphite", "server"),
        prefix=
        f"{config.get('graphite', 'prefix')}.{config.get('main', 'alias')}",
    )

NAME = "RemBot"
VERSION = "0.0.1"
HASH_ = None
TOKEN = config.get("icq_bot", "token")
OWNER = config.get("icq_bot", "owner")
BOT_UIN = TOKEN.split(":")[-1]
POLL_TIMEOUT_S = int(config.get("icq_bot", "poll_time_s"))
REQUEST_TIMEOUT_S = int(config.get("icq_bot", "request_timeout_s"))
TASK_TIMEOUT_S = int(config.get("icq_bot", "task_timeout_s"))
TASK_MAX_LEN = int(config.get("icq_bot", "task_max_len"))
BOT_API_HOST = config.get("icq_bot", "host")

PID_NAME = config.get("main", "pid")

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,
    api_url_base=BOT_API_HOST,
)
コード例 #3
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))
コード例 #4
0
from pid import PidFile
from config import *
from handlers import *
from mailru_im_async_bot.bot import Bot
from mailru_im_async_bot.filter import Filter
from mailru_im_async_bot.handler import MessageHandler, BotButtonCommandHandler

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)

# Register your handlers here
# ---------------------------------------------------------------------

bot.dispatcher.add_handler(
    BotButtonCommandHandler(callback=subscription,
                            filters=Filter.callback_data('subscription')))
bot.dispatcher.add_handler(
    BotButtonCommandHandler(callback=formal_reply,
                            filters=Filter.callback_data('formal_reply')))
bot.dispatcher.add_handler(
    BotButtonCommandHandler(callback=rand_photo,
                            filters=Filter.callback_data('rand_photo')))
bot.dispatcher.add_handler(
    BotButtonCommandHandler(callback=start,
                            filters=Filter.callback_data('main')))
bot.dispatcher.add_handler(MessageHandler(callback=start))