public void Connect() { using (var irc = new TcpClient(Server, Port)) { irc.SendBufferSize = Client.BufferSize; irc.ReceiveBufferSize = Client.BufferSize; using (var client = new Client(irc.GetStream())) { client.Pass(Password); client.User(Environment.UserName, InitUsermode, RealName); client.Nick(Nick); client.Mode(Nick, Usermode); Thread.Sleep(SendDelay * 3); client.Join(Channel, string.Empty); client.MessageReceived += Trigger; PasteSetup(client); FunBotsSetup(client); client.Listen(); } irc.Client.Close(SendDelay); } }
void FunBotsSetup(Client client) { var timer = new Timer(60 * 60 * 1000 / 2); timer.Elapsed += new ElapsedEventHandler(delegate(object sender, ElapsedEventArgs e) { client.Private("lolikins", "!stuff"); }); client.Quitting += new EventHandler(delegate(object sender, EventArgs e) { if (timer.Enabled) timer.Stop(); }); timer.Start(); }
void Connect() { irc = new TcpClient(Server, Port); irc.SendBufferSize = Client.BufferSize; irc.ReceiveBufferSize = Client.BufferSize; client = new Client(irc.GetStream()); client.Pass(Password); client.User(Username, InitUsermode, RealName); client.Nick(Username); client.Mode(Username, Usermode); Thread.Sleep(SendDelay * 3); client.Join(Channel, string.Empty); PasteSetup(); FunBotsSetup(); }
void PasteSetup(Client client) { if (string.IsNullOrEmpty(PasteURL)) return; pasteIds = new List<string>(); var timer = new Timer(PasteFreq); var local = !string.IsNullOrEmpty(PasteSync) && Directory.Exists(PasteSync); timer.Elapsed += new ElapsedEventHandler(delegate(object sender, ElapsedEventArgs e) { if (local) { foreach (var file in new DirectoryInfo(PasteSync).GetFiles()) { string id = file.Name, nick = File.ReadAllText(file.FullName), info = string.Empty, item = PasteURL + id; if (pasteIds.Contains(item)) continue; int z = nick.IndexOf(' '); if (z != -1) { info = nick.Substring(z + 1); nick = nick.Substring(0, z); } pasteIds.Add(item); file.Delete(); pasteMessage(client, nick, item, info); } } else { var list = pasteFetch(); foreach (var item in list.Keys) { if (pasteIds.Contains(item)) continue; pasteIds.Add(item); pasteMessage(client, list[item][0], item, list[item][1]); } } }); if (local) { foreach (var file in new DirectoryInfo(PasteSync).GetFiles()) { pasteIds.Add(PasteURL + file.Name); file.Delete(); } } else { foreach (var item in pasteFetch().Keys) pasteIds.Add(item); } client.Quitting += new System.EventHandler(delegate(object sender, EventArgs e) { if (timer.Enabled) timer.Stop(); }); timer.Start(); }
void pasteMessage(Client client, string nick, string id, string info) { if (!string.IsNullOrEmpty(info)) info = " - " + info; client.Private(Channel, string.Format("{0} pasted {1}{2}", new string[] { nick, id, info })); }