Giter Site home page Giter Site logo

gotgproto's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gotgproto's Issues

How to get chat invitation link to private chat

Hi everyone! So I need to get invitation links of created chats, but I can't figure out how to do so. This is my code:

ppackage client

import (
	"log"
	"tclient/internal/config"

	"github.com/anonyindian/gotgproto"
	"github.com/anonyindian/gotgproto/sessionMaker"
)

func Create(c *config.AppConfig) (*gotgproto.Client, error) {
	clientType := gotgproto.ClientType{
		Phone: c.Phone,
	}
	client, err := gotgproto.NewClient(
		c.AppId,
		c.ApiHash,
		clientType,
		&gotgproto.ClientOpts{
			Session: sessionMaker.NewSession("tclient", sessionMaker.Session),
		},
	)
	if err != nil {
		log.Fatalln("failed to start client:", err)
	}

        chat, err := client.CreateContext().CreateChat("test", []int64{})
	if err != nil {
		panic(err)
	}

	res := map[string]string{
		"chatID": chat.GetID(),
		"title":  chat.GetTitle(),
                 "joinLink":  ????
	}
}

Please help me! Thanks!

Add mention helpers in parsemodes

Add helpers in entityhelpers and stylinghelpers from the parsemode package to mention users with their usernames or user ids using telegram's deeplinks.
To Mention With User ID: tg://user?id=
To Mention With User ID: tg://resolve?domain=

Can the session expiration time be set?

After verifying the authorization, I found that I need to revalidate the code verification permissions the next day

Can the expiration time be set in the files saved during the session? For example, the number of valid days: 30 days or 365 days, permanently valid, etc

`fatal error: stack overflow` on ext.Context context.WithValue

I'm trying to add contextual logging using zerolog and context.Context.
I'm adding handler to dispatcher:

dispatcher.AddHandler(
		handlers.Message{
			Callback:      injectContext,
			Filters:       nil,
			UpdateFilters: nil,
			Outgoing:      true,
		},
	)

injectContext:

func injectContext(ctx *ext.Context, update *ext.Update) error {
	ctx.Context = log.
		With().
		Int("update_effective_message_id", update.EffectiveMessage.ID).
		Logger().
		WithContext(ctx)
        _, _ = ctx.Reply(update, update.EffectiveMessage.Message.Message, nil) // for debug purposes 
	return nil
}

If you are not familiar with zerolog, this code just creates new logger with injected field and uses context.WithValue to store it in ctx.
But this function always panics with large traceback:

runtime: goroutine stack exceeds 1000000000-byte limit
runtime: sp=0xc020740398 stack=[0xc020740000, 0xc040740000]
fatal error: stack overflow

runtime stack:
runtime.throw({0x1010f0601?, 0x101cdf180?})
        /usr/local/go/src/runtime/panic.go:1047 +0x5d fp=0x31e4f4d88 sp=0x31e4f4d58 pc=0x10003853d
runtime.newstack()
        /usr/local/go/src/runtime/stack.go:1105 +0x5bd fp=0x31e4f4f38 sp=0x31e4f4d88 pc=0x1000526bd
runtime.morestack()
        /usr/local/go/src/runtime/asm_amd64.s:574 +0x8b fp=0x31e4f4f40 sp=0x31e4f4f38 pc=0x100069eab

goroutine 41 [running]:
github.com/anonyindian/gotgproto/ext.(*Context).Done(0xc000694400?)
        <autogenerated>:1 +0x3f fp=0xc0207403a8 sp=0xc0207403a0 pc=0x100b3895f
context.(*valueCtx).Done(0x0?)
        <autogenerated>:1 +0x2a fp=0xc0207403c0 sp=0xc0207403a8 pc=0x1000b590a
github.com/anonyindian/gotgproto/ext.(*Context).Done(0x0?)
        <autogenerated>:1 +0x2b fp=0xc0207403d8 sp=0xc0207403c0 pc=0x100b3894b
context.(*valueCtx).Done(0x0?)
        <autogenerated>:1 +0x2a fp=0xc0207403f0 sp=0xc0207403d8 pc=0x1000b590a
github.com/anonyindian/gotgproto/ext.(*Context).Done(0x0?)
        <autogenerated>:1 +0x2b fp=0xc020740408 sp=0xc0207403f0 pc=0x100b3894b
context.(*valueCtx).Done(0x0?)
...

