Skip to content

Commit

Permalink
Layer 148 -> 170, Version 2.3.5, Fixed TL Generator, Bug FIxes, Enhan…
Browse files Browse the repository at this point in the history
…cements
  • Loading branch information
AmarnathCJD committed Jan 4, 2024
1 parent 68b8675 commit dc0cb8b
Show file tree
Hide file tree
Showing 90 changed files with 10,011 additions and 8,120 deletions.
15 changes: 7 additions & 8 deletions README.rst
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
GσGram
========

Massive Updates and Bug Fixes on December 2023 :)


.. epigraph::

⚒️ Under Development.
Expand All @@ -17,6 +14,9 @@ Gogram is designed to be fast and efficient, and it has no external dependencies
*If you're looking to build a Telegram client or bot using the Go programming language, Gogram is definitely worth considering. Its open-source nature also means that you can contribute to its development and suggest new features or improvements.*


Layer - 170


What is this?
-------------

Expand All @@ -28,7 +28,7 @@ heavy job for you, so you can focus on developing an application.
Known Bugs
----------

getFullChannel fails due to flag2.0
Find em:)

PRs and Issues are always welcome.

Expand Down Expand Up @@ -59,8 +59,7 @@ Set-Up Client
AppID: 0,
AppHash: "",
})
client.Connect()
client.LoginBot(botToken) // client.Login(phoneNumber)
client.ConnectBot(botToken) // client.Login(phoneNumber)
client.Idle() // start infinite polling
Expand Down Expand Up @@ -142,8 +141,8 @@ TODO
- ✔️ Add Update Handle System
- ✔️ Make a reliable HTML Parser
- ✔️ Friendly Methods to Handle CallbackQuery, VoiceCalls
- 🔨 Add Flag2.0 Parser (Then update to Layer-151)
- 📝 Fix File handling
- ✔️ Add Flag2.0 Parser (Then update to Layer-170)
- ✔️ Fix File handling
- 📝 Write beautiful Docs
- 📝 Multiple tests

Expand Down
3 changes: 0 additions & 3 deletions TODO

This file was deleted.

2 changes: 1 addition & 1 deletion errors.go
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023 RoseLoverX
// Copyright (c) 2024 RoseLoverX

package gogram

Expand Down
2 changes: 1 addition & 1 deletion handshake.go
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023 RoseLoverX
// Copyright (c) 2024 RoseLoverX

package gogram

Expand Down
2 changes: 1 addition & 1 deletion internal/aes_ige/aes.go
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022,RoseLoverX
// Copyright (c) 2024 RoseLoverX

package ige

Expand Down
2 changes: 2 additions & 0 deletions internal/aes_ige/aes_common.go
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright (c) 2024 RoseLoverX

package ige

