Giter Site home page Giter Site logo

gotgproto's People

Contributors

annihilatorrrr avatar celestix avatar coiaprant233 avatar deepsource-autofix[bot] avatar deepsourcebot avatar dependabot[bot] avatar dev-freelance-ru avatar dukeann avatar emanxu avatar everythingsuckz avatar inascf avatar jimpo26 avatar konekod avatar nksama avatar teadove avatar thehellruler avatar

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  avatar  avatar

gotgproto's Issues

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!

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?

QUESTION: Session problems

Screenshot 2024-04-27 at 19 46 17

Even when i pass in a string of a session it still tries to send a code and get a code from me. Additionally it creates the session storage files. you see i need to store the session in the mongodb and how do i properly extract it so that when i create a new client next time the server restarts it wont ask me the code that comes to telegram.

P.S i extract the session with client.ExportStringSession() maybe there is a better way

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

`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)

auth-using-api-base example doesn't work

Allways stuck at Rec [phone|code|...]. Works fine with make of channels:

func GetWebAuth() *webAuth {
	return &webAuth{
		phoneChan:  make(chan string),
		codeChan:   make(chan string),
		passwdChan: make(chan string),
	}
}

go run main.go Stuck unable to execute

When I run:go run main.go

GoTGProto v1.0.0-beta17, Copyright (C) 2024 Anony <github.com/celestix>
Licensed under the terms of GNU General Public License v3

The terminal keeps showing this, why is this problem stuck?

Is it related to the certificate?


Another issue is that when running on a brand new computer, it runs very slowly for the first time. Is it a problem downloading certificates? Where is the certificate stored? Can I directly call the local certificate

Add Download methods

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

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

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.

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=

Client creation with session

Screenshot 2024-04-29 at 17 03 54

if i create a client with a ready session it still tries to authenticate the user. is there a way to cancel auth, if the session is passed?

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.

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{})
}

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

Internal library error

Trying to run a program using this library I get an error (picture below). Is it an error on my side (that is GOCACHE or pkg/mod pkg/sumdb related stuff) or an error on your side?
Screenshot from 2024-05-05 22-38-02

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..

Possible to login as user without 2FA prompt?

Hi there

I'm wondering if its possible to init the client as user without the need to provide the 2FA code? My Telegram account does not have 2FA enabled.

tgClient, err := gotgproto.NewClient(
			cfg.AppId,
			cfg.AppHash,
			gotgproto.ClientTypePhone("REDACTED"),
			&gotgproto.ClientOpts{
				Session: sessionMaker.SqlSession(sqlite.Open("echobot")),
			},
		)

I'm aware of other libs, tdl in JS for example that do not require the 2FA code, just appId and appHash.

Thanks!

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

When creating a new client it starts asking the authentication by itself

Screenshot 2024-04-27 at 18 29 40

I have a problem, when i create a new client it starts handling the authentication itself asking me the code in the terminal, and though it is good, it does it in the terminal is what is bad.

Screenshot 2024-04-27 at 18 29 12

You see in my platform people will be sending the data through rest and then i have to pass it in manually through the functions it canе the handled through terminal. Is there a way to either cancel the option of terminal auth, or switching it to a different approach. Cuz because it tries to manually handle the authentication i cannot use regular client.Auth().SignIn() with it. Thanks in advance

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()
}

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.

peer not found on ctx.GetMessages

I have the following problem. I would like to fetch the whole chat history of a chat (
m, err := ctx.GetMessages(chatId, []tg.InputMessageClass{ &tg.InputMessageID{ID: offsetId}, }))
and then switch to live listen mode with (
clientDispatcher := client.Dispatcher clientDispatcher.AddHandlerToGroup(handlers.NewMessage(filters.Message.Chat(chatId), printMessage), 1)
).

Unfortunately I always get the error peers not found. But if I use this line

clientDispatcher.AddHandlerToGroup(handlers.NewMessage(filters.Message.Chat(chatId), printMessage), 1)
alone and then run my programm again with the fetch history, the peer is found because handlers.NewMessage adds the correct peer to the cache. Is there a possibility how I can execute the peers function which is called in handlers.NewMessage before I execute both operations?

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.