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); adminCommands = new AdminCommands(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); }
public bool Start() { if (config.AttemptToRecconnect) { recon = new Timer(config.AttemptReconnectInterval * 1000); recon.AutoReset = true; recon.Elapsed += recon_Elapsed; } recon.Enabled = false; tas.ConnectionLost += tas_ConnectionLost; tas.Connected += tas_Connected; tas.LoginDenied += tas_LoginDenied; tas.LoginAccepted += tas_LoginAccepted; Auth = new AuthService(tas); adminCommands = new AdminCommands(tas); offlineMessages = new OfflineMessages(tas); playerMover = new PlayerMover(tas); MumbleMover = new MumbleMover(tas); PayPalInterface = new PayPalInterface(); PayPalInterface.Error += (e) => { tas.Say(TasClient.SayPlace.Channel, "zkdev", "PAYMENT ERROR: " + e.ToString(), true); }; PayPalInterface.NewContribution += (c) => { tas.Say(TasClient.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(TasClient.SayPlace.Channel, "zkdev", "Warning, user account unknown yet, payment remains unassigned. If you know user name, please assign it manually http://zero-k.info/Contributions", true); } else { tas.Say(TasClient.SayPlace.Channel, "zkdev", string.Format("It is {0} http://zero-k.info/Users/Detail/{1}", c.AccountByAccountID.Name, c.AccountID), true); } }; try { tas.Connect(config.ServerHost, config.ServerPort); } catch { recon.Start(); } return(true); }