webapps

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 8, 2022 License: MIT Imports: 9 Imported by: 0

README

Telegram WebApps

Tools for telegram web apps: https://core.telegram.org/bots/webapps

Quick start:

Install Package: go get github.com/Fuchsoria/telegram-webapps

Add Imports:

import (
	"fmt"
	"log"
	webapps "github.com/Fuchsoria/telegram-webapps"
)

Use!:

func  main() {
	token  :=  "BOT_TOKEN"
	data  :=  "WebAppInitData_from_TG"

	err, user  := webapps.VerifyWebAppData(data, token)
	if err !=  nil {
		log.Fatal(err)
	}

	fmt.Println(user)
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	HashIsNotValid = errors.New("hash is not valid")
)

Functions

This section is empty.

Types

type WebAppUser

type WebAppUser struct {
	ID           int    `json:"id"`
	IsBot        bool   `json:"is_bot"`
	FirstName    string `json:"first_name"`
	LastName     string `json:"last_name"`
	Username     string `json:"username"`
	LanguageCode string `json:"language_code"`
	PhotoUrl     string `json:"photo_url"`
}

func VerifyWebAppData

func VerifyWebAppData(telegramInitData string, token string) (error, WebAppUser)

Jump to

Keyboard shortcuts

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