Skip to content

Commit

Permalink
Updated generator
Browse files Browse the repository at this point in the history
  • Loading branch information
mymmrac committed Dec 31, 2023
1 parent bea7c49 commit 0009ea5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var typeStructsSetters = []string{
"KeyboardButton",
"InlineKeyboardButton",
"MenuButtonWebApp",
"KeyboardButtonRequestUser",
"KeyboardButtonRequestUsers",
"KeyboardButtonRequestChat",

"InlineQueryResultCachedAudio",
Expand Down
8 changes: 6 additions & 2 deletions internal/generator/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,13 @@ func writeTypes(file *os.File, types tgTypes, currentTypes string) {
data.WriteString(`package telego
import (
"context"
"errors"
"fmt"
"strconv"
"github.com/mymmrac/telego/internal/json"
ta "github.com/mymmrac/telego/telegoapi"
"github.com/mymmrac/telego/telegoapi"
)
`)

Expand Down Expand Up @@ -275,6 +276,9 @@ func fieldSpecialCases(field *tgTypeField, typeName string) {
if field.name == "UserId" && field.typ == "int" {
field.typ = "int64"
}
if field.name == "UserIds" && field.typ == "[]int" {
field.typ = "[]int64"
}

if field.name == "Media" && field.typ == "string" {
field.typ = "InputFile"
Expand All @@ -285,7 +289,7 @@ func fieldSpecialCases(field *tgTypeField, typeName string) {
}

if typeName == "ChatPermissions" ||
((typeName == "KeyboardButtonRequestUser" || typeName == "KeyboardButtonRequestChat") &&
((typeName == "KeyboardButtonRequestUsers" || typeName == "KeyboardButtonRequestChat") &&
field.typ == "bool" && field.optional) {
field.typ = "*bool"
}
Expand Down

0 comments on commit 0009ea5

Please sign in to comment.