Skip to content

Commit

Permalink
check, that user is registred
Browse files Browse the repository at this point in the history
  • Loading branch information
JackBekket committed Nov 19, 2022
1 parent 6c55c27 commit 4b2609e
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func main() {
pk := myenv["PK"] // load private key from env

msgTemplates["hello"] = "Hey, this bot is attaching personal wallets to telegram user & collective wallets to chat id"
msgTemplates["case0"] = "Go to link and attach your tg_id to your metamask wallet"
msgTemplates["case0"] = "Open following link in metamask broswer"
msgTemplates["await"] = "Awaiting for verification"
msgTemplates["case1"] = "You have successfully authorized your wallet to your account. Now you can use additional functions"
msgTemplates["who_is"] = "Input wallet address to know it's associated telegram nickname"
Expand Down Expand Up @@ -173,6 +173,12 @@ func main() {
msg := tgbotapi.NewMessage(userDatabase[update.Message.From.ID].tgid, msgTemplates["hello"])
msg.ReplyMarkup = mainKeyboard
bot.Send(msg)
// check for registration
registred := IsAlreadyRegistred(session,update.Message.From.ID)
if registred == true {
userDatabase[update.Message.From.ID] = user{update.Message.Chat.ID, update.Message.Chat.UserName, 1}
}

} else {

switch userDatabase[update.Message.From.ID].dialog_status {
Expand Down Expand Up @@ -472,6 +478,22 @@ func WhoIsAddress(session *passport.PassportSession,address_to_check common.Addr

}

func IsAlreadyRegistred(session *passport.PassportSession, user_id int64) (bool) {
//GetPassportWalletByID
passport_address, err := session.GetPassportWalletByID(user_id)
if err != nil {
return false
}
log.Println("check that user with this id:", user_id)
log.Println("have associated wallet address:",passport_address)
if passport_address == common.HexToAddress("0x0000000000000000000000000000000000000000") {
log.Println("passport is null, user is not registred")
return false
} else {
return true
}
}

// generate link to trust page
func TrustUserLink(tgid_string string, friend_tg_id string, friend_username string) (string) {
//http://localhost:3000/trust?user_tg_id=1337&friend_tg_id=1997&friend_user_name=sbekket
Expand Down

0 comments on commit 4b2609e

Please sign in to comment.