Skip to content

Commit

Permalink
change chat id to chat object to be able to work with username
Browse files Browse the repository at this point in the history
  • Loading branch information
tschulz committed May 20, 2016
1 parent 5fe18ae commit 1bb4d12
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.telegram.telegrambots.api.commands;

import org.telegram.telegrambots.api.objects.Chat;
import org.telegram.telegrambots.bots.AbsSender;

/**
Expand Down Expand Up @@ -69,7 +70,7 @@ public final String getBotToken() {
* execute the command
*
* @param arguments passed arguments
* @param chatId id of the chat, to be able to send replies
* @param chat the chat, to be able to send replies
*/
public abstract void execute(String[] arguments, long chatId);
public abstract void execute(String[] arguments, Chat chat);
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public final boolean executeCommand(Message message) {

if (commandRegistryMap.containsKey(command)) {
String[] parameters = Arrays.copyOfRange(commandSplit, 1, commandSplit.length);
commandRegistryMap.get(command).execute(parameters, message.getChatId());
commandRegistryMap.get(command).execute(parameters, message.getChat());
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.telegram.telegrambots.BotLogger;
import org.telegram.telegrambots.TelegramApiException;
import org.telegram.telegrambots.api.methods.send.SendMessage;
import org.telegram.telegrambots.api.objects.Chat;

/**
* standard help command, which gets registered by default, to supply a list of all available commands
Expand All @@ -20,10 +21,11 @@ public HelpBotCommand(ICommandRegistry commandRegistry, String botToken) {
}

@Override
public void execute(String[] arguments, long chatId) {
public void execute(String[] arguments, Chat chat) {

for (BotCommand registeredBotCommand : commandRegistry.getRegisteredCommands()) {
SendMessage sendMessage = new SendMessage();
sendMessage.setChatId(chatId);
sendMessage.setChatId(chat.getId());
sendMessage.enableHtml(true);
sendMessage.setText("<b>" + COMMAND_INIT_CHARACTER + registeredBotCommand.getCommandIdentifier() + "</b>\n" + registeredBotCommand.getDescription());

Expand Down

0 comments on commit 1bb4d12

Please sign in to comment.