service.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:StreamNotificationBot 作者: ivandardi 项目源码 文件源码
def _notify_subscribers_of_streamer(self, streamer: Streamer):
        subscribers = await self.bot.database.get_subscribers_from_streamer(streamer.db_id)
        for (subscriber_id,) in subscribers:
            if subscriber_id in self.disabled_users:
                continue
            subscriber = await self._get_subscriber(subscriber_id)
            if subscriber:
                notification_embed = streamer.create_notification_embed()
                try:
                    await subscriber.send(embed=notification_embed)
                    log.info('Notified %s that streamer %s is online on %s',
                             subscriber, streamer.channel_name, streamer.service_name)
                except discord.Forbidden as e:
                    log.exception('_notify_subscribers_of_streamer: No permissions to send the message.\n%s', e)
                except discord.HTTPException as e:
                    log.exception('_notify_subscribers_of_streamer: Sending the message failed.\n%s', e)
                except Exception as e:
                    log.exception('_notify_subscribers_of_streamer: General exception.\n%s', e)
            else:
                log.error('_notify_subscribers_of_streamer: Subscriber not found: %s', subscriber_id)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号