コード例 #1
0
ファイル: TwitterBot.cs プロジェクト: dorisol1019/SNS_Bot
        //フォロワーさんを励ます機能
        public async Task SendMessageToFollowerAsync <TWords>(ICharacter character, TWords word, SerifType type, IUsingDataTable usingDataTable)
            where TWords : IWords
        {
            var timeline = await twitterHelper.GetTimeLineAsync();

            var tsuraiTweets = timeline.Where(e => e.RetweetedStatus == null).Where(e => !e.IsFavorited ?? true).Where(e => word.IsContained(e.Text)).Select(e => new { UserId = e.User.Id, e.Id, e.User.Name, e.Text });

            foreach (var tsuraiTweet in tsuraiTweets)
            {
                if (tsuraiTweet.UserId == await twitterHelper.GetMyId())
                {
                    continue;
                }
                if (tsuraiTweet.Text.Contains("@"))
                {
                    continue;
                }
                if (tsuraiTweet.Text.Contains("@"))
                {
                    continue;
                }
                string mes = usingDataTable.GetUseSerif(character.Name, type);

                var txt = mes.Replace("{ScreenName}", tsuraiTweet.Name);

                await twitterHelper.ReplyAsync(tsuraiTweet.Id, txt);

                await Task.Delay(100);

                await twitterHelper.FavoritesAsync(tsuraiTweet.Id);
            }
        }