mirror of https://github.com/icedream/npsharp.git
51 lines
1.2 KiB
C#
51 lines
1.2 KiB
C#
|
using System;
|
|||
|
using System.Text;
|
|||
|
using NPSharp.Authentication;
|
|||
|
|
|||
|
namespace NPSharp.CommandLine.MOTD
|
|||
|
{
|
|||
|
class Program
|
|||
|
{
|
|||
|
static void Main(string[] args)
|
|||
|
{
|
|||
|
var hostname = args[0];
|
|||
|
var username = args[1];
|
|||
|
var password = args[2];
|
|||
|
|
|||
|
var ah = new AuthenticationHelper(hostname);
|
|||
|
try
|
|||
|
{
|
|||
|
ah.Authenticate(username, password);
|
|||
|
}
|
|||
|
catch
|
|||
|
{
|
|||
|
Console.Error.WriteLine("Could not authenticate.");
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
var np = new NPClient(hostname);
|
|||
|
try
|
|||
|
{
|
|||
|
np.AuthenticateWithToken(ah.SessionToken).Wait();
|
|||
|
}
|
|||
|
catch
|
|||
|
{
|
|||
|
Console.Error.WriteLine("Authenticated but session token was invalid.");
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
Console.WriteLine(Encoding.UTF8.GetString(np.GetPublisherFile("motd-english.txt").Result));
|
|||
|
}
|
|||
|
catch
|
|||
|
{
|
|||
|
Console.Error.WriteLine("Could not read MOTD from NP server.");
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|