pkBot

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 31, 2021 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// This client secret is a ciphertext generated by using the AES key and then calling
	// aes.encrypt(CLIENT_USERNAME, AES_KEY) for CBC mode
	// and getting the string form of the result. See setWithDynamicKey method in
	// https://selfregistration.cowin.gov.in/main-es2015.a738dfab7b730e7c14ac.js:formatted
	CLIENT_SECRET = "U2FsdGVkX1+OsCQvQsCompcYGsHbguKSzKrIAh4xUB/us+Z7ZTqUiCsbkR+fKtfft6wsmYmTYyGlzVqi3L/x/g=="
	// See constructor of one of the classes in
	// https://selfregistration.cowin.gov.in/main-es2015.a738dfab7b730e7c14ac.js:formatted
	AES_KEY = "CoWIN@$#&*(!@%^&"
	// See anonymouslogin method in
	// https://selfregistration.cowin.gov.in/main-es2015.a738dfab7b730e7c14ac.js:formatted
	// If it's different for your browser client code, you may just put the breakpoints
	// for the methods listed above and get the client secret yourself or use any AES lib
	// to calculate your secret using the key given above and the username plaintext
	CLIENT_USERNAME = "b5cab167-7977-4df1-8027-a63aa144f04e"
)

Variables

This section is empty.

Functions

func BeginPollingForClients

func BeginPollingForClients(interval int) error

func CheckSlots

func CheckSlots(remoteClient *RemoteClient) error

func Clients

func Clients() map[string]*RemoteClient

func Initialize

func Initialize() *map[string]interface{}

func PollServer

func PollServer(remoteClient *RemoteClient) error

func Respond

func Respond(remoteClient *RemoteClient)

func SendResponse

func SendResponse(remoteClient *RemoteClient, userInput string)

func SetWACClient

func SetWACClient(wac *pkWhatsApp.WhatsappClient)

Types

type AppointmentConfirmation

type AppointmentConfirmation struct {
	ConfirmationId string `json:"appointment_confirmation_no"`
}

type AppointmentList

type AppointmentList struct {
	DoseAppointments []struct {
	} `json:"appointments"`
}

type Appointments

type Appointments struct {
	Centers []struct {
		CenterID      int     `json:"center_id"`
		Name          string  `json:"name"`
		NameL         string  `json:"name_l"`
		StateName     string  `json:"state_name"`
		StateNameL    string  `json:"state_name_l"`
		DistrictName  string  `json:"district_name"`
		DistrictNameL string  `json:"district_name_l"`
		BlockName     string  `json:"block_name"`
		BlockNameL    string  `json:"block_name_l"`
		Pincode       int     `json:"pincode"`
		Address       string  `json:"address"`
		Lat           float64 `json:"lat"`
		Long          float64 `json:"long"`
		From          string  `json:"from"`
		To            string  `json:"to"`
		FeeType       string  `json:"fee_type"`
		VaccineFees   []struct {
			Vaccine string `json:"vaccine"`
			Fee     string `json:"fee"`
		} `json:"vaccine_fees"`
		Sessions []struct {
			CenterID          int
			SessionID         string   `json:"session_id"`
			Date              string   `json:"date"`
			AvailableCapacity float64  `json:"available_capacity"`
			MinAgeLimit       int      `json:"min_age_limit"`
			Vaccine           string   `json:"vaccine"`
			Dose1Capacity     float64  `json:"available_capacity_dose1"`
			Dose2Capacity     float64  `json:"available_capacity_dose2"`
			Slots             []string `json:"slots"`
		} `json:"sessions"`
	} `json:"centers"`
}

type ApptRequestError

type ApptRequestError struct {
	Error     string `json:"error"`
	ErrorCode string `json:"errorCode"`
}

type BeneficiaryList