import (
Expand Down
2 changes: 1 addition & 1 deletion internal/aes_ige/errors.go
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023 RoseLoverX
// Copyright (c) 2024 RoseLoverX

package ige

Expand Down
2 changes: 1 addition & 1 deletion internal/aes_ige/ige_cipher.go
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022,RoseLoverX
// Copyright (c) 2024 RoseLoverX

package ige

Expand Down
47 changes: 0 additions & 47 deletions internal/cmd/tlgen/gen/testdata/basic/expected/enums_gen.go

This file was deleted.

11 changes: 0 additions & 11 deletions internal/cmd/tlgen/gen/testdata/basic/expected/init_gen.go

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions internal/cmd/tlgen/gen/testdata/basic/expected/methods_gen.go

This file was deleted.

14 changes: 0 additions & 14 deletions internal/cmd/tlgen/gen/testdata/basic/expected/types_gen.go

This file was deleted.

27 changes: 0 additions & 27 deletions internal/cmd/tlgen/gen/testdata/basic/schema.tl

This file was deleted.

9 changes: 6 additions & 3 deletions internal/cmd/tlgen/gen/tl_gen_methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ func (g *Generator) generateMethodFunction(obj *tlparser.Method) jen.Code {
// еще одно злоебучее исключение. проблема в том, что bool это вот как бы и объект, да вот как бы и нет
// трабла только в том, что нельзя просто так взять, и получить bool из MakeRequest. так что
// возвращаем tl.Bool
nuk := jen.Nil()
if obj.Response.Type == "Bool" {
resp = jen.Op("*").Qual(tlPackagePath, "bool")
resp = jen.Op("").Qual("", "bool")
nuk = jen.Bool()
}

responses := []jen.Code{resp, jen.Error()}
Expand All @@ -72,10 +74,11 @@ func (g *Generator) generateMethodFunction(obj *tlparser.Method) jen.Code {
//* }
//*
//* return resp, nil

method := jen.Func().Params(jen.Id("c").Op("*").Id("Client")).Id(goify(obj.Name, true)).Params(g.generateArgumentsForMethod(obj)...).Params(responses...).Block(
jen.List(jen.Id("responseData"), jen.Id("err")).Op(":=").Id("c").Dot("MakeRequest").Call(g.generateMethodArgumentForMakingRequest(obj)),
jen.If(jen.Err().Op("!=").Nil()).Block(
jen.Return(jen.Nil(), jen.Qual(errorsPackagePath, "Wrap").Call(jen.Err(), jen.Lit("sending "+goify(obj.Name, true)))),
jen.Return(nuk, jen.Qual(errorsPackagePath, "Wrap").Call(jen.Err(), jen.Lit("sending "+goify(obj.Name, true)))),
),
jen.Line(),
jen.List(jen.Id("resp"), jen.Id("ok")).Op(":=").Id("responseData").Assert(resp),
Expand Down Expand Up @@ -117,7 +120,7 @@ func (g *Generator) generateArgumentsForMethod(obj *tlparser.Method) []jen.Code
return items
}

func (*Generator) generateMethodArgumentForMakingRequest(obj *tlparser.Method) *jen.Statement {
func (g *Generator) generateMethodArgumentForMakingRequest(obj *tlparser.Method) *jen.Statement {
if len(obj.Parameters) > maximumPositionalArguments {
return jen.Id("params")
}
Expand Down
10 changes: 7 additions & 3 deletions internal/cmd/tlgen/gen/tl_gen_structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (g *Generator) generateStructTypeAndMethods(definition tlparser.Object, imp
flagBitIndex := -1 // -1 это если нет опциональных полей вообще
if containsOptionalParameters {
for i, param := range definition.Parameters {
if param.Name == "flags" && param.Type == "bitflags" {
if param.Name == "flags" && param.Type == "bitflags" || param.Name == "flags2" && param.Type == "bitflags" {
flagBitIndex = i
}
}
Expand Down Expand Up @@ -100,14 +100,18 @@ func (g *Generator) generateStructTypeAndMethods(definition tlparser.Object, imp

func (g *Generator) generateStructParameter(param *tlparser.Parameter) *jen.Statement {
goifiedName := goify(param.Name, true)
tag := "" // то что в `tl:"..."` находится
tag := ""
f := jen.Id(goifiedName)
if param.IsVector {
f = f.Index()
}

if param.IsOptional {
tag = fmt.Sprintf("flag:%v", param.BitToTrigger)
if param.Version == 1 {
tag = fmt.Sprintf("flag:%v", param.BitToTrigger)
} else if param.Version == 2 {
tag = fmt.Sprintf("flag2:%v", param.BitToTrigger)
}
}

if param.Type == "true" {
Expand Down
32 changes: 28 additions & 4 deletions internal/cmd/tlgen/gen/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"unicode"

"github.com/dave/jennifer/jen"
"github.com/iancoleman/strcase"
"github.com/xelaj/go-dry"

"github.com/amarnathcjd/gogram/internal/cmd/tlgen/tlparser"
)
Expand Down Expand Up @@ -41,12 +39,12 @@ func maxBitflag(params []tlparser.Parameter) int {
}

func goify(name string, public bool) string {
delim := strcase.ToDelimited(name, '|')
delim := ToDelimited(name, '|')
delim = strings.ReplaceAll(delim, ".", "|") // strace не видит точки!!
splitted := strings.Split(delim, "|")
for i, item := range splitted {
item = strings.ToLower(item)
if dry.SliceContains(capitalizePatterns, item) {
if SliceContains(capitalizePatterns, item) {
item = strings.ToUpper(item)
}

Expand Down Expand Up @@ -110,3 +108,29 @@ func (g *Generator) typeIdFromSchemaType(t string) *jen.Statement {

return item
}

func SliceContains(slice []string, item string) bool {
for _, i := range slice {
if i == item {
return true
}
}

return false
}

func ToDelimited(s string, delims ...rune) string {
if len(delims) == 0 {
delims = []rune{'_', '-'}
}

var result []rune
for _, r := range s {
if unicode.IsUpper(r) {
result = append(result, '_')
}
result = append(result, unicode.ToLower(r))
}

return string(result)
}
9 changes: 3 additions & 6 deletions internal/cmd/tlgen/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@ go 1.15

require (
github.com/dave/jennifer v1.4.1
github.com/iancoleman/strcase v0.1.2
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 // indirect
github.com/k0kubun/pp v3.0.1+incompatible
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.8.0
github.com/xelaj/go-dry v0.0.0-20210621215431-21c77821487c
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect
golang.org/x/sys v0.0.0-20220803195053-6e608f9ce704 // indirect
github.com/stretchr/testify v1.6.1
golang.org/x/sys v0.0.0-20201029080932-201ba4db2418 // indirect
)
Loading

0 comments on commit dc0cb8b

Please sign in to comment.