bot

package
v0.0.0-...-2abc9a5 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

package to wrap telegram bot api

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AmzDealSent

func AmzDealSent(user *models.UserData, deal *models.CamCamCamDeal) bool

Check if the AMZ deal has already been sent to the user

func OzbDealSent

func OzbDealSent(user *models.UserData, deal *models.OzBargainDeal) bool

Check if the OZB deal has already been sent to the user

Types

type KramerBot

type KramerBot struct {
	Token      string
	Logger     *zap.Logger
	BotApi     *tgbotapi.BotAPI
	OzbScraper *scrapers.OzBargainScraper
	CCCScraper *scrapers.CamCamCamScraper
	UserStore  *models.UserStore
	DataWriter persist.DatabaseIF
	Pipup      *pipup.Pipup
	Config     *viper.Viper
	ApiServer  *api.GinServer
}

func (*KramerBot) BotProc

func (k *KramerBot) BotProc(updates tgbotapi.UpdatesChannel)

func (*KramerBot) CreateUserData

func (k *KramerBot) CreateUserData(chatID int64, username string, keyword string,
	ozbGood bool, ozbSuper bool, amzDaily bool, amzWeekly bool) *models.UserData

Create user data from parameters passed in

func (*KramerBot) GetAdminPass

func (k *KramerBot) GetAdminPass() string

function to read admin password from environment variable

func (*KramerBot) GetToken

func (k *KramerBot) GetToken() string

function to read token from environment variable

func (*KramerBot) Help

func (k *KramerBot) Help(chat *tgbotapi.Chat)

Function to display help message

func (*KramerBot) LoadUserStore

func (k *KramerBot) LoadUserStore()

Function to load user store from file

func (*KramerBot) MakeAnnouncement

func (k *KramerBot) MakeAnnouncement(chat *tgbotapi.Chat, announcement string)

Make an announcement to all users i.e. important messages, updates etc. Note: This is an admin function and will need KRAMERBOT_ADMIN_PASSWORD

func (*KramerBot) MigrateSqliteToMongo

func (k *KramerBot) MigrateSqliteToMongo(mongoURI string, mongoDBName string, mongoCollectionName string)

migration function to migrate from sqlite to mongo

func (*KramerBot) NewBot

function to create a new bot

func (*KramerBot) SaveUserStore

func (k *KramerBot) SaveUserStore()

Function to save user store to file

func (*KramerBot) SendAmzDeal

func (k *KramerBot) SendAmzDeal(user *models.UserData, deal *models.CamCamCamDeal)

func (*KramerBot) SendAmzWatchedDeal

func (k *KramerBot) SendAmzWatchedDeal(user *models.UserData, deal *models.CamCamCamDeal)

Send AMZ watched deal to user

func (*KramerBot) SendHTMLMessage

func (k *KramerBot) SendHTMLMessage(chatID int64, text string)

send html message to chat

func (*KramerBot) SendMarkdownMessage

func (k *KramerBot) SendMarkdownMessage(chatID int64, text string)

send markdown message to chat

func (*KramerBot) SendMessage

func (k *KramerBot) SendMessage(chatID int64, text string)

send message to chat

func (*KramerBot) SendOzbGoodDeal

func (k *KramerBot) SendOzbGoodDeal(user *models.UserData, deal *models.OzBargainDeal)

Send OZB good deal message to user

func (*KramerBot) SendOzbSuperDeal

func (k *KramerBot) SendOzbSuperDeal(user *models.UserData, deal *models.OzBargainDeal)

Send OZB super deal to user

func (*KramerBot) SendOzbWatchedDeal

func (k *KramerBot) SendOzbWatchedDeal(user *models.UserData, deal *models.OzBargainDeal)

Send OZB watched deal to user

func (*KramerBot) SendPhoto

func (k *KramerBot) SendPhoto(chatID int64, fileName string)

Send a photo to the user

func (*KramerBot) SendTestMessage

func (k *KramerBot) SendTestMessage(chat *tgbotapi.Chat)

Send test message

func (*KramerBot) SendVideo

func (k *KramerBot) SendVideo(chatID int64, fileName string)

Send a video to the user

func (*KramerBot) StartBot

func (k *KramerBot) StartBot()

start receiving updates from telegram

func (*KramerBot) StartProcessing

func (k *KramerBot) StartProcessing()

Process deals returned by the scraper, check deal type and notify user if they are subscribed to a particular deal type

func (*KramerBot) UpdateUser

func (k *KramerBot) UpdateUser(userData *models.UserData)

Update single user record in user store

Jump to

Keyboard shortcuts

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