<commit_before>package telegram

import (
	"OttBot2/models"
	"OttBot2/settings"
	"fmt"
	"gopkg.in/telegram-bot-api.v4"
	"strconv"
	"strings"
	"OttBot2/metrics"
)

var BotTarget *models.ChatUser

func HandleUsers(upd tgbotapi.Update, bot *tgbotapi.BotAPI) {
	foundUser := models.ChatUserFromTGID(upd.Message.From.ID, upd.Message.From.UserName)
	models.UpdateAliases(upd.Message.From.FirstName, upd.Message.From.LastName, foundUser.ID)
	fmt.Println(foundUser)
}
func FindUserByUsername(upd tgbotapi.Update, bot *tgbotapi.BotAPI) {
	if upd.Message.Chat.ID == settings.GetControlID() {
		username := upd.Message.Text[7:]
		username = strings.Trim(username, " ")
		username = strings.ToLower(username) //Woo string processing
		user := models.SearchUserByUsername(username)
		if user != nil {
			curAlias := models.GetLatestAliasFromUserID(user.ID)
			fmt.Println(user)
			outmsg := fmt.Sprintf("UserID: %d\nCurrent Name: %s\n", user.TgID, curAlias.Name)
			for _, warn := range models.GetUsersWarnings(user) {
				outmsg += warn.WarningText + "\n"
			}
			newMsg := tgbotapi.NewMessage(settings.GetControlID(), outmsg)
			bot.Send(newMsg)
		} else {
			newMsg := tgbotapi.NewMessage(settings.GetControlID(), "User not found.")
			bot.Send(newMsg)
		}
	}

}
func FindUserByUserID(upd tgbotapi.Update, bot *tgbotapi.BotAPI) {
	var userName string
	if upd.Message == nil {
		userName = upd.CallbackQuery.Data[5:]
		config := tgbotapi.NewCallback(upd.CallbackQuery.ID, "") //We don't need this so get it outta da way.
		bot.AnswerCallbackQuery(config)
	} else {
		userName = upd.Message.Text[5:]
	}
	fmt.Println(userName)
	userName = strings.Trim(userName, " ")
	usrID, err := strconv.ParseInt(userName, 10, 64)
	if err != nil {
		newMsg := tgbotapi.NewMessage(upd.Message.Chat.ID, "Error parsing userID. Make sure it's an actual number!")
		fmt.Println(userName)
		fmt.Println(err)
		bot.Send(newMsg)
		return
	}
	user := models.ChatUserFromTGIDNoUpd(int(usrID))
	if user != nil {
		curAlias := models.GetLatestAliasFromUserID(user.ID)
		fmt.Println(user)
		outmsg := fmt.Sprintf("UserID: %d\nCurrent Name:%s\n", user.TgID, curAlias.Name)
		for _, warn := range models.GetUsersWarnings(user) {
			outmsg += warn.WarningText + "\n"
		}
		newMsg := tgbotapi.NewMessage(settings.GetControlID(), outmsg)<commit_msg>Update info calls to return active user status<commit_after>package telegram

import (
	"OttBot2/models"
	"OttBot2/settings"
	"fmt"
	"gopkg.in/telegram-bot-api.v4"
	"strconv"
	"strings"
	"OttBot2/metrics"
)

var BotTarget *models.ChatUser

func HandleUsers(upd tgbotapi.Update, bot *tgbotapi.BotAPI) {
	foundUser := models.ChatUserFromTGID(upd.Message.From.ID, upd.Message.From.UserName)
	models.UpdateAliases(upd.Message.From.FirstName, upd.Message.From.LastName, foundUser.ID)
	fmt.Println(foundUser)
}
func FindUserByUsername(upd tgbotapi.Update, bot *tgbotapi.BotAPI) {
	if upd.Message.Chat.ID == settings.GetControlID() {
		username := upd.Message.Text[7:]
		username = strings.Trim(username, " ")
		username = strings.ToLower(username) //Woo string processing
		user := models.SearchUserByUsername(username)
		if user != nil {
			curAlias := models.GetLatestAliasFromUserID(user.ID)
			fmt.Println(user)
			outmsg := fmt.Sprintf("UserID: %d\nCurrent Name:%s\nActive User: %t", user.TgID, curAlias.Name, user.ActiveUser)
			for _, warn := range models.GetUsersWarnings(user) {
				outmsg += warn.WarningText + "\n"
			}
			newMsg := tgbotapi.NewMessage(settings.GetControlID(), outmsg)
			bot.Send(newMsg)
		} else {
			newMsg := tgbotapi.NewMessage(settings.GetControlID(), "User not found.")
			bot.Send(newMsg)
		}
	}

}
func FindUserByUserID(upd tgbotapi.Update, bot *tgbotapi.BotAPI) {
	var userName string
	if upd.Message == nil {
		userName = upd.CallbackQuery.Data[5:]
		config := tgbotapi.NewCallback(upd.CallbackQuery.ID, "") //We don't need this so get it outta da way.
		bot.AnswerCallbackQuery(config)
	} else {
		userName = upd.Message.Text[5:]
	}
	fmt.Println(userName)
	userName = strings.Trim(userName, " ")
	usrID, err := strconv.ParseInt(userName, 10, 64)
	if err != nil {
		newMsg := tgbotapi.NewMessage(upd.Message.Chat.ID, "Error parsing userID. Make sure it's an actual number!")
		fmt.Println(userName)
		fmt.Println(err)
		bot.Send(newMsg)
		return
	}
	user := models.ChatUserFromTGIDNoUpd(int(usrID))
	if user != nil {
		curAlias := models.GetLatestAliasFromUserID(user.ID)
		fmt.Println(user)
		outmsg := fmt.Sprintf("UserID: %d\nCurrent Name:%s\nActive User: %t", user.TgID, curAlias.Name, user.ActiveUser)
		for _, warn := range models.GetUsersWarnings(user) {
			outmsg += warn.WarningText + "\n"
		}
		newMsg := tgbotapi.NewMessage(settings.GetControlID(), outmsg)
{'fraction_non_alphanumeric': 0.14158163265306123, 'fraction_numerical': 0.00467687074829932, 'mean_word_length': 4.554899645808737, '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': '206370', 'n_tokens_mistral': 1873, 'n_tokens_neox': 1737, 'n_words': 319}