commit f7dd14f08cd585892657318889d7ffcd1676b24f Author: Ben Harris Date: Wed Feb 6 01:18:03 2019 -0500 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a5dff61 --- /dev/null +++ b/.gitignore @@ -0,0 +1,34 @@ +*.swp +*.*~ +project.lock.json +.DS_Store +*.pyc +nupkg/ + +# Visual Studio Code +.vscode + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ +[Oo]ut/ +msbuild.log +msbuild.err +msbuild.wrn + +# Visual Studio 2015 +.vs/ diff --git a/App.config b/App.config new file mode 100644 index 0000000..161ff99 --- /dev/null +++ b/App.config @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..00eb2e1 --- /dev/null +++ b/Program.cs @@ -0,0 +1,54 @@ +using ChatSharp; +using System; +using System.Configuration; +using System.Collections.Specialized; +using System.Linq; + +namespace agrajag +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("starting agrajag"); + + NameValueCollection cfg = ConfigurationManager.AppSettings; + + var client = new IrcClient( + $"{cfg.Get("irc_host")}:{cfg.Get("irc_port")}", + new IrcUser(cfg.Get("bot_nick"), cfg.Get("bot_user")), + cfg.Get("irc_ssl") == "true" + ); + + client.ConnectionComplete += (s, e) => { + Console.WriteLine($"connected. joining {cfg.Get("channels")}"); + cfg.Get("channels") + .Split(',') + .ToList() + .ForEach(c => client.JoinChannel(c)); + }; + + client.ChannelMessageReceived += (s, e) => + { + var channel = client.Channels[e.PrivateMessage.Source]; + + if (e.PrivateMessage.Message == ".list") + channel.SendMessage(string.Join(", ", channel.Users.Select(u => u.Nick))); + else if (e.PrivateMessage.Message.StartsWith(".ban ")) + { + if (!channel.UsersByMode['@'].Contains(client.User)) + { + channel.SendMessage("I'm not an op here!"); + return; + } + var target = e.PrivateMessage.Message.Substring(5); + client.WhoIs(target, whois => channel.ChangeMode("+b *!*@" + whois.User.Hostname)); + } + }; + + client.ConnectAsync(); + + while (true) ; // Waste CPU cycles + } + } +} diff --git a/agrajag.csproj b/agrajag.csproj new file mode 100644 index 0000000..0e3c9c8 --- /dev/null +++ b/agrajag.csproj @@ -0,0 +1,18 @@ + + + + Exe + netcoreapp2.2 + + + + + ./chatsharp.dll + + + + + + + + diff --git a/chatsharp.dll b/chatsharp.dll new file mode 100644 index 0000000..e9bbfd4 Binary files /dev/null and b/chatsharp.dll differ