[telegram] Add username to telegram bots
This commit is contained in:
parent
a7f0898fd7
commit
5e9a947284
|
@ -32,6 +32,9 @@ class TelegramBot(Censor):
|
|||
self.bot = Bot(token=self.telegram_model.api_token)
|
||||
self.dp = self._create_dispatcher()
|
||||
logger.debug(f'Bot {self.telegram_model.hood.name} starting.')
|
||||
user = await self.bot.get_me()
|
||||
if user.username:
|
||||
await self.telegram_model.update(username=user.username)
|
||||
await gather(self.dp.start_polling(), self._push())
|
||||
except CancelledError:
|
||||
logger.debug(f'Bot {self.telegram_model.hood.name} received Cancellation.')
|
||||
|
|
|
@ -11,6 +11,7 @@ class Telegram(Model):
|
|||
hood: ForeignKey(Hood)
|
||||
api_token: Text(unique=True)
|
||||
welcome_message: Text()
|
||||
username: Text(allow_null=True) = None
|
||||
enabled: Boolean() = True
|
||||
|
||||
class Mapping(Mapping):
|
||||
|
|
Loading…
Reference in a new issue