| 1 | package com.github.netkorp.telegram.framework.commands.abstracts; |
||
|
0 ignored issues
–
show
Code Smell
introduced
by
Loading history...
|
|||
| 2 | |||
| 3 | import com.github.netkorp.telegram.framework.bots.PollingTelegramBot; |
||
| 4 | import com.github.netkorp.telegram.framework.commands.interfaces.Command; |
||
| 5 | import com.github.netkorp.telegram.framework.managers.CommandManager; |
||
| 6 | import org.springframework.beans.factory.annotation.Autowired; |
||
| 7 | import org.springframework.beans.factory.annotation.Qualifier; |
||
| 8 | import org.springframework.context.MessageSource; |
||
| 9 | import org.springframework.context.annotation.Lazy; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * Stores the basic components that the command needs. |
||
| 13 | */ |
||
| 14 | abstract class AbstractCommand implements Command { |
||
|
0 ignored issues
–
show
|
|||
| 15 | |||
| 16 | /** |
||
| 17 | * The bot that the command can use to share information with Telegram. |
||
| 18 | */ |
||
| 19 | protected PollingTelegramBot bot; |
||
|
0 ignored issues
–
show
|
|||
| 20 | |||
| 21 | /** |
||
| 22 | * The component for managing all of the commands available in the bot. |
||
| 23 | */ |
||
| 24 | protected CommandManager commandManager; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * The component for resolving messages |
||
| 28 | */ |
||
| 29 | protected MessageSource messageSource; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Sets the Telegram bot to be used. |
||
| 33 | * |
||
| 34 | * @param bot the Telegram bot. |
||
| 35 | */ |
||
| 36 | @Autowired |
||
| 37 | public void setBot(PollingTelegramBot bot) { |
||
|
0 ignored issues
–
show
|
|||
| 38 | this.bot = bot; |
||
|
0 ignored issues
–
show
|
|||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Sets the {@link CommandManager} to be used. |
||
| 43 | * |
||
| 44 | * @param commandManager the {@link CommandManager} instance. |
||
| 45 | */ |
||
| 46 | @Autowired |
||
| 47 | public void setCommandManager(@Lazy CommandManager commandManager) { |
||
|
0 ignored issues
–
show
|
|||
| 48 | this.commandManager = commandManager; |
||
|
0 ignored issues
–
show
|
|||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Sets the {@link MessageSource} to be used. |
||
| 53 | * |
||
| 54 | * @param messageSource the {@link MessageSource} instance. |
||
| 55 | */ |
||
| 56 | @Autowired |
||
| 57 | public void setMessageSource(@Qualifier("TelegramFrameworkMessageSource") MessageSource messageSource) { |
||
|
0 ignored issues
–
show
|
|||
| 58 | this.messageSource = messageSource; |
||
|
0 ignored issues
–
show
|
|||
| 59 | } |
||
| 60 | } |
||
| 61 |