Am I doing something wrong? Are there any ways to use WithValue with ext.Context?

Used dependencies:

	github.com/anonyindian/gotgproto v1.0.0-beta11
	github.com/gotd/td v0.82.0
	github.com/rs/zerolog v1.30.0

(I've deleted unrelated)

Add a bounded text interface parameter for ctx.Reply

As discussed in #19, text is a raw unbounded interface currently which can cause problems in many ways. To avoid it, we should add a bounded interface with at least one private method to prevent people breaking the library from external manipulation.

type InputText interface{
    isAPrivateMethodYetToBeNamed()
}

How I Create Multi Instance

I want to create many clients, and they are in one program, for example I want to create /login then I want to create one more client, and allow for multiple clients.

Your phone number has been banned

Hi everyone, I tried your app on a newly created telegram account and immediately after authorization I got a ban from telegram. I'm not sure if it's a bug, but somehow telegram knows how to distinguish between real login and login through this library.

channels.getAdminedPublicChannels analogy

Dear team,
First of all i wanted to thank you for such great library, awesome job!

I have an question: i need to fetch all channels, even if its private, where i am an admin. For public channels, i m using channels.getAdminedPublicChannels and it works fine.
for example, web telegram is able to show me all channels, even if it is private and i am an admin there. Any idea how it could be done with hekp of MTProto?

thanks

cannot use request.Reaction (variable of type []tg.ReactionClass) as type string in assignment

I have an error trying to run go script in Ubuntu and Amazon Linux2, in mac OS works rightly but in these SO i tested i have this error:

# github.com/anonyindian/gotgproto/ext
../go/pkg/mod/github.com/anonyindian/[email protected]/ext/context.go:174:14: cannot use request.Reaction (variable of type []tg.ReactionClass) as type string in assignment

For reproduce i only do ->
go run tg_bot.go

Few month ago was working , but not atm..

Add Download methods

Add Download* methods to download various available media, use td/telegram/downloader for the purpose.

Error code 400: CHANNEL_INVALID

i use this to get participants in group but report error 400: CHANNEL_INVALID

_, ok := client.API().ChannelsGetParticipants(context.Background(), &tg.ChannelsGetParticipantsRequest{Channel: &tg.InputChannel{ChannelID: -1001933086941}, Filter: &tg.ChannelParticipantsRecent{}})
fmt.Println("Ok: ", ok)

Please help me to fix!

Can't create new NewClient.

I tried to run this example, but no 2FA code is being sent to me at all. I tried on different systems.

System Info
OS: Linux artixlinux 6.8.2-artix1-1
Golang Version: go version go1.22.1 linux/amd64
gotgproto Version: v1.0.0-beta17

go.mod
gbin.me/5a7

main.go file
gbin.me/5a6

Login without phone number

How to log in without entering a code from your mobile phone? And why then use the pyrogram / tdata session at all if phone verification is still required?

How to forward a message?

I don't know how to forward a message.

func echo(ctx *ext.Context, update *ext.Update) error {
	ctx.ForwardMessage(Chat,
		ToChatID,
		&tg.MessagesForwardMessagesRequest{})
}

Using html.String returns null message text and raises MESSAGE_EMPTY

Describe the bug
When using html.String with ctx.Reply, html text is not parsed, but message sends and TG return MESSAGE_EMPTY error:

_, err := ctx.Reply(
		update,
		[]styling.StyledTextOption{html.String(nil, "<code>Hi!</code>")},
		nil,
	)

returns err: send styled text: rpcDoRequest: rpc error code 400: MESSAGE_EMPTY

Almost the same code, using pure gotg works just fine.

To Reproduce
Steps to reproduce the behavior:

  1. create reply using ctx.Reply
  2. []styling.StyledTextOption{html.String(nil, htmlMessage)}, where htmlMessage - any text with html
  3. send reply

Expected behavior
Sends HTML parsed message

Environment
MAC OS, M1, github.com/anonyindian/gotgproto v1.0.0-beta10, User bots.

When I use: [StringSession ,TelethonSession ] Unable to start main.go

&gotgproto.ClientOpts{
Session: sessionMaker.StringSession("test").
// Sqlite session name (if you're not using memory session)
// i.e. InMemory in ClientOpts is set to false
// It will be saved as my_session.session as per this example.
Name("my_session"),

I want to set the session, but the following error occurs. Using SimpleSession() is normal

failed to start client: invalid character 'µ' looking for beginning of value

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.