Comments (8)
Blimey! You know what?
It is.
Just.
Perfect.
I don't even care anymore because I'm in the process of making Telebot God Emperor Bot Thing so hey boys and girls chill out
from telebot.
/cc @irgendwr
from telebot.
I really like the Idea of using reflection as a way of simplifying the send methods!
But wouldn't your proposed message builder mean that you have multiple ways of doing the same thing (ie. sending a message)? Might be confusing, idk.
The error handler would also be very useful to reduce repetitive error checking.
start/listen/serve is confusing
- I think
Serve
is kind of useless because when I define a handler I expect it to be called by default. - Listen is weird as it's not really needed (see second example in readme; I also don't use listen) and is now also kind of getting replaced by Handlers.
You could add Handlers for Message and Query events to fully replace Listen and the channel-thing. - Couldn't
Start
also be merged withNewBot
? Or is there a reason to have to explicitly define when the bot should start? Race-conditions should be unlikely presuming handlers are registered right after creation.
As you can guess I like the "There should be one-- and preferably only one --obvious way to do it." mentality 😄
from telebot.
I haven't used callbacks yet but they could probably be handlers too, registered per user/state or per message for example.
from telebot.
I think
Serve
is kind of useless because when I define a handler I expect it to be called by default.
I couldn't introduce it any other way without breaking backwards compat. 😞
Listen is weird as it's not really needed
Fair enough! I kept it for backwards compat too, even though we can now let it go in v2
.
Couldn't
Start
also be merged withNewBot
?
Good question. I don't think so. All the receiving channels must be initialized when long polling starts, so we probably should stick to the 3-phase init process: NewBot
, channels & handlers, and Start
.
I haven't used callbacks yet but they could probably be handlers too, registered per user or per message for example.
I use callbacks for better UI mostly: inline keyboard buttons cause message updates. What's the benefit of "registering" callbacks as handlers and wiring them to messages, especially considering that associated messages are returned as a part of a callback struct?
from telebot.
Any progress? It seems there hasn't been much activity after August 25...
from telebot.
@matteocontrini No progress at all, I'm still pretty much waiting for feedback.
from telebot.
FYI, I just added Send()
, Reply()
and Forward()
the three "generic" methods. All of them accept 2+ arguments (recipient, payload and "options"). Since both payload and options are of type interface{}
, it lets you pass either string
or Sendable
as payload and pretty much anything for options.
But what exactly is an "option"? Nice thing about this API is that by "options" it doesn't necessarily mean *SendOptions
. Both *SendOptions
, *ReplyMarkup
and one of the const Option
s (which I'm still working on, but basically these are just fancy shortcuts) will work, following arguments overriding preceding ones. Look:
b.Send(user, "Message")
b.Send(user, photo, tb.ForceReply)
b.Send(user, photo, tb.NoPreview, tb.ForceReply)
// instead of
b.Send(user, photo, &tb.SendOptions{
DisableWebPagePreview: true,
ReplyMarkup: &ReplyMarkup{ForceReply: true},
})
// You can override some properties of stored options also:
savedOptions := &tb.SendOptions{}
b.Send(user, "text", savedOptions, tb.NoPreview) // overrides DisableWebPagePreview from `savedOptions`
Let me know if there's anything that doesn't feel right.
from telebot.
Related Issues (20)
- help wanted
- message: implement UnmarshalJSON for InaccessibleMessage
- UserJoined Event can't be catched with hidden members group HOT 2
- 400 Bad request "USER_IS_BLOCKED" HOT 1
- Why does this code not display the pop-up window? HOT 1
- Get username by user id HOT 1
- Please update business bot
- query user not work use ReplyRecipient
- many old version reply HOT 1
- Here is some update for processing message reaction events
- How to forward a message to a specific topic in other groups. please help me HOT 4
- How can I detect if getUpdate failed? HOT 1
- The handler does not respond to OnChatMember for large groups. HOT 1
- bot: implement Trigger to trigger registered handler
- when i use img html tag, telegram: Bad Request: can't parse entities: Unsupported start tag "img" at byte offset 1 (400) HOT 2
- What is diffent and how send message by id?
- OnChatMember not catched
- selector inline mode handle not listener callback button pressed
- Cant catch forwarded messages
- ChatByUsername telegram: chat not found (400) HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from telebot.