public static void IrcConnectionListCallback(object sender, ReadLineEventArgs e) { string[] linear = e.Line.Split(new char[] {' '}); if (linear.Length >= 5 && linear[1] == "322") { Console.WriteLine("On the IRC channel "+CHANNEL+" are "+linear[4]+" users"); ((IrcConnection)sender).Disconnect(); } }
private void _SimpleParser(object sender, ReadLineEventArgs args) { string rawline = args.Line; string[] rawlineex = rawline.Split(new char[] { ' ' }); string messagecode = ""; if (rawline[0] == ':') { messagecode = rawlineex[1]; ReplyCode replycode = ReplyCode.Null; try { replycode = (ReplyCode)int.Parse(messagecode); } catch (FormatException) { } if (replycode != ReplyCode.Null) { switch (replycode) { case ReplyCode.Welcome: _IsRegistered = true; #if LOG4NET Logger.Connection.Info("logged in"); #endif break; } } else { switch (rawlineex[1]) { case "PONG": DateTime now = DateTime.Now; _LastPongReceived = now; _Lag = now - _LastPingSent; #if LOG4NET Logger.Connection.Debug("PONG received, took: " + _Lag.TotalMilliseconds + " ms"); #endif break; } } } else { messagecode = rawlineex[0]; switch (messagecode) { case "ERROR": // FIXME: handle server errors differently than connection errors! //IsConnectionError = true; break; } } }
private void OnReadLine(object sender, ReadLineEventArgs e) { IrcMessageData data = _irc.MessageParser(e.Line); if (!_irc.IsMe(data.Nick)) foreach (var bottable in Modules) if (!bottable.OnReadLine(data)) break; //_irc.ListenOnce(); }
private void _SimpleParser(object sender, ReadLineEventArgs args) { string line = args.Line; string[] strArray = line.Split(' '); if (line[0] == ':') { string s = strArray[1]; int result = 0; ReplyCode replyCode = ReplyCode.Null; if (int.TryParse(s, out result) && System.Enum.IsDefined(typeof(ReplyCode), (object)result)) { replyCode = (ReplyCode)result; } switch (replyCode) { case ReplyCode.Null: switch (strArray[1]) { case "PONG": DateTime now = DateTime.Now; this._LastPongReceived = now; this._Lag = now - this._LastPingSent; return; case null: return; default: return; } case ReplyCode.Welcome: this._IsRegistered = true; break; } } else { string str; if ((str = strArray[0]) == null) { return; } int num = str == "ERROR" ? 1 : 0; } }
private void _SimpleParser(object sender, ReadLineEventArgs args) { string rawline = args.Line; string[] rawlineex = rawline.Split(new char[] { ' ' }); string messagecode = ""; if (rawline[0] == ':') { messagecode = rawlineex[1]; try { ReplyCode replycode = (ReplyCode)int.Parse(messagecode); switch (replycode) { case ReplyCode.Welcome: _IsRegistered = true; #if LOG4NET Logger.Connection.Info("logged in"); #endif break; } } catch (FormatException) { // nothing } } else { messagecode = rawlineex[0]; switch (messagecode) { case "ERROR": IsConnectionError = true; break; } } }
void OnReadLine(object sender, ReadLineEventArgs e) { string command = e.Line.Split(' ')[1]; if( command.Equals("PING") ) { string server = e.Line.Split(' ')[2]; irc.WriteLine("PONG " + server, Priority.Critical); } else if( command.Equals("422") || command.Equals("376") ) // 422: motd missing // 376: end of motd { if(OpList != null) OpList.Clear(); irc.RfcJoin(channel); } }
private void _Worker(object sender, ReadLineEventArgs e) { // lets see if we have events or internal messagehandler for it _HandleEvents(MessageParser(e.Line)); }
private void OnReadLine(object sender, ReadLineEventArgs e) { string decodedMessage = Encoding.UTF8.GetString(Encoding.Default.GetBytes(e.Line)); if (_logging) Console.WriteLine(decodedMessage); if (decodedMessage.Split(':').Length > 2) { if (decodedMessage.Split(':')[2] == "You are in a maze of twisty passages, all alike.") { _connected = true; OnConnected?.Invoke(null, new OnConnectedArgs {Username = TwitchUsername}); } } if (decodedMessage.Split(' ').Length > 3 && decodedMessage.Split(' ')[2] == "WHISPER") { var whisperMessage = new WhisperMessage(decodedMessage, _credentials.TwitchUsername); _previousWhisper = whisperMessage; OnWhisperReceived?.Invoke(null, new OnWhisperReceivedArgs {WhisperMessage = whisperMessage}); if (_commandIdentifier == '\0' || whisperMessage.Message[0] != _commandIdentifier) return; string command; var argumentsAsString = ""; var argumentsAsList = new List<string>(); if (whisperMessage.Message.Contains(" ")) { command = whisperMessage.Message.Split(' ')[0].Substring(1, whisperMessage.Message.Split(' ')[0].Length - 1); argumentsAsList.AddRange( whisperMessage.Message.Split(' ').Where(arg => arg != _commandIdentifier + command)); argumentsAsString = whisperMessage.Message.Replace(whisperMessage.Message.Split(' ')[0] + " ", ""); } else { command = whisperMessage.Message.Substring(1, whisperMessage.Message.Length - 1); } OnCommandReceived?.Invoke(null, new OnCommandReceivedArgs { Command = command, Username = whisperMessage.Username, ArgumentsAsList = argumentsAsList, ArgumentsAsString = argumentsAsString }); } else { //Special cases if (decodedMessage == ":tmi.twitch.tv NOTICE * :Error logging in") { _client.Disconnect(); OnIncorrectLogin?.Invoke(null, new OnIncorrectLoginArgs { Exception = new ErrorLoggingInException(decodedMessage, _credentials.TwitchUsername) }); } else { if (_logging) Console.WriteLine("Not registered: " + decodedMessage); } } }
void OnReadLine(object sender, ReadLineEventArgs e) { DebugRead(e.Line); }
private void _SimpleParser(object sender, ReadLineEventArgs args) { string rawline = args.Line; string[] rawlineex = rawline.Split(new char[] {' '}); string messagecode = ""; if (rawline[0] == ':') { messagecode = rawlineex[1]; ReplyCode replycode = ReplyCode.Null; try { replycode = (ReplyCode)int.Parse(messagecode); } catch (FormatException) { } if (replycode != ReplyCode.Null) { switch (replycode) { case ReplyCode.Welcome: _IsRegistered = true; #if LOG4NET Logger.Connection.Info("logged in"); #endif break; } } else { switch (rawlineex[1]) { case "PONG": DateTime now = DateTime.Now; _LastPongReceived = now; _Lag = now - _LastPingSent; #if LOG4NET Logger.Connection.Debug("PONG received, took: " + _Lag.TotalMilliseconds + " ms"); #endif break; } } } else { messagecode = rawlineex[0]; switch (messagecode) { case "ERROR": // FIXME: handle server errors differently than connection errors! //IsConnectionError = true; break; } } }
void OnReadLine(object sender, ReadLineEventArgs e) { string command = e.Line.Split(' ')[1]; if (command == "PING") { string server = e.Line.Split(' ')[2]; irc.WriteLine("PONG " + server, Priority.Critical); } else if (command == "376") // end of motd { if (OpList != null) OpList.Clear(); irc.RfcJoin(channel); } }
private void OnReadLine(object sender, ReadLineEventArgs e) { string command = e.Line.Split(' ')[0]; string second = e.Line.Split(' ')[1]; if (command.Equals("PING")) { irc.WriteLine("PONG " + second, Priority.Critical); } else if (second.Equals("422") || second.Equals("376")) // 422: motd missing // 376: end of motd { if (OpList != null) OpList.Clear(); if (OpList == null) OpList = new HashSet<string>(); } else if (second == "TOPIC") { } else { Console.WriteLine(">>> " + e.Line); } }
private static void Test(object sender,ReadLineEventArgs args) {Debug.WriteLine(args.Line);}
private void MeebyIrc_OnReadLine(object sender, Meebey.SmartIrc4net.ReadLineEventArgs e) { //Console.WriteLine("onReadLine Event:" + e.Line); }
private void _SimpleParser(object sender, ReadLineEventArgs args) { string rawline = args.Line; string[] rawlineex = rawline.Split(new char[] {' '}); string line = null; string prefix = null; string command = null; if (rawline[0] == ':') { prefix = rawlineex[0].Substring(1); line = rawline.Substring(prefix.Length + 2); } else { line = rawline; } string[] lineex = line.Split(new char[] {' '}); command = lineex[0]; ReplyCode replycode = ReplyCode.Null; int intReplycode; if (Int32.TryParse(command, out intReplycode)) { replycode = (ReplyCode) intReplycode; } if (replycode != ReplyCode.Null) { switch (replycode) { case ReplyCode.Welcome: _IsRegistered = true; #if LOG4NET Logger.Connection.Info("logged in"); #endif break; } } else { switch (command) { case "ERROR": // FIXME: handle server errors differently than connection errors! //IsConnectionError = true; break; case "PONG": DateTime now = DateTime.Now; _LastPongReceived = now; _Lag = now - _LastPingSent; #if LOG4NET Logger.Connection.Debug("PONG received, took: " + _Lag.TotalMilliseconds + " ms"); #endif break; } } }
private void _SimpleParser(object sender, ReadLineEventArgs args) { string rawline = args.Line; string[] rawlineex = rawline.Split(new char[] {' '}); string messagecode = ""; if (rawline[0] == ':') { messagecode = rawlineex[1]; try { ReplyCode replycode = (ReplyCode)int.Parse(messagecode); switch(replycode) { case ReplyCode.Welcome: _IsRegistered = true; #if LOG4NET Logger.Connection.Info("logged in"); #endif break; } } catch (FormatException) { // nothing } } else { messagecode = rawlineex[0]; switch(messagecode) { case "ERROR": IsConnectionError = true; break; } } }
private static void OnReadLine(object sender, ReadLineEventArgs e) { WriteDebug(e.Line); }
void OnReadLine(object sender, ReadLineEventArgs e) { if (e.Line != "") { Console.WriteLine("{0} >> {1}", DateTime.Now.ToShortTimeString(), e.Line); } else { Console.WriteLine("{0} >> {1}", DateTime.Now.ToShortTimeString(), "Received empty line.."); } }
void ClientOnReadLine(object sender, ReadLineEventArgs e) { _events.Enqueue(new IrcEvent { Type = IrcEvent.EventType.ReadLine, Event = e }); _waitHandle.Set(); }