This repository has been archived by the owner on Jul 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Resetter.cs
93 lines (85 loc) · 2.97 KB
/
Resetter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
using System;
using CoreTweet;
using CoreTweet.Core;
namespace Mh.Twitter.Resetter
{
class Resetter
{
private Tokens tokens;
public Resetter(Tokens tokens)
{
this.tokens = tokens;
}
public void EraseAllTweets(bool silence)
{
var user = tokens.Account.VerifyCredentials(include_email: false);
long userId = user.Id.Value;
ListedResponse<Status> timeline = null;
long? maxId = null;
do
{
timeline = tokens.Statuses.UserTimeline(count: 200, max_id: maxId, exclude_replies: false);
foreach (var status in timeline)
{
Status retweetedStatus = status.RetweetedStatus;
if (retweetedStatus != null)
{
if (!silence)
{
Console.WriteLine("unretweeting - " + status.Text);
}
tokens.Statuses.Unretweet(retweetedStatus.Id, true);
}
else
{
if (!silence)
{
Console.WriteLine("deleting - " + status.Text);
}
tokens.Statuses.Destroy(status.Id);
}
if (!maxId.HasValue || status.Id < maxId.Value)
{
maxId = status.Id - 1L;
}
}
}
while (timeline.Count > 0);
}
public void KickAllFollowers(bool silence)
{
var user = tokens.Account.VerifyCredentials(include_email: false);
long userId = user.Id.Value;
long? cursor = null;
do
{
var followerList = tokens.Followers.List(userId, cursor);
foreach (var follower in followerList)
{
if (!silence)
{
Console.WriteLine("blocking user : {0} (@{1})", follower.Name, follower.ScreenName);
}
tokens.Blocks.Create(follower.Id.Value, false, true);
}
cursor = followerList.NextCursor;
}
while (cursor != null && cursor != 0L);
cursor = null;
do
{
var blockList = tokens.Blocks.List(cursor);
foreach (var blocked in blockList)
{
if (!silence)
{
Console.WriteLine("unblocking user: {0} (@{1})", blocked.Name, blocked.ScreenName);
}
tokens.Blocks.Destroy(blocked.Id.Value, false, true);
}
cursor = blockList.NextCursor;
}
while (cursor != null && cursor != 0L);
}
}
}