<commit_before>package main

import (
	"bufio"
	"bytes"
	"encoding/xml"
	"fmt"
	"math/rand"
	"net/http"
	"net/url"
	"strings"
	"text/template"

	"github.com/Sirupsen/logrus"
)

// Image from Flickr API
type Image struct {
	Photos struct {
		Page    int    `xml:"page,attr"`
		Pages   int    `xml:"pages,attr"`
		PerPage int    `xml:"perpage,attr"`
		Total   string `xml:"total,attr"`
		Photo   []struct {
			ID       string `xml:"id,attr"`
			Owner    string `xml:"owner,attr"`
			Secret   string `xml:"secret,attr"`
			Server   string `xml:"server,attr"`
			Farm     int    `xml:"farm,attr"`
			Title    string `xml:"title,attr"`
			IsPublic int    `xml:"ispublic,attr"`
			IsFriend int    `xml:"isfriend,attr"`
			IsFamily int    `xml:"isfamily,attr"`
			URLZ     string `xml:"url_z,attr"`
			HeightZ  string `xml:"height_z,attr"`
			WidthZ   string `xml:"width_z,attr"`
			URLN     string `xml:"url_n,attr"`
			HeightN  string `xml:"height_n,attr"`
			WidthN   string `xml:"width_n,attr"`
			URLO     string `xml:"url_o,attr"`
			HeightO  string `xml:"height_o,attr"`
			WidthO   string `xml:"width_o,attr"`
		} `xml:"photo"`
	} `xml:"photos"`
	Stat string `xml:"stat,attr"`
}

func pluginImg(result Result) {
	logrus.Infof("pluginImg: request %d", result.UpdateID)

	err := sendChatAction(result.Message.Chat.ID, result.Message.MessageID, "upload_photo")
	if err != nil {
		logrus.Error("pluginImg:", err)
		return
	}

	key := url.QueryEscape(strings.TrimPrefix(result.Message.Text, "/img "))

	res, err := http.Get(fmt.Sprintf("https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=%s&extras=url_z,url_n,url_o&text=%s", config.FlickrAPIKey, key))
	if err != nil {<commit_msg>flickr: use 10 most relevant images, disable safe search<commit_after>package main

import (
	"bufio"
	"bytes"
	"encoding/xml"
	"fmt"
	"math/rand"
	"net/http"
	"net/url"
	"strings"
	"text/template"

	"github.com/Sirupsen/logrus"
)

// Image from Flickr API
type Image struct {
	Photos struct {
		Page    int    `xml:"page,attr"`
		Pages   int    `xml:"pages,attr"`
		PerPage int    `xml:"perpage,attr"`
		Total   string `xml:"total,attr"`
		Photo   []struct {
			ID       string `xml:"id,attr"`
			Owner    string `xml:"owner,attr"`
			Secret   string `xml:"secret,attr"`
			Server   string `xml:"server,attr"`
			Farm     int    `xml:"farm,attr"`
			Title    string `xml:"title,attr"`
			IsPublic int    `xml:"ispublic,attr"`
			IsFriend int    `xml:"isfriend,attr"`
			IsFamily int    `xml:"isfamily,attr"`
			URLZ     string `xml:"url_z,attr"`
			HeightZ  string `xml:"height_z,attr"`
			WidthZ   string `xml:"width_z,attr"`
			URLN     string `xml:"url_n,attr"`
			HeightN  string `xml:"height_n,attr"`
			WidthN   string `xml:"width_n,attr"`
			URLO     string `xml:"url_o,attr"`
			HeightO  string `xml:"height_o,attr"`
			WidthO   string `xml:"width_o,attr"`
		} `xml:"photo"`
	} `xml:"photos"`
	Stat string `xml:"stat,attr"`
}

func pluginImg(result Result) {
	logrus.Infof("pluginImg: request %d", result.UpdateID)

	err := sendChatAction(result.Message.Chat.ID, result.Message.MessageID, "upload_photo")
	if err != nil {
		logrus.Error("pluginImg:", err)
		return
	}

	key := url.QueryEscape(strings.TrimPrefix(result.Message.Text, "/img "))

	res, err := http.Get(fmt.Sprintf("https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=%s&safe_search=3&sort=relevance&per_page=10&extras=url_z,url_n,url_o&text=%s", config.FlickrAPIKey, key))
	if err != nil {
{'fraction_non_alphanumeric': 0.16303099885189437, 'fraction_numerical': 0.0014351320321469576, 'mean_word_length': 4.0, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 52}, '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': '2301999', 'n_tokens_mistral': 1406, 'n_tokens_neox': 1286, 'n_words': 254}