Skip to content
Permalink
Browse files

Rename model for compatibility.

  • Loading branch information...
n1try
n1try committed Aug 22, 2017
1 parent c1a86bf commit 94b98d619787aa514f085d36b04005d4c8db6c78
Showing with 5 additions and 5 deletions.
  1. +3 −3 main.go
  2. +1 −1 model.go
  3. +1 −1 store.go
@@ -45,7 +45,7 @@ func sendMessage(recipientId, text string) error {

func invalidateUserToken(userChatId int) {
for k, v := range StoreGetMap() {
entry, ok := v.(StoreUserObject)
entry, ok := v.(StoreObject)
if ok && entry.ChatId == userChatId {
StoreDelete(k)
}
@@ -55,7 +55,7 @@ func invalidateUserToken(userChatId int) {
func resolveToken(token string) string {
value := StoreGet(token)
if value != nil {
return strconv.Itoa((value.(StoreUserObject)).ChatId)
return strconv.Itoa((value.(StoreObject)).ChatId)
}
return ""
}
@@ -161,7 +161,7 @@ func processUpdate(update TelegramUpdate) {
if strings.HasPrefix(update.Message.Text, "/start") {
id := uuid.NewV4().String()
invalidateUserToken(chatId)
StorePut(id, StoreUserObject{User: update.Message.From, ChatId: chatId})
StorePut(id, StoreObject{User: update.Message.From, ChatId: chatId})
text = "Here is your token you can use to send messages to your Telegram account:\n\n_" + id + "_"
log.Println("Sending new token to", strconv.Itoa(chatId))
} else {
@@ -1,6 +1,6 @@
package main

type StoreUserObject struct {
type StoreObject struct {
User TelegramUser `json:"user"`
ChatId int `json:"chat_id"`
}
@@ -9,7 +9,7 @@ import (
var store map[string]interface{}

func InitStore() {
gob.Register(StoreUserObject{})
gob.Register(StoreObject{})
gob.Register(StoreMessageObject{})
}

0 comments on commit 94b98d6

Please sign in to comment.
You can’t perform that action at this time.