<commit_before>package main

import (
	"flag"
	"fmt"
	"log"
	"net"
	"os"

	"github.com/davecgh/go-spew/spew"
	"github.com/igungor/ilberbot/command"
	"github.com/igungor/tlbot"
)

// flags
var (
	token   = flag.String("token", "", "telegram bot token")
	webhook = flag.String("webhook", "", "webhook url")
	host    = flag.String("host", "", "host to listen to")
	port    = flag.String("port", "1985", "port to listen to")
	debug   = flag.Bool("d", false, "debug mode (*very* verbose)")
)

func usage() {
	fmt.Fprintf(os.Stderr, "ilberbot is a multi-purpose Telegram bot\n\n")
	fmt.Fprintf(os.Stderr, "usage:\n")
	fmt.Fprintf(os.Stderr, "  ilberbot -token <insert-your-telegrambot-token> -webhook <insert-your-webhook-url>\n\n")
	fmt.Fprintf(os.Stderr, "flags:\n")
	flag.PrintDefaults()
	os.Exit(2)
}

func main() {
	log.SetFlags(0)
	log.SetPrefix("ilberbot: ")
	flag.Usage = usage
	flag.Parse()

	if *token == "" {
		log.Printf("missing token parameter\n\n")
		flag.Usage()
	}
	if *webhook == "" {
		log.Printf("missing webhook parameter\n\n")
		flag.Usage()
	}

	b := tlbot.New(*token)
	err := b.SetWebhook(*webhook)
	if err != nil {
		log.Fatal(err)
	}

	if *debug {
		spew.Config.DisableMethods = true
	}

	messages := b.Listen(net.JoinHostPort(*host, *port))
	for msg := range messages {
		spew.Dump(msg)
		// is message a command?
		cmdname := msg.Command()
		if cmdname == "" {
			continue
		}

		// is the command even registered?
		cmd := command.Lookup(cmdname)
		if cmd == nil {
			continue
		}

		// it is. cool, run it!
		cmd.Run(&b, &msg)
	}
}<commit_msg>Do not block incoming messages<commit_after>package main

import (
	"flag"
	"fmt"
	"log"
	"net"
	"os"

	"github.com/davecgh/go-spew/spew"
	"github.com/igungor/ilberbot/command"
	"github.com/igungor/tlbot"
)

// flags
var (
	token   = flag.String("token", "", "telegram bot token")
	webhook = flag.String("webhook", "", "webhook url")
	host    = flag.String("host", "", "host to listen to")
	port    = flag.String("port", "1985", "port to listen to")
	debug   = flag.Bool("d", false, "debug mode (*very* verbose)")
)

func usage() {
	fmt.Fprintf(os.Stderr, "ilberbot is a multi-purpose Telegram bot\n\n")
	fmt.Fprintf(os.Stderr, "usage:\n")
	fmt.Fprintf(os.Stderr, "  ilberbot -token <insert-your-telegrambot-token> -webhook <insert-your-webhook-url>\n\n")
	fmt.Fprintf(os.Stderr, "flags:\n")
	flag.PrintDefaults()
	os.Exit(2)
}

func main() {
	log.SetFlags(0)
	log.SetPrefix("ilberbot: ")
	flag.Usage = usage
	flag.Parse()

	if *token == "" {
		log.Printf("missing token parameter\n\n")
		flag.Usage()
	}
	if *webhook == "" {
		log.Printf("missing webhook parameter\n\n")
		flag.Usage()
	}

	b := tlbot.New(*token)
	err := b.SetWebhook(*webhook)
	if err != nil {
		log.Fatal(err)
	}

	if *debug {
		spew.Config.DisableMethods = true
	}

	messages := b.Listen(net.JoinHostPort(*host, *port))
	for msg := range messages {
		spew.Dump(msg)
		// is message a command?
		cmdname := msg.Command()
		if cmdname == "" {
			continue
		}

		// is the command even registered?
		cmd := command.Lookup(cmdname)
		if cmd == nil {
			continue
		}

		// it is. cool, run it!
		go cmd.Run(&b, &msg)
	}
}
{'fraction_non_alphanumeric': 0.18389346861128725, 'fraction_numerical': 0.003804692454026633, 'mean_word_length': 3.443661971830986, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1471753', 'n_tokens_mistral': 1324, 'n_tokens_neox': 1260, 'n_words': 263}