reefstah / TelegramBotAPI

A Java 8 implementation of Telegram's bot API.
MIT License
8 stars 1 forks source link

Suggestion #5

Open UnAfraid opened 9 years ago

UnAfraid commented 9 years ago

Hello,

I was wondering can you implement some generic helper about all the method's parameters. I mean all those duplicated methods with only difference optional parameters.

Something like

sendMessage:

bot.sendMessage(new MessageBuilder(chat_id)
    .text("my text here")
    .reply(messageId));

sendPhoto:

bot.sendPhoto(new PhotoBuilder(chat_id)
    .photo(new File("myPhoto.png"))
    .caption("this is my photo")
    .reply(messageId));
reefstah commented 9 years ago

Sounds like a good idea, but then in the form of a fluent API like Apache did with their rest client.

UnAfraid commented 9 years ago

I've done it, and yeah its fluent, i'll do pull request

UnAfraid commented 9 years ago

Pull Request up: https://github.com/Reefstah/TelegramBotAPI/pull/6

reefstah commented 9 years ago

Whoops linked commit to wrong issue. Anyway here is the link to the commit. This is what I ment (;

SendMessage
        .to(YourChatIdHere)
        .withText("Sexy fluent TelegramBotAPI.")
        .withBot(YourBotTokenHere);
reefstah commented 9 years ago

I think we should still keep the method overloading I think that is just a matter of taste, but we should add the builders of course. Could you remove the licenses from the class headers and make the tests work. I have no idea how it works with forks, but I have set TOKEN and GROUP_CHAT_ID in Travis. Thanks :D #6

UnAfraid commented 9 years ago

I striped the license :O