<commit_before>const Telegraf = require('telegraf');
const commandParts = require('telegraf-command-parts');
const cfg = require('../config');
const commander = require('./commander');
const middleware = require('./middleware');

const bot = new Telegraf(cfg.tgToken);

// Apply middleware
bot.use(commandParts());
bot.use(middleware.getSession);

bot.command('kirjaudu', commander.login);

bot.command('saldo', middleware.loggedIn, commander.saldo);
bot.command('lisaa', middleware.loggedIn, commander.add);
bot.command('viiva', middleware.loggedIn, commander.subtract);

bot.on('message', commander.message);

// Get own username to handle commands such as /start@my_bot
bot.telegram.getMe()
.then((botInfo) => {
  bot.options.username = botInfo.username;
});

// Setup webhook when in production
if (cfg.isProduction) {
  bot.telegram.setWebhook(`${cfg.appUrl}/bot${cfg.tgToken}`);
  bot.startWebhook(`/bot${cfg.tgToken}`, null, cfg.appPort);

// If env is development, get updates by polling
} else {
  bot.telegram.setWebhook(); // Unsubscribe webhook if it exists
  bot.startPolling();
}<commit_msg>Use /start command as login and use proper webhook remover function<commit_after>const Telegraf = require('telegraf');
const commandParts = require('telegraf-command-parts');
const cfg = require('../config');
const commander = require('./commander');
const middleware = require('./middleware');

const bot = new Telegraf(cfg.tgToken);

// Apply middleware
bot.use(commandParts());
bot.use(middleware.getSession);

bot.command('start', commander.login);
bot.command('kirjaudu', commander.login);

bot.command('saldo', middleware.loggedIn, commander.saldo);
bot.command('lisaa', middleware.loggedIn, commander.add);
bot.command('viiva', middleware.loggedIn, commander.subtract);

bot.on('message', commander.message);

// Get own username to handle commands such as /start@my_bot
bot.telegram.getMe()
.then((botInfo) => {
  bot.options.username = botInfo.username;
});

// Setup webhook when in production
if (cfg.isProduction) {
  bot.telegram.setWebhook(`${cfg.appUrl}/bot${cfg.tgToken}`);
  bot.startWebhook(`/bot${cfg.tgToken}`, null, cfg.appPort);

// If env is development, get updates by polling
} else {
  bot.telegram.deleteWebhook(); // Unsubscribe webhook if it exists
  bot.startPolling();
}
{'fraction_non_alphanumeric': 0.16175195143104942, 'fraction_numerical': 0.0, 'mean_word_length': 5.5539772727272725, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5234111', 'n_tokens_mistral': 735, 'n_tokens_neox': 729, 'n_words': 164}