private static void OnCtcpRequest(object sender, CtcpEventArgs e) { string from = e.Data.Nick; switch (e.CtcpCommand.ToUpper()) { case "CLIENTINFO": client.SendMessage(SendType.CtcpReply, from, "CLIENTINFO Supported CTCP commands: CLIENTINFO FACTION PING VERSION"); break; case "FACTION": if (!crcNicks.ContainsKey(from)) { crcNicks[from] = "actor_stalker"; client.SendMessage(SendType.CtcpRequest, from, "FACTION"); } client.SendMessage(SendType.CtcpReply, from, "FACTION " + CRCOptions.GetFaction()); break; case "PING": client.SendMessage(SendType.CtcpReply, from, "PING " + e.CtcpParameter); break; case "VERSION": client.SendMessage(SendType.CtcpReply, from, "VERSION Chernobyl Relay Chat " + Application.ProductVersion); break; } }
public static void SendDeath(string message) { string nick = CRCStrings.RandomName(CRCOptions.GameFaction); client.SendMessage(SendType.Message, CRCOptions.ChannelProxy(), nick + FAKE_DELIM + CRCOptions.GetFaction() + META_DELIM + message); CRCDisplay.OnChannelMessage(nick, message); CRCGame.OnChannelMessage(nick, CRCOptions.GameFaction, message); }
private static void OnConnected(object sender, EventArgs e) { Users.Clear(); crcNicks.Clear(); lastName = CRCOptions.Name; lastChannel = CRCOptions.ChannelProxy(); lastFaction = CRCOptions.GetFaction(); client.Login(CRCOptions.Name, CRCStrings.Localize("crc_name") + " " + Application.ProductVersion); client.RfcJoin(CRCOptions.ChannelProxy()); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); #if !DEBUG // Prevent multiple instances if (!mutex.WaitOne(TimeSpan.FromSeconds(0), false)) { return; } #endif CRCStrings.Load(); bool optionsLoaded = CRCOptions.Load(); if (!optionsLoaded) { // No point localizing this since localization may not even be loaded MessageBox.Show("CRC was unable to access the registry, which is needed to preserve settings.\r\n" + "Please try running the application As Administrator.\r\n\r\n" + "CRC не смог получить доступ к реестру, который необходим для сохранения настроек.\r\n" + "Попробуйте запустить приложение с правами администратора.", CRCStrings.Localize("crc_name"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (CRCUpdate.CheckFirstUpdate()) { return; } displayThread = new Thread(CRCDisplay.Start); displayThread.Start(); clientThread = new Thread(CRCClient.Start); clientThread.Start(); clientThread.Join(); displayThread.Join(); CRCOptions.Save(); }
private void buttonOK_Click(object sender, EventArgs e) { string name = textBoxName.Text.Replace(' ', '_'); string result = CRCStrings.ValidateNick(name); if (result != null) { MessageBox.Show(result, CRCStrings.Localize("crc_error"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string lang = indexToLanguage[comboBoxLanguage.SelectedIndex]; if (lang != CRCOptions.Language) { CRCOptions.Language = lang; MessageBox.Show(CRCStrings.Localize("options_language_restart"), CRCStrings.Localize("crc_name"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } CRCOptions.Channel = indexToChannel[comboBoxChannel.SelectedIndex]; CRCOptions.AutoFaction = radioButtonFactionAuto.Checked; CRCOptions.ManualFaction = indexToFaction[comboBoxFaction.SelectedIndex]; CRCOptions.Name = name; CRCOptions.ShowTimestamps = checkBoxTimestamps.Checked; CRCOptions.SendDeath = checkBoxDeathSend.Checked; CRCOptions.ReceiveDeath = checkBoxDeathReceive.Checked; CRCOptions.DeathInterval = (int)numericUpDownDeath.Value; CRCOptions.NewsDuration = (int)numericUpDownNewsDuration.Value; CRCOptions.ChatKey = textBoxChatKey.Text; CRCOptions.NewsSound = checkBoxNewsSound.Checked; CRCOptions.CloseChat = checkBoxCloseChat.Checked; CRCOptions.Save(); CRCClient.UpdateSettings(); CRCGame.UpdateSettings(); this.Close(); }
public static void UpdateSettings() { if (CRCOptions.Name != lastName) { client.RfcNick(CRCOptions.Name); lastName = CRCOptions.Name; } if (CRCOptions.ChannelProxy() != lastChannel) { Users.Clear(); client.RfcPart(lastChannel); client.RfcJoin(CRCOptions.ChannelProxy()); lastChannel = CRCOptions.ChannelProxy(); } if (CRCOptions.GetFaction() != lastFaction) { foreach (string nick in crcNicks.Keys) { client.SendMessage(SendType.CtcpReply, nick, CRCOptions.GetFaction()); } lastFaction = CRCOptions.GetFaction(); } }
public static void SendQuery(string nick, string message) { client.SendMessage(SendType.Message, nick, CRCOptions.GetFaction() + META_DELIM + message); CRCDisplay.OnQueryMessage(CRCOptions.Name, nick, message); CRCGame.OnQueryMessage(CRCOptions.Name, nick, CRCOptions.GetFaction(), message); }
public static void Send(string message) { client.SendMessage(SendType.Message, CRCOptions.ChannelProxy(), message); CRCDisplay.OnOwnChannelMessage(CRCOptions.Name, message); CRCGame.OnChannelMessage(CRCOptions.Name, CRCOptions.GetFaction(), message); }