database

package
v0.0.0-...-89853f3 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: MIT Imports: 5 Imported by: 0

README

golang-http-spam

This Go package manages a SQLite database for a spam bot application.

Configuration

Before using the utility, configure the database settings to suit your environment:

  1. Update the AdminUserID variable with the desired admin user ID.
  2. Review the InitDB function to ensure the database connection settings match your environment.
func InitDB() {
    // Update the database connection string as needed
    var err error
    db, err = gorm.Open(sqlite.Open("spam_bot.db"), &gorm.Config{})
    if err != nil {
        panic("failed to connect database")
    }

    db.AutoMigrate(&User{}, &AttackHistory{})
}

Notes

  • Ensure that SQLite is installed and accessible in your environment.
  • Modify the database connection string in InitDB to point to the desired SQLite database file.
  • Customize the admin user ID in the AdminUserID variable.
  • Review and adapt the code according to your specific requirements and use case.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AdminUserID int64 = 696300339
View Source
var Db *gorm.DB

Functions

func AddAdmin

func AddAdmin(userID int64)

func DeleteAdmin

func DeleteAdmin(userID int64)

func DeleteAuthCode

func DeleteAuthCode(code string) bool

func InitDB

func InitDB()

func IsAdmin

func IsAdmin(userID int64) bool

func SaveAttackHistory

func SaveAttackHistory(userID *int64, command, attackURL string, success bool)

Types

type AttackHistory

type AttackHistory struct {
	gorm.Model
	UserID    *int64
	Command   string
	AttackURL string
	Success   bool
}

type AuthCode

type AuthCode struct {
	gorm.Model
	TelegramID int64
	Code       string
	IsUsed     bool
	CreatedAt  time.Time
}

func GetAuthCode

func GetAuthCode(code string) (*AuthCode, error)

type User

type User struct {
	gorm.Model
	UserID int64 `gorm:"uniqueIndex"`
}

Jump to

Keyboard shortcuts

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