52 lines
2.1 KiB
C#
52 lines
2.1 KiB
C#
using franz;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Threading.Tasks;
|
|
using TwitchEventSub.Types.EventSubSubscription;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace twitcher
|
|
{
|
|
class Program
|
|
{
|
|
public static TwitchEventSub.Receiver httpd;
|
|
public static Config twitcherConf;
|
|
//public static Telefranz tf;
|
|
static void Main(string[] args)
|
|
{
|
|
JsonConvert.DefaultSettings = () => {
|
|
var s = new JsonSerializerSettings();
|
|
s.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
|
|
return s;
|
|
};
|
|
if (!File.Exists("appsettings.json"))
|
|
{
|
|
Console.Error.WriteLine("appsettings.json was not found!");
|
|
twitcherConf = new Config();
|
|
File.WriteAllText("appsettings.json", JsonConvert.SerializeObject(twitcherConf, Formatting.Indented));
|
|
return;
|
|
}
|
|
twitcherConf = JsonConvert.DeserializeObject<Config>(File.ReadAllText("appsettings.json"));
|
|
|
|
// Telefranz.Configure(name: twitcherConf.kafka_name, bootstrap_servers: twitcherConf.kafka_bootstrap);
|
|
// Task.WaitAll(Task.Delay(1000));
|
|
// tf = Telefranz.Instance;
|
|
|
|
//TODO: throw a request out somewhere asking for public url
|
|
//tf.ProduceMessage(new silver_messages.directorial.execute_command(){command = "ssl_expose", args = {twitcherConf.port.ToString()}});
|
|
|
|
httpd = new TwitchEventSub.Receiver(twitcherConf.port, twitcherConf.clientId, twitcherConf.clientSecret, twitcherConf.public_uri);
|
|
var theRunTask = httpd.go();
|
|
httpd.Subscribe(SubscribableTypes.channel_follow,
|
|
new TwitchEventSub.Types.Conditions.ChannelFollow() { broadcaster_user_id = "12826" },
|
|
(tg) => {
|
|
Console.WriteLine("I'm the handler for a twitchogram!");
|
|
Console.WriteLine(JsonConvert.SerializeObject(tg));
|
|
}
|
|
);
|
|
Task.WaitAll(theRunTask);
|
|
}
|
|
}
|
|
}
|