-
Notifications
You must be signed in to change notification settings - Fork 4
/
Program.cs
70 lines (52 loc) · 1.91 KB
/
Program.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YoutubeChat;
namespace YoutubeChatTest
{
class Program
{
private const string YoutubeClientId = "";
private const string YoutubeClientSecret = "";
private const string GoogleApiKey = "";
[STAThread]
static void Main(string[] args)
{
//Login With Bot User
YoutubeLogin botLogin = new YoutubeLogin(YoutubeClientId, YoutubeClientSecret);
botLogin.ShowDialog();
//Login With Channel User
YoutubeLogin channelLogin = new YoutubeLogin(YoutubeClientId, YoutubeClientSecret);
channelLogin.ShowDialog();
(string channelAccessToken, _) = channelLogin.RequestTokens();
YoutubeLiveChat<MyUser> youtube = new YoutubeLiveChat<MyUser>(botLogin, GoogleApiKey);
youtube.LoadLiveChatId(channelAccessToken); //Only working with a live "Youtube Event"(Planned LiveStream)
youtube.Userlist.Load("userlist.xml");
youtube.ChannelMessage += (o, e) =>
{
Console.WriteLine(e.From.DisplayName + ": " + e.Message + "(Created "+e.From.Created.ToString() +")");
if (e.Message == "!test") youtube.Send("test received");
};
youtube.Start();
//Stop and Save
Console.ReadLine();
youtube.Stop();
youtube.Userlist.Save("userlist.xml");
}
}
public class MyUser : LiveUser
{
private DateTime created;
public MyUser()
{
created = DateTime.Now;
}
public override void Update() //called every 10 seconds
{
//created = created.AddSeconds(1); //makes no sense but works
}
public DateTime Created { get => created; set => created = value; }
}
}