celestix / gotgproto Goto Github PK
View Code? Open in Web Editor NEWA wrapper for Go Telegram Client, i.e. gotd/td.
License: GNU General Public License v3.0
A wrapper for Go Telegram Client, i.e. gotd/td.
License: GNU General Public License v3.0
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 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=
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
It has not been implemented yet but was left in codes by mistake.
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)
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 can i create session string using dc id and auth key pare?
Here the value should be false
since it is a chat in line 142. https://github.com/anonyindian/gotgproto/blob/191c68cf73cf1e0c4317b3e4d8c252907d6ea6cb/types/chat.go#L141-L143
Here the value should be true
since it is a chat in line 147. https://github.com/anonyindian/gotgproto/blob/191c68cf73cf1e0c4317b3e4d8c252907d6ea6cb/types/chat.go#L146-L148
Is really needed for Dispatcher
Restoring stored sessions doesn't work in linux while they work properly with windows.
Add Args()
method for ext.Update
and Plain()
method for entity-root
Tonight I will describe it in more detail.
I'm trying to log in, it looks like it's a session error.
(I accidentally closed the post)
ext.Context
uses random.Int63
in its generateRandomID
method which causes race conditions on parallel request sending.
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.
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.
because, in somewhere like cn, can't not connect to tg server directly.
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
How to get paticipaint in channel/group? please help me!
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 to download various available media, use td/telegram/downloader
for the purpose.
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!
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
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?
TdataSession Error reporting method does not exist
The example code has already expired
HI.
Have "Compilation finished with exit code 2"
just tried running the example echo-bot
# 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
I don't know how to forward a message.
func echo(ctx *ext.Context, update *ext.Update) error {
ctx.ForwardMessage(Chat,
ToChatID,
&tg.MessagesForwardMessagesRequest{})
}
If use memery session,Frequent reacquisition of sessions will be restricted by the server
But use Sqlite Session will Compilation failed when cross compiling
Because gorm default sql drivers is github.com/mattn/go-sqlite3,It is cgo package
So can replace it to https://github.com/glebarez/sqlite
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:
ctx.Reply
[]styling.StyledTextOption{html.String(nil, htmlMessage)}
, where htmlMessage
- any text with htmlExpected behavior
Sends HTML parsed message
Environment
MAC OS, M1, github.com/anonyindian/gotgproto v1.0.0-beta10, User bots.
&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
Code: https://pastebin.com/xMsVvqw4 < api and hash just examples.
\context.go:174:14: cannot use request.Reaction
How can i fix it ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.