<commit_before>const Promise = require('bluebird')
const { allowedToSendToChatAlready } = require('./flood-control')
const { CachingImageSender } = require('./caching-image-sender')
const Jimp = require("jimp")
Jimp.prototype.getBufferAsync = Promise.promisify(Jimp.prototype.getBuffer)

const IMAGE_URLS = ['http://haba.tko-aly.fi/kuvat/webcam1.jpg', 'http://haba.tko-aly.fi/kuvat/webcam2.jpg']
const EIGHT_S_TO_MS = 8 * 1000

function createCamsCommand(tgClient) {
    const sender = new CachingImageSender(tgClient, fetchAndConvertPhoto, EIGHT_S_TO_MS)

    return msg => {
        if (!allowedToSendToChatAlready(msg.chat.id)) return
        sender.send(msg.chat.id)
    }
}
<commit_msg>Show a 'Loading...' message while processing cmd<commit_after>const Promise = require('bluebird')
const { allowedToSendToChatAlready } = require('./flood-control')
const { CachingImageSender } = require('./caching-image-sender')
const Jimp = require("jimp")
Jimp.prototype.getBufferAsync = Promise.promisify(Jimp.prototype.getBuffer)

const IMAGE_URLS = ['http://haba.tko-aly.fi/kuvat/webcam1.jpg', 'http://haba.tko-aly.fi/kuvat/webcam2.jpg']
const EIGHT_S_TO_MS = 8 * 1000

function createCamsCommand(tgClient) {
    const camsSender = new CachingImageSender(tgClient, fetchAndConvertPhoto, EIGHT_S_TO_MS)

    return msg => {
        const chatId = msg.chat.id
        if (!allowedToSendToChatAlready(chatId)) return

        doWithLoadingMessage(tgClient, chatId, () => camsSender.send(chatId))
    }
}

// Send a "Loading..." message, then remove it after the action has finished
// doWithLoadingMessage(tgClient: TelegramClient, chatId: string, action: () => Thenable<void>)
function doWithLoadingMessage(tgClient, chatId, action) {
    const opts = {
        parse_mode: 'markdown',
        disable_notification: true
    }

    tgClient.sendMessage(chatId, '_Loading..._', opts).then(loadingMsg => {
        action().then(() => tgClient.deleteMessage(chatId, loadingMsg.message_id))
    })
}

{'fraction_non_alphanumeric': 0.135678391959799, 'fraction_numerical': 0.007035175879396985, 'mean_word_length': 4.454794520547945, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 10, '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': '2681828', 'n_tokens_mistral': 667, 'n_tokens_neox': 644, 'n_words': 117}