コード例 #1
0
        public static async Task <bool> SendFeedUpdateAsync(TheGodfatherBot shard, RssSubscription sub, SyndicationItem latest)
        {
            DiscordChannel?chn;

            try {
                chn = await shard.Client.GetShard(sub.GuildId).GetChannelAsync(sub.ChannelId);
            } catch (NotFoundException) {
                return(false);
            }

            if (chn is null)
            {
                return(false);
            }

            var emb = new LocalizedEmbedBuilder(shard.Services.GetRequiredService <LocalizationService>(), sub.GuildId);

            emb.WithTitle(latest.Title.Text);
            emb.WithUrl(sub.Feed.LastPostUrl);
            emb.WithColor(DiscordColor.Gold);
            emb.WithLocalizedTimestamp(latest.LastUpdatedTime > latest.PublishDate ? latest.LastUpdatedTime : latest.PublishDate);

            if (latest.Content is TextSyndicationContent content)
            {
                string?imageUrl = RedditService.GetImageUrl(content);
                if (imageUrl is { })
コード例 #2
0
 public override (ulong gid, ulong cid) EntityGroupSelector(RssSubscription entity)
 => (entity.GuildId, entity.ChannelId);
コード例 #3
0
 public override int EntityIdSelector(RssSubscription entity)
 => entity.Id;
コード例 #4
0
 public void RemoveItem(RssSubscription subscription)
 {
     Subscriptions.Remove(subscription);
 }