Class MessageContext
- java.lang.Object
-
- org.telegram.abilitybots.api.objects.MessageContext
-
public class MessageContext extends Object
MessageContext is a wrapper class to theUpdate, originating end-user and the arguments present in its message (if any).A user is not bound to the usage of this higher level context as it's possible to fetch the underlying
Updateusingupdate().- Author:
- Abbas Abou Daya
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String[]arguments()If there's no message in the update, then this will an empty array.BaseAbilityBotbot()LongchatId()booleanequals(Object o)StringfirstArg()inthashCode()static MessageContextnewContext(org.telegram.telegrambots.meta.api.objects.Update update, org.telegram.telegrambots.meta.api.objects.User user, Long chatId, BaseAbilityBot bot, String... arguments)StringsecondArg()StringthirdArg()StringtoString()org.telegram.telegrambots.meta.api.objects.Updateupdate()org.telegram.telegrambots.meta.api.objects.Useruser()
-
-
-
Method Detail
-
newContext
public static MessageContext newContext(org.telegram.telegrambots.meta.api.objects.Update update, org.telegram.telegrambots.meta.api.objects.User user, Long chatId, BaseAbilityBot bot, String... arguments)
-
user
public org.telegram.telegrambots.meta.api.objects.User user()
- Returns:
- the originating Telegram user of this update
-
chatId
public Long chatId()
- Returns:
- the originating chatId, maps correctly to both group and user-private chats
-
bot
public BaseAbilityBot bot()
- Returns:
- the bot in which this message is executed
-
arguments
public String[] arguments()
If there's no message in the update, then this will an empty array.- Returns:
- the text sent by the user message.
-
firstArg
public String firstArg()
- Returns:
- the first argument directly after the command
- Throws:
IllegalStateException- if message has no arguments
-
secondArg
public String secondArg()
- Returns:
- the second argument directly after the command
- Throws:
IllegalStateException- if message has no arguments
-
thirdArg
public String thirdArg()
- Returns:
- the third argument directly after the command
- Throws:
IllegalStateException- if message has no arguments
-
update
public org.telegram.telegrambots.meta.api.objects.Update update()
- Returns:
- the actual update behind this context
-
-