<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
import logging
import logging.config

from telegram.ext import Updater, InlineQueryHandler, CallbackQueryHandler, MessageHandler

import handlers
import logconf
from bot_api_token import TELEGRAM_BOT_API_TOKEN
from db import db
from voca_db import voca_db

logconf.start()
logger = logging.getLogger(__name__)


# noinspection PyUnusedLocal
def error(bot, update, err):
    logger.warning('Update "%s" caused error "%s"' % (update, err))


# noinspection PyUnusedLocal,PyIncorrectDocstring
def all_msg_filter(update):
    """We want them all!"""
    return True


def main():
    dp.addHandler(MessageHandler([all_msg_filter], handlers.MessageHandler))

    dp.addHandler(InlineQueryHandler(handlers.InlineQueryHandler))

    dp.addHandler(CallbackQueryHandler(handlers.CallbackQueryHandler))

    dp.addErrorHandler(error)

    # Add DB saving to job queue
    queue.put(db.commit, interval=5 * 60, repeat=True)

    updater.start_polling()
    updater.idle()


if __name__ == '__main__':
    # noinspection SpellCheckingInspection
    updater = Updater(token=TELEGRAM_BOT_API_TOKEN, workers=8, job_queue_tick_interval=60)
    dp = updater.dispatcher
    queue = updater.job_queue

    voca_db.set_name(updater.bot.name)<commit_msg>Have API key in env var instead of python source file.<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
import logging
import logging.config
import os

from telegram.ext import Updater, InlineQueryHandler, CallbackQueryHandler, MessageHandler

import handlers
import logconf
from db import db
from voca_db import voca_db

logconf.start()
logger = logging.getLogger(__name__)


# noinspection PyUnusedLocal
def error(bot, update, err):
    logger.warning('Update "%s" caused error "%s"' % (update, err))


# noinspection PyUnusedLocal,PyIncorrectDocstring
def all_msg_filter(update):
    """We want them all!"""
    return True


def main():
    dp.addHandler(MessageHandler([all_msg_filter], handlers.MessageHandler))

    dp.addHandler(InlineQueryHandler(handlers.InlineQueryHandler))

    dp.addHandler(CallbackQueryHandler(handlers.CallbackQueryHandler))

    dp.addErrorHandler(error)

    # Add DB saving to job queue
    queue.put(db.commit, interval=5 * 60, repeat=True)

    updater.start_polling()
    updater.idle()


if __name__ == '__main__':
    # noinspection SpellCheckingInspection
    updater = Updater(token=os.environ.get('VOCABOT_API_KEY'), workers=8, job_queue_tick_interval=60)
    dp = updater.dispatcher
    queue = updater.job_queue

    voca_db.set_name(updater.bot.name)
{'fraction_non_alphanumeric': 0.10111495578623607, 'fraction_numerical': 0.005382545174932718, 'mean_word_length': 4.940639269406392, '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': '7667301', 'n_tokens_mistral': 856, 'n_tokens_neox': 839, 'n_words': 187}