type BeneficiaryList struct {
	Beneficiaries []struct {
		ReferenceID     string `json:"beneficiary_reference_id"`
		Name            string `json:"name"`
		Birth           string `json:"birth_year"`
		Gender          string `json:"gender"`
		Mobile          string `json:"mobile_number"`
		PhotoIdType     string `json:"photo_id_type"`
		PhotoIdNumber   string `json:"photo_id_number"`
		ComorbidityInd  string `json:"comorbidity_ind"`
		VaccinationStat string `json:"vaccination_status"`
		Vaccine         string `json:"vaccine"`
		Dose1Date       string `json:"dose1_date"`
		Dose2Date       string `json:"dose2_date"`
		Appointments    []struct {
			AppointmentID string `json:"appointment_id"`
			CenterID      int    `json:"center_id"`
			Name          string `json:"name"`
			StateName     string `json:"state_name"`
			DistrictName  string `json:"district_name"`
			BlockName     string `json:"block_name"`
			From          string `json:"from"`
			To            string `json:"to"`
			Dose          int    `json:"dose"`
			SessionID     string `json:"session_id"`
			Date          string `json:"date"`
			Slot          string `json:"slot"`
		} `json:"appointments"`
	} `json:"beneficiaries"`
	Description   string
	EligibleCount int
}

type BookingSlot

type BookingSlot struct {
	Available           bool
	Preferred           bool
	CenterID            int
	BookAnySlot         bool
	CenterName          string
	SessionID           string
	Slot                string
	Description         string
	PotentialSessions   []PotentialSession
	EligibleCount       int
	TotalDose1Available int
}
func Search(remoteClient *RemoteClient) (*BookingSlot, error)

type CaptchaSVG

type CaptchaSVG struct {
	Captcha string `json:"captcha"`
}

type Command

type Command struct {
	Name             string `json:"name"`
	CommandType      string `json:"commandType"`
	ToBeSent         string `json:"toBeSent"`
	ResponseType     string `json:"responseType"`
	ExpectedResponse string `json:"expectedResponse"`
	NextCommand      string `json:"nextCommand"`
	ErrorResponse1   string `json:"errorResponse1"`
	ErrorResponse2   string `json:"errorResponse2"`
	NextYCommand     string `json:"nextYCommand"`
	NextNCommand     string `json:"nextNCommand"`
}

type DistrictList

type DistrictList struct {
	Districts []struct {
		StateID       int    `json:"state_id"`
		DistrictID    int    `json:"district_id"`
		DistrictName  string `json:"district_name"`
		DistrictNameL string `json:"district_name_l"`
	} `json:"districts"`
	TTL int `json:"ttl"`
}

type OTPConfirmTxn

type OTPConfirmTxn struct {
	TOKEN string `json:"token"`
}

type OTPTxn

type OTPTxn struct {
	TXNId       string `json:"txnId"`
	BearerToken string
}

type PotentialSession

type PotentialSession struct {
	CenterID          int
	CenterName        string
	CenterAddress     string
	SessionID         string
	Date              string
	AvailableCapacity float64
	MinAgeLimit       int
	Vaccine           string
	Dose1Capacity     float64
	Dose2Capacity     float64
	Slots             []string
}

type RemoteClient

type RemoteClient struct {
	RemoteJID          string
	RemoteMobileNumber string
	LastReceived       pkWhatsApp.Message
	LastSent           *Command
	Received           pkWhatsApp.Message
	Host               *pkWhatsApp.WhatsappClient
	Params             *UserParams
	PollingInterval    int
	PollWaitCounter    int
}

Remote WhatsappClient who's trying to communicate

func NewClient

NewClient create whatsapp client

func NewRemoteClient

func NewRemoteClient(msg pkWhatsApp.Message, from, mobile string, wac *pkWhatsApp.WhatsappClient) *RemoteClient

type StateList

type StateList struct {
	States []struct {
		StateID    int    `json:"state_id"`
		StateName  string `json:"state_name"`
		StateNameL string `json:"state_name_l"`
	} `json:"states"`
	TTL int `json:"ttl"`
}

type Subscriber

type Subscriber struct {
	RemoteJID    string
	MobileNumber string
	Date         string
}

type Subscriptions

type Subscriptions struct {
	Subscribers    []Subscriber
	NonSubscribers []Subscriber
}

type UserParams

type UserParams struct {
	State          string
	District       string
	StateID        int
	DistrictID     int
	Age            int
	OTP            int
	OTPTxnDetails  *OTPTxn
	Beneficiaries  *BeneficiaryList
	BookingPrefs   *BookingSlot
	CAPTCHA        string
	ConfirmationID string
}

Jump to

Keyboard shortcuts

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