72 lines
1.8 KiB
C#
72 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using S22.Xmpp.Client;
|
|
using S22.Xmpp.Im;
|
|
|
|
namespace RhinoReminds
|
|
{
|
|
public class ProgramSettings
|
|
{
|
|
public string Jid = null;
|
|
public string Username => Jid.Split('@')[0];
|
|
public string Hostname => Jid.Split('@')[1];
|
|
|
|
public string Password = null;
|
|
}
|
|
|
|
public static class Program
|
|
{
|
|
private static ProgramSettings settings = new ProgramSettings();
|
|
|
|
public static int Main(string[] args)
|
|
{
|
|
List<string> extras = new List<string>();
|
|
for (int i = 0; i < args.Length; i++)
|
|
{
|
|
if (!args[i].StartsWith("-")) {
|
|
extras.Add(args[i]);
|
|
continue;
|
|
}
|
|
|
|
switch (args[i]) {
|
|
case "--help":
|
|
Console.WriteLine("--- RhinoReminds ---");
|
|
Console.WriteLine("> An XMPP reminder bot");
|
|
Console.WriteLine(" By Starbeamrainbowlabs");
|
|
Console.WriteLine();
|
|
Console.WriteLine("Usage:");
|
|
Console.WriteLine(" mono RhinoReminds.exe {options}");
|
|
Console.WriteLine();
|
|
Console.WriteLine("Options:");
|
|
Console.WriteLine(" -h --help Show this message");
|
|
Console.WriteLine();
|
|
Console.WriteLine("Environment Variables:");
|
|
Console.WriteLine(" XMPP_JID The JID to login to");
|
|
Console.WriteLine(" XMPP_PASSWORD The password to login with");
|
|
return 0;
|
|
|
|
case "--jid":
|
|
settings.Jid = args[++i];
|
|
break;
|
|
}
|
|
}
|
|
|
|
settings.Jid = Environment.GetEnvironmentVariable("XMPP_JID");
|
|
settings.Password = Environment.GetEnvironmentVariable("XMPP_PASSWORD");
|
|
|
|
return 0;
|
|
}
|
|
|
|
public static void Run()
|
|
{
|
|
XmppClient client = new XmppClient(
|
|
settings.Hostname,
|
|
settings.Username, settings.Password
|
|
);
|
|
client.Message += (object sender, MessageEventArgs e) => {
|
|
Console.WriteLine($"[Rhino/Reciever] {e.Jid} | {e.Message}");
|
|
};
|
|
client.Connect();
|
|
}
|
|
}
|
|
}
|