-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTwitter.cs
More file actions
55 lines (41 loc) · 1.44 KB
/
Twitter.cs
File metadata and controls
55 lines (41 loc) · 1.44 KB
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
using System;
using System.Threading;
using System.Collections;
using Tweetinvi;
namespace NoMoreBotrooms
{
public class Twitter
{
static DateTime pullTime;
public static void CheckForDMs()
{
Auth.SetUserCredentials("####YOUR TWITTER API TOKENS HERE####");
var user = User.GetAuthenticatedUser();
TimeSpan twoMins = TimeSpan.FromMinutes(2);
foreach (var msg in user.GetLatestMessages())
{
if (msg.SenderId.ToString() != "####YOUR OWN TWITTER USER_ID####" && (msg.CreatedAt >= pullTime || msg.CreatedAt.Subtract(twoMins) < pullTime))
{
string textToTweet = Markov.MarkovChain("yellowwallpaper.txt", 2, 300);
long userID = msg.SenderId;
Tweet(textToTweet, userID);
}
else if (msg.CreatedAt < pullTime)
{
break;
}
}
Console.WriteLine("Checking again...");
}
public static void RegisterPullTime()
{
pullTime = DateTime.Now;
Thread.Sleep(200000);
}
public static void Tweet(string textToTweet, long userID)
{
Auth.SetUserCredentials("####YOUR TWITTER TOKENS HERE####");
var message = Message.PublishMessage(textToTweet, userID);
}
}
}