Documentation ¶
Overview ¶
package to wrap telegram bot api
Index ¶
- func AmzDealSent(user *models.UserData, deal *models.CamCamCamDeal) bool
- func OzbDealSent(user *models.UserData, deal *models.OzBargainDeal) bool
- type KramerBot
- func (k *KramerBot) BotProc(updates tgbotapi.UpdatesChannel)
- func (k *KramerBot) CreateUserData(chatID int64, username string, keyword string, ozbGood bool, ozbSuper bool, ...) *models.UserData
- func (k *KramerBot) GetAdminPass() string
- func (k *KramerBot) GetToken() string
- func (k *KramerBot) Help(chat *tgbotapi.Chat)
- func (k *KramerBot) LoadUserStore()
- func (k *KramerBot) MakeAnnouncement(chat *tgbotapi.Chat, announcement string)
- func (k *KramerBot) MigrateSqliteToMongo(mongoURI string, mongoDBName string, mongoCollectionName string)
- func (k *KramerBot) NewBot(ozbs *scrapers.OzBargainScraper, cccs *scrapers.CamCamCamScraper)
- func (k *KramerBot) SaveUserStore()
- func (k *KramerBot) SendAmzDeal(user *models.UserData, deal *models.CamCamCamDeal)
- func (k *KramerBot) SendAmzWatchedDeal(user *models.UserData, deal *models.CamCamCamDeal)
- func (k *KramerBot) SendHTMLMessage(chatID int64, text string)
- func (k *KramerBot) SendMarkdownMessage(chatID int64, text string)
- func (k *KramerBot) SendMessage(chatID int64, text string)
- func (k *KramerBot) SendOzbGoodDeal(user *models.UserData, deal *models.OzBargainDeal)
- func (k *KramerBot) SendOzbSuperDeal(user *models.UserData, deal *models.OzBargainDeal)
- func (k *KramerBot) SendOzbWatchedDeal(user *models.UserData, deal *models.OzBargainDeal)
- func (k *KramerBot) SendPhoto(chatID int64, fileName string)
- func (k *KramerBot) SendTestMessage(chat *tgbotapi.Chat)
- func (k *KramerBot) SendVideo(chatID int64, fileName string)
- func (k *KramerBot) StartBot()
- func (k *KramerBot) StartProcessing()
- func (k *KramerBot) UpdateUser(userData *models.UserData)
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 ¶
function to read admin password from environment variable
func (*KramerBot) LoadUserStore ¶
func (k *KramerBot) LoadUserStore()
Function to load user store from file
func (*KramerBot) MakeAnnouncement ¶
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 ¶
func (k *KramerBot) NewBot(ozbs *scrapers.OzBargainScraper, cccs *scrapers.CamCamCamScraper)
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 ¶
send html message to chat
func (*KramerBot) SendMarkdownMessage ¶
send markdown message to chat
func (*KramerBot) SendMessage ¶
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) SendTestMessage ¶
Send test message
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 ¶
Update single user record in user store