<commit_before>import logging
from typing import *

import config
from bot import models, trello, messages, trello_wh
from bot.base_bot import BaseBot, Context, Dialog

logging.basicConfig(
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
    level=logging.INFO)


class AddHookDialog(Dialog):

    def __init__(self, boards):
        self.boards = boards
        self.board_options = [ b.name for b in self.boards ]
        self.board_map = { b.name: b for b in self.boards }

        super().__init__()

    def step1(self, ctx: Context):
        try:
            board = self.board_map[ctx.text]
        except KeyError:
            ctx.send_message(messages.NOTIFY_NOBOARD)
            return False

        try:
            ctx.trello_session.webhooks.add(
                callbackURL=ctx.base_bot.wh_reciever.callback_url(ctx.chat_id),
                idModel=board.id,
            )
        except trello.TrelloError as e:
            ctx.send_message('```' + str(e) + '```')
            return True

        (hook, created) = models.BoardHook.get_or_create(session=ctx.session, board_id=board.id)
        if not created:
            ctx.send_message(messages.NOTIFY_ALREADY)
            return True

        ctx.send_message(messages.NOTIFY_SUCCESS)
        return True

    step1_message = messages.NOTIFY_DLG_MSG

    @property
    def step1_options(self):
        return self.board_options
<commit_msg>Do not care if it exists<commit_after>import logging
from typing import *

import config
from bot import models, trello, messages, trello_wh
from bot.base_bot import BaseBot, Context, Dialog

logging.basicConfig(
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
    level=logging.INFO)


class AddHookDialog(Dialog):

    def __init__(self, boards):
        self.boards = boards
        self.board_options = [ b.name for b in self.boards ]
        self.board_map = { b.name: b for b in self.boards }

        super().__init__()

    def step1(self, ctx: Context):
        try:
            board = self.board_map[ctx.text]
        except KeyError:
            ctx.send_message(messages.NOTIFY_NOBOARD)
            return False

        try:
            ctx.trello_session.webhooks.add(
                callbackURL=ctx.base_bot.wh_reciever.callback_url(ctx.chat_id),
                idModel=board.id,
            )
        except trello.TrelloError as e:
            text = str(e)
            if 'already exists' not in text:
                ctx.send_message('```' + text + '```')
                return True

        (hook, created) = models.BoardHook.get_or_create(session=ctx.session, board_id=board.id)
        if not created:
            ctx.send_message(messages.NOTIFY_ALREADY)
            return True

        ctx.send_message(messages.NOTIFY_SUCCESS)
        return True

    step1_message = messages.NOTIFY_DLG_MSG

    @property
    def step1_options(self):
        return self.board_options

{'fraction_non_alphanumeric': 0.0976271186440678, 'fraction_numerical': 0.002033898305084746, 'mean_word_length': 2.2464246424642464, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4637014', 'n_tokens_mistral': 931, 'n_tokens_neox': 893, 'n_words': 195}