Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed API from bot-centered to method-centered #331

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

HarryZalessky
Copy link
Contributor

fixes #164

• Moved execute method from TelegramBot to BaseRequest
• Moved DeleteMyCommands.java from model to request
• Added BaseRequest.api member for execute method
• Added api argument to all constructors and static generator functions and passed them down to BaseRequest.
• Added wrapper functions for all requests in TelegramBot.
• Fixed tests to use new API. NOTE: LogOutCloseTest.java is inherently broken and has to be fixed.
• Deprecated the entire SetStickerSetThumb class, instead of one of the compilers.
• Fixed API usage in sample to match the new API.
• Added lambda syntax to execute method
@HarryZalessky
Copy link
Contributor Author

@pengrad review? :)

Copy link

@s0m31-hub s0m31-hub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cloned your branch.

I prefer the way we have stuff in current version. Or at least would need some layer to have both method-based and request-based execution.

Method-based control will be cool in small and easy bots that are easy to code. It is always easier to call a method rather than 1) creating request. 2) setting it up. 3) passing as a parameter. But let's take a look at its main disadvantages now:

  • methods are not as configurable as classes. I didn't find how you want people to attach keyboards to their messages. You either need 100 overloads or think of something crazy
  • Java is famous with its class structure. Getting rid of it is just making it less Java
  • No backward compatibility. All classes now wants TelegramBotClient in constructor, which makes it impossible to update old projects to newer version of bot api without complete rewrites.
  • I love integrating IoC to my projects (who doesn't? Spring is used everywhere). And I used to have lists of requests to be executed, which another component borrowed and nailed the job. Now it is impossible, as everything have to be methods. Would either need a lot of reflection tweaks or create a ton of code just to achieve same results.

Overall, choosing small and very easy bots over big ones is totally not what I wanna see. Maybe if that was in parallel to classes - changes would be okay. But not in the current way you made it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make a sweet API
2 participants