Class MessageContext
Object
MessageContext
MessageContext is a wrapper class to the
Update, 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 Update using update().
- Author:
- Abbas Abou Daya
-
Method Summary
Modifier and TypeMethodDescriptionString[]If there's no message in the update, then this will an empty array.bot()chatId()booleanfirstArg()inthashCode()static MessageContextnewContext(Update update, User user, Long chatId, BaseAbilityBot bot, String... arguments) thirdArg()toString()Updateupdate()Useruser()
-
Method Details
-
newContext
public static MessageContext newContext(Update update, User user, Long chatId, BaseAbilityBot bot, String... arguments) -
user
public User user()- Returns:
- the originating Telegram user of this update
-
chatId
- Returns:
- the originating chatId, maps correctly to both group and user-private chats
-
bot
- Returns:
- the bot in which this message is executed
-
arguments
If there's no message in the update, then this will an empty array.- Returns:
- the text sent by the user message.
-
firstArg
- Returns:
- the first argument directly after the command
- Throws:
IllegalStateException- if message has no arguments
-
secondArg
- Returns:
- the second argument directly after the command
- Throws:
IllegalStateException- if message has no arguments
-
thirdArg
- Returns:
- the third argument directly after the command
- Throws:
IllegalStateException- if message has no arguments
-
update
public Update update()- Returns:
- the actual update behind this context
-
toString
-
equals
-
hashCode
public int hashCode()
-