jimbot

package
v0.0.0-...-ed200d0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2025 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KISS     = "😘"
	HEART    = "💕"
	TONGUE   = "😋"
	UNHAPPY  = "😐"
	SILENT   = "😶"
	HUH      = "🌚"
	HII      = "🙃"
	SWEAT    = "😓"
	SURPRISE = "😮"
)

Emojis

Variables

View Source
var CachedMessages string

cache recent messages in case we need to reply

View Source
var InitConfig = Config{}

InitConfig : cache config data

Functions

func AES_GCM_Decrypt

func AES_GCM_Decrypt(password, ciphertext []byte) ([]byte, error)

AES_GCM_Decrypt decrypts ciphertext with password using AES-GCM

func AES_GCM_Encrypt

func AES_GCM_Encrypt(password, plaintext []byte) ([]byte, error)

AES_GCM_Encrypt encrypts plaintext with password using AES-GCM

func ChoiceMaker

func ChoiceMaker(choices []string) string

ChoiceMaker : Select a random item from a slice

func DecisionMaker

func DecisionMaker() bool

DecisionMaker : decide if a a reply is needed, randomly

func DeriveKey

func DeriveKey(password, salt []byte) []byte

func DownloadFile

func DownloadFile(filepath string, url string) error

DownloadFile : Download a url to a local file. It's efficient because it will write as it downloads and not load the whole file into memory.

func FileToLines

func FileToLines(filePath string) ([]string, error)

FileToLines : Read lines from a text file

func GenerateRandomBytes

func GenerateRandomBytes(size int) ([]byte, error)

func Notifier

func Notifier(reminder Reminder) string

Notifier : wait until it's time to send our reminder

func NowWeather

func NowWeather(city string) string

NowWeather : Current weather info from his/her city

func ProcessCmd

func ProcessCmd(command string, commandArgs string, userID int64) string

ProcessCmd : handles bot commands

func ProcessMsg

func ProcessMsg(message string, userID int64) string

ProcessMsg : handles chat messages

func Search(query string, image bool) string

Search : CSE search, for external use

func StartBot

func StartBot()

StartBot : Connect to Telegram bot API and start working

func ToEnglish

func ToEnglish(text string) string

ToEnglish : translate any language to English

func UpdateConfig

func UpdateConfig(pattern string, withStr string) error

Updated UpdateConfig : Update a key in config.json without overwriting existing values

func WriteStringToFile

func WriteStringToFile(path string, text string, overwrite bool) error

WriteStringToFile : write or append line to file

Types

type CoinPrice

type CoinPrice struct {
	CoinName   string
	PriceInBTC string
	PriceInUSD string
}

CoinPrice : Price info of a coin

func GetPrice

func GetPrice(coin string) CoinPrice

GetPrice : Read coin prices from public API

type Config

type Config struct {
	GFID            int64  `json:"GFID"`
	BFID            int64  `json:"BFID"`
	OllamaModelName string `json:"OllamaModelName"`
	Token           string `json:"Token"`
	GFName          string `json:"Girlfriend"`
	BFName          string `json:"Boyfriend"`
	CSE             string `json:"CSE"`
	HerCity         string `json:"HerCity"`
	HisCity         string `json:"HisCity"`
	MemDay          string `json:"MemDay"`
	MemdayGreetings string `json:"MemdayGreetings"`
	Birthday        string `json:"Birthday"`
	HuobiAccessKey  string `json:"HuobiAccessKey"`
	HuobiSecretKey  string `json:"HuobiSecretKey"`
}

Config : Bot configuration

func ReadConfig

func ReadConfig() Config

Modified ReadConfig: loads configuration from config.json file

type Reminder

type Reminder struct {
	// contains filtered or unexported fields
}

Reminder type for reminders data

func NewReminder

func NewReminder(notifyTime time.Time, event string) Reminder

NewReminder : create new reminder with time and event

type Result

type Result struct {
	Position int64
	Result   *customsearch.Result
}

Result : CSE search result type

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址