public bool Start() { tas.Connected += tas_Connected; tas.LoginDenied += tas_LoginDenied; tas.LoginAccepted += tas_LoginAccepted; using (var db = new ZkDataContext()) { var acc = db.Accounts.FirstOrDefault(x => x.Name == GlobalConst.NightwatchName); if (acc != null) { acc.SetPasswordPlain(config.AccountPassword); acc.IsBot = true; acc.IsZeroKAdmin = true; db.SaveChanges(); } } Auth = new AuthService(tas); offlineMessages = new OfflineMessages(tas); playerMover = new PlayerMover(tas); SteamHandler = new NwSteamHandler(tas, new Secrets().GetSteamWebApiKey()); chatRelay = new ChatRelay(tas, new Secrets().GetNightwatchPassword(), new List<string>() { "zkdev", "sy", "moddev" }); PayPalInterface = new PayPalInterface(); PayPalInterface.Error += (e) => { tas.Say(SayPlace.Channel, "zkdev", "PAYMENT ERROR: " + e.ToString(), true); }; PayPalInterface.NewContribution += (c) => { tas.Say(SayPlace.Channel, "zkdev", string.Format("WOOHOO! {0:d} New contribution of {1:F2}€ by {2} - for the jar {3}", c.Time, c.Euros, c.Name.Split(new[]{' '},StringSplitOptions.RemoveEmptyEntries).FirstOrDefault(), c.ContributionJar.Name), true); if (c.AccountByAccountID == null) tas.Say(SayPlace.Channel, "zkdev", string.Format("Warning, user account unknown yet, payment remains unassigned. If you know user name, please assign it manually {0}/Contributions", GlobalConst.BaseSiteUrl), true); else tas.Say(SayPlace.Channel, "zkdev", string.Format("It is {0} {2}/Users/Detail/{1}", c.AccountByAccountID.Name, c.AccountID, GlobalConst.BaseSiteUrl), true); }; tas.Connect(config.ServerHost, config.ServerPort); return true; }
static void SetupPaypalInterface() { PayPalInterface = new PayPalInterface(); PayPalInterface.Error += (e) => { Server.GhostSay(new Say() { IsEmote = true, Target = "zkdev", User = GlobalConst.NightwatchName, Text = "PAYMENT ERROR: " + e.ToString() }); }; PayPalInterface.NewContribution += (c) => { var message = string.Format("WOOHOO! {0:d} New contribution of {1:F2}€ by {2} - for the jar {3}", c.Time, c.Euros, c.Name.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault(), c.ContributionJar.Name); Server.GhostSay(new Say() { IsEmote = true, Target = "zkdev", User = GlobalConst.NightwatchName, Text = message }); if (c.AccountByAccountID != null) { Server.GhostSay(new Say() { IsEmote = true, Target = "zkdev", User = GlobalConst.NightwatchName, Text = string.Format("It is {0} {2}/Users/Detail/{1}", c.AccountByAccountID.Name, c.AccountID, GlobalConst.BaseSiteUrl) }); } }; }