/// <summary>Adds a message for the competition.</summary> /// <param name="messageSource">Source of the message.</param> /// <param name="messageSeverity">Severity of the message.</param> /// <param name="message">Text of the message.</param> /// <param name="hint">Hints for the message.</param> internal void WriteMessageCore( MessageSource messageSource, MessageSeverity messageSeverity, [NotNull] string message, [CanBeNull] string hint = null) { Message result; lock (_lockKey) { AssertIsInCompetition(); result = new Message( RunNumber, MessagesInRun + 1, Elapsed, messageSource, messageSeverity, message, hint); _messages.Add(result); MessagesInRun++; if (HighestMessageSeverityInRun < messageSeverity) { HighestMessageSeverityInRun = messageSeverity; } if (HighestMessageSeverity < messageSeverity) { HighestMessageSeverity = messageSeverity; } } Logger.LogMessage(result); }
private bool HandlePluginSupport(IPlayer player, string message, MessageSource type, int channel = 0) { if (_pluginConfig.PluginSupport.AdminChat.Enabled) { string adminChatPrefix = _pluginConfig.PluginSupport.AdminChat.AdminChatPrefix; if (message.StartsWith(adminChatPrefix)) { HandleAdminChat(player, message.Substring(adminChatPrefix.Length), type); return(_pluginConfig.PluginSupport.AdminChat.ExcludeDefault); } if (IsInAdminChat(player)) { HandleAdminChat(player, message, type); return(_pluginConfig.PluginSupport.AdminChat.ExcludeDefault); } } if (ChatTranslator != null && ChatTranslator.IsLoaded) { HandleTranslate(message, _pluginConfig.PluginSupport.ChatTranslator.DiscordServerLanguage, lang.GetLanguage(player.Id), translatedMessage => { HandleChatMessage(player, translatedMessage, channel); }); return(true); } if (IsInAdminDeepCover(player) && channel != 1) { return(true); } return(false); }
public MessageError(MessageSource source, string code) { Source = source; Code = code ?? ""; switch (Code.ToUpper()) { case "BUFFER": Message = "X10 message buffer is full. Please wait a few seconds and try again."; break; case "SYNTAX": Message = "Syntax error in message sent to controller."; break; case "TIMOUT": Message = Source != MessageSource.Ethernet ? "Complete 3 or 9 character message not received within timeout." : "Response Timeout. Client failed to send response to 100 Continue challenge within threshold."; break; case "NOAUTH": Message = "Unauthorized. Client tried to log in with invalid user name or password."; break; case "METHOD": Message = "Not Implemented. Client made a request using an unsupported HTTP method."; break; default: Message = "Unknown exception type."; break; } }
public static void ProcessMessage(Message msg, MessageSource source) { logger.Info($"Read sender details from app settings -> Email sender : {OrderEmailSender}, SMS sender : {OrderSmsSender}"); var notificationMessage = msg.Body as NotificationMessage; if (source.Equals(MessageSource.Order)) { if (IsValidOrderEmailSender && !string.IsNullOrEmpty(notificationMessage.RecipientDetails.EmailAddress)) { SendEmailMessage(OrderEmailSender, notificationMessage.RecipientDetails.EmailAddress, notificationMessage.Subject, notificationMessage.Body); } if (IsValidOrderSmsSender && !string.IsNullOrEmpty(notificationMessage.RecipientDetails.PhoneNumber)) { SendSmsMessage(OrderSmsSender, notificationMessage.RecipientDetails.PhoneNumber, notificationMessage.Subject, notificationMessage.Body); } } else if (source.Equals(MessageSource.Incident)) { if (IsValidIncidentEmailSender && !string.IsNullOrEmpty(notificationMessage.RecipientDetails.EmailAddress)) { SendEmailMessage(IncidentEmailSender, notificationMessage.RecipientDetails.EmailAddress, notificationMessage.Subject, notificationMessage.Body); } if (IsValidIncidentSmsSender && !string.IsNullOrEmpty(notificationMessage.RecipientDetails.PhoneNumber)) { SendSmsMessage(IncidentSmsSender, notificationMessage.RecipientDetails.PhoneNumber, notificationMessage.Subject, notificationMessage.Body); } } }
public string Parse(MessageSource sender, CommandArgs args) { Stream stream; if(args.Args.Count != 0) { if(!sender.Permission.IsOperator) { return string.Format("Error - usage {0}. Operators may force updates of other streamers", args.Name); } stream = _handler.GetStream(args.Args[0]); if (stream == null) { return "Sorry no streamer exists with that name."; } } else { stream = _handler.GetStream(sender.Nickname); if (stream == null) { return "Sorry you don't seem to own a stream."; } } Logger.Info("Manual update for " + stream.Name); stream.Update(_handler); return "Updating " + stream.Name; }
// TODO: The error tracking could be made better to track the full information returned by Dafny public override bool Message(MessageSource source, ErrorLevel level, IToken tok, string msg) { if (base.Message(source, level, tok, msg)) { switch (level) { case ErrorLevel.Error: dd.RecordError(tok.filename, tok.line, tok.col, source == MessageSource.Parser ? ErrorCategory.ParseError : ErrorCategory.ResolveError, msg); break; case ErrorLevel.Warning: dd.RecordError(tok.filename, tok.line, tok.col, source == MessageSource.Parser ? ErrorCategory.ParseWarning : ErrorCategory.ResolveWarning, msg); break; case ErrorLevel.Info: // The AllMessages variable already keeps track of this break; } return(true); } else { return(false); } }
public void ProcessGroupMessage(GroupEndPoint endPoint, MessageSource source, string message) { Task.Run(async() => { try { if (await UpdateUserBandingAsync(endPoint.GroupId, source.FromQq, message)) { return; } if (await WhirIsBestAsync(endPoint.GroupId, source.FromQq, message)) { return; } if (ListUnbind(endPoint.GroupId, source.FromQq, message)) { return; } await TestInGroupNameAsync(endPoint.GroupId, source.FromQq, message); } catch (Exception e) { Logger.LogException(e); } }); }
public string Parse(MessageSource sender, CommandArgs args) { if(args.Args.Count != 2) { return String.Format("Error - Usage {0} <stream-name> <stream-url>", args.Name); } var name = args.Args[0]; var url = args.Args[1]; Logger.InfoFormat("{0} is adding a new stream. {1} - {2}", sender, name, url); if(_handler.GetStream(name) != null) { return "Error - A streamer already exists with that name"; } if( !_handler.AddStream(name, url) ) { // Yeah yeah, it's hacky. _handler.RemoveAll(a => a.Name == name); return "Error - The URL provided can not be handled by any stream plugins."; } _settings.AddStream(name, url); Logger.InfoFormat("{0} added a new stream. {1} - {2}", sender, name, url); return string.Format("Success, {0} added as a new streamer", name); }
public static void OnMessage(MessageSource src, QMessage msg) { try { QMessage newMsg = msg; bool release = MiddlewareCore.OnMessage(ref src, ref newMsg); if (release) { int stat = ModuleCore.OnMessage(src, newMsg); ServiceCore.OnMessage(src, newMsg, msg, stat != -1, stat >= 0 ? ModuleCore.Modules[stat] : null); } } catch (Exception e) { StringBuilder sb = new(DateTime.Now.ToString()); sb.Append($"\nMessage: "); if (src.IsGroup) { sb.Append($"[{src.group!.ID}] "); } sb.Append($"[{src.user.ID}] "); sb.Append(msg); sb.Append($"\n{e}"); if (BotReg.GetBool("CORE/LOG_ERROR", true) && BotAuth.HasOwner) { _ = BotAPI.SendPrivateMessageAsync(BotAuth.Owner, new PlainMessage(sb.ToString())); } sb.Append("\n\n"); File.AppendAllText(AppDomain.CurrentDomain.BaseDirectory + "/log_error.txt", sb.ToString()); } }
// This method required by the Parser internal void Error(MessageSource source, string filename, int line, int col, string msg) { var tok = new Token(line, col); tok.filename = filename; Error(source, tok, msg); }
public void Error(MessageSource source, Expression e, string msg, params object[] args) { Contract.Requires(e != null); Contract.Requires(msg != null); Contract.Requires(args != null); Error(source, e.tok, msg, args); }
public void Error(MessageSource source, Statement s, string msg, params object[] args) { Contract.Requires(s != null); Contract.Requires(msg != null); Contract.Requires(args != null); Error(source, s.Tok, msg, args); }
public void Error(MessageSource source, NonglobalVariable v, string msg, params object[] args) { Contract.Requires(v != null); Contract.Requires(msg != null); Contract.Requires(args != null); Error(source, v.tok, msg, args); }
internal SocketMessage(DiscordSocketClient discord, ulong id, ISocketMessageChannel channel, SocketUser author, MessageSource source) : base(discord, id) { Channel = channel; Author = author; Source = source; }
public void Error(MessageSource source, Declaration d, string msg, params object[] args) { Contract.Requires(d != null); Contract.Requires(msg != null); Contract.Requires(args != null); Error(source, d.tok, msg, args); }
public MessageWrapper(MessageSource msgSource, string command, string data) { this.Source = msgSource; this.Command = command; this.Data = data; this.Status = MessageStatus.OK; }
public string Parse(MessageSource sender, CommandArgs args) { Console.WriteLine(args.Args.Count); if (args.Args.Count < 1 || args.Args.Count > 2) { return String.Format("Error - Usage {0} <hostname> [permission]", args.Name); } string permission = "Operator"; if(args.Args.Count == 2) { permission = args.Args[1]; } var targetPermission = _settings.GetUserPermission(args.Args[0]); // A permission already exists for the target user if (targetPermission != null) { return "This hostname already has permissions attached."; } var perm = Permission.GetPermission(permission); if(perm == null) { return "No permission exists by that name"; } _settings.AddUserPermission(args.Args[0], perm); return String.Format("Added permissions for {0}.", args.Args[0]); }
public void Error(MessageSource source, IToken tok, string msg, params object[] args) { Contract.Requires(tok != null); Contract.Requires(msg != null); Contract.Requires(args != null); Error(source, tok, String.Format(msg, args)); }
public MessageEventArgs(NetUser from, string message, MessageSource source, string sourceInfo) { this.message = message; this.from = from; this.source = source; this.sourceInfo = sourceInfo; }
internal RestMessage(BaseDiscordClient discord, ulong id, IMessageChannel channel, IUser author, MessageSource source) : base(discord, id) { Channel = channel; Author = author; Source = source; }
public async Task TestSendAndReceiveMessage() { var lazyConnection = new Lazy <IConnection>(() => { var cf = new ConnectionFactory(); return(cf.CreateConnection("nats://192.168.99.100:32774")); // change to local Docker address:port that maps onto 4222 }, LazyThreadSafetyMode.ExecutionAndPublication); const string subjectPrefix = "Obvs.NATS.Tests"; var deserializers = new List <IMessageDeserializer <TestMessage> > { new JsonMessageDeserializer <TestMessage>() }; IMessageSerializer serializer = new JsonMessageSerializer(); var source = new MessageSource <TestMessage>(lazyConnection, subjectPrefix, deserializers); var publisher = new MessagePublisher <TestMessage>(lazyConnection, subjectPrefix, serializer); var subscription = source.Messages.ObserveOn(Scheduler.Default).Subscribe(Console.WriteLine); for (var i = 0; i < 10; i++) { await publisher.PublishAsync(new TestMessage { Id = i }); } await Task.Delay(TimeSpan.FromSeconds(1)); subscription.Dispose(); }
internal RpcMessage(DiscordRpcClient discord, ulong id, RestVirtualMessageChannel channel, RpcUser author, MessageSource source) : base(discord, id) { Channel = channel; Author = author; Source = source; }
public Message Receive(TimeSpan timeout) { Message message = null; if (DoneReceivingInCurrentState()) { return(null); } bool shouldFault = true; try { message = MessageSource.Receive(timeout); OnReceiveMessage(message); shouldFault = false; return(message); } finally { if (shouldFault) { if (message != null) { message.Close(); message = null; } Fault(); } } }
// This is the only thing that needs to be overriden public virtual bool Message(MessageSource source, ErrorLevel level, IToken tok, string msg) { bool discard = (ErrorsOnly && level != ErrorLevel.Error) || // Discard non-errors if ErrorsOnly is set (tok is TokenWrapper && !(tok is NestedToken) && !(tok is RefinementToken)); // Discard wrapped tokens, except for nested and refinement if (!discard) { AllMessages[level].Add(new ErrorMessage { token = tok, message = msg }); } return !discard; }
/// <summary>Initializes a new instance of the <see cref="Analysis"/> class.</summary> /// <param name="config">The config.</param> /// <param name="messageSource">Source for the messages.</param> public Analysis([NotNull] IConfig config, MessageSource messageSource) { Code.NotNull(config, nameof(config)); DebugEnumCode.Defined(messageSource, nameof(messageSource)); RunState = CompetitionCore.RunState[config]; MessageSource = messageSource; }
public void Get() { int i = 0; ISource <int> source = new MessageSource <int>(() => 1, value => i = value); Assert.Equal(1, source.Value); }
public MessageReceivedEvent(DateTime timestamp, string from, MessageSource source, bool player, MessageChannel channel, string message) : base(timestamp, NAME) { this.from = from; Source = source; this.player = player; Channel = channel; this.message = message; }
public void Dispose() { if (MessageSource != null) { MessageSource.MessageReceived -= MessageSource_MessageReceived; MessageSource.Dispose(); } }
/// <summary>Initializes a new instance of the <see cref="Analysis"/> class.</summary> /// <param name="id">The identifier.</param> /// <param name="summary">The summary.</param> /// <param name="messageSource">Source for the messages.</param> public ResultAnalysis([NotNull] string id, [NotNull] Summary summary, MessageSource messageSource) : base(summary.Config, messageSource) { Code.NotNullNorEmpty(id, nameof(id)); Id = id; Summary = summary; }
public void Get() { int i = 0; ISource<int> source = new MessageSource<int>(() => 1, value => i = value); Assert.Equal(1, source.Value); }
public NetworkMessage(Type messageType, uint cmdID, ulong timeStamp, uint serial, MessageSource source) { this.messageType = messageType; this.cmdId = cmdID; TimeStamp = timeStamp; this.serial = serial; this.source = source; }
public static bool Enumerable(MessageSource src, object?result) { if (result is not IEnumerable meeting) { return(false); } Meeting.Start(src, meeting); return(true); }
public static bool StringBuilder(MessageSource src, object?result) { if (result is not StringBuilder res || res.Length <= 0) { return(false); } src.Send(res.ToString()); return(true); }
public string Parse(MessageSource source, CommandArgs args) { if (_filter(source)) { return _command.Parse(source, args); } return ErrorText; }
public void WriteMessage( MessageSource messageSource, MessageSeverity messageSeverity, [NotNull] string messageFormat, params object[] args) { var message = args.IsNullOrEmpty() ? messageFormat : string.Format(EnvironmentInfo.MainCultureInfo, messageFormat, args); WriteMessage(messageSource, messageSeverity, message); }
public void Set() { int i = 0; ISource <int> source = new MessageSource <int>(() => 1, value => i = value); source.Value = 2; Assert.Equal(2, i); }
/// <summary> /// Returns message for the specified resource name. /// </summary> /// <param name="name">Resource name.</param> /// <returns>Message text.</returns> public string GetProgramMessage(string name) { if (this.EnableInsertControlCache) { this.CheckTranslateSymbolAndSaveToDatabase(name); } name = string.Format("{0}|;;|{1}", this.ProgramCode, name); return(MessageSource.GetMessage(name, UserCulture)); }
public void DeprecatedStyle(MessageSource source, IToken tok, string msg, params object[] args) { Contract.Requires(tok != null); Contract.Requires(msg != null); Contract.Requires(args != null); if (DafnyOptions.O.DeprecationNoise == 2) { Warning(source, tok, String.Format(msg, args)); } }
public void Set() { int i = 0; ISource<int> source = new MessageSource<int>(() => 1, value => i = value); source.Value = 2; Assert.Equal(2, i); }
private static void LogThreadLoop() { // Read from the logging queue. bool readLine = _loggingQueue.TryDequeue(out Tuple <MessageType, MessageSource, string> nextLog); if (!readLine) { return; } MessageType type = nextLog.Item1; MessageSource source = nextLog.Item2; string message = nextLog.Item3; // Change the color of the log depending on the type. switch (type) { case MessageType.Error: Console.ForegroundColor = ConsoleColor.Red; break; case MessageType.Info: Console.ForegroundColor = ConsoleColor.Cyan; break; case MessageType.Trace: Console.ForegroundColor = ConsoleColor.White; break; case MessageType.Warning: Console.ForegroundColor = ConsoleColor.Yellow; break; default: Console.ForegroundColor = ConsoleColor.Gray; break; } // Check if highlighted. if (source == _highlighted) { Console.ForegroundColor = ConsoleColor.Magenta; } // Log and display the message. _logger.Log("[" + type + "-" + source + "] " + message); if (type != MessageType.Trace) { Console.WriteLine("[" + source + "] " + message); } // Restore the normal color. Console.ForegroundColor = ConsoleColor.Gray; Console.BackgroundColor = ConsoleColor.Black; }
public string Parse(MessageSource sender, CommandArgs args) { var ret = string.Join(", ", _instance.GetPermissions().Where(_predicate).Select(x => x.Nickname ?? ("@" + x.Hostname))); if(string.IsNullOrWhiteSpace(ret)) { return ErrorMessage; } return String.Format(Format, ret); }
public string Parse(MessageSource sender, CommandArgs args) { var ret = string.Join(", ", _handler.Matching(_predicate).Select(x => x.Name)); if(string.IsNullOrWhiteSpace(ret)) { return ErrorMessage; } return String.Format(Format, ret); }
public string Parse(MessageSource sender, CommandArgs args) { if (args.Args.Count == 1) { var name = args.Args[0]; var resp = _handler.RemoveAll(a => a.Name == name) > 0 ? "Deleted " + name : "No streamer exists by that name"; _settings.RemoveStream(name); return resp; } return string.Format("Error - Usage {0} <streamer-name>", args.Name); }
public static void LogWriteLineinHTML(string msg, MessageSource source, string exception, messageType msgType) { lock (Obj) { if (!Directory.Exists(folderPath)) Directory.CreateDirectory(folderPath); string header = "<html><title>CommitCRM integration with Repairshopr </title><head><head><body><div align='center'><h1> CommitCRM integration with Repairshopr </h1></div><table border=\"1\" style=\"width:100%\"><tr><th>Date Time</th><th>Source</th><th>Log Level </th><th>Message</th><th>Exception </th><tr>"; string message = null;//string.Format("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3} </td><td>{4}</td></tr>", DateTime.Now, source, msgType, msg, exception); if (msgType == messageType.Error) { message = string.Format("<tr><td><font color='red'><b>{0}</b></font></td><td><font color='red'><b>{1}</b></font></td><td><font color='red'><b>{2}</b></font></td><td><font color='red'><b>{3}</b></font> </td><td><font color='red'><b>{4}</b></font></td></tr>", DateTime.Now, source, msgType, msg, exception); } else if(source==MessageSource.Complete) { message = string.Format("<tr><td><font color='Green'><b>{0}</b></font></td><td><font color='Green'><b>{1}</b></font></td><td><font color='Green'><b>{2}</b></font></td><td><font color='Green'><b>{3}</b></font> </td><td><font color='Green'><b>{4}</b></font></td></tr>", DateTime.Now, source, msgType, msg, exception); } else { message = string.Format("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3} </td><td>{4}</td></tr>", DateTime.Now, source, msgType, msg, exception); } if (File.Exists(path)) { FileInfo fl = new FileInfo(path); long size = fl.Length; if (ConvertBytesToMegabytes(size) > 3) { path = folderPath + "\\" + string.Format("RepairshoprLog_{0}_{1}.Html", DateTime.Today.Date.ToString("dd/MM/yyyy").Replace("/", "_"), sufix);//Path.Combine(folderPath, "KarmaCRMLog.Html"); sufix++; } } if (!File.Exists(path)) { using (StreamWriter sw = File.CreateText(path)) { //Creating file with new Content. sw.WriteLine(string.Format("{0}", header)); sw.WriteLine(string.Format("{0}", message)); } } else { using (StreamWriter sw = File.AppendText(path)) { sw.WriteLine(string.Format("{0}", message)); } } } }
public string Parse(MessageSource sender, CommandArgs args) { if (args.Args.Count != 1) { return String.Format("Error - Usage {0} <hostname>", args.Name); } if (_settings.RemoveUserPermission(args.Args[0])) { return String.Format("Removed permissions for {0}.", args.Args[0]); } return string.Format("{0} does not have any permissions attached", args.Args[0]); }
public override bool Message(MessageSource source, ErrorLevel level, IToken tok, string msg) { if (base.Message(source, level, tok, msg) && ((DafnyOptions.O != null && DafnyOptions.O.PrintTooltips) || level != ErrorLevel.Info)) { // Extra indent added to make it easier to distinguish multiline error messages for clients that rely on the CLI msg = msg.Replace(Environment.NewLine, Environment.NewLine + " "); ConsoleColor previousColor = Console.ForegroundColor; Console.ForegroundColor = ColorForLevel(level); Console.WriteLine(ErrorToString(level, tok, msg)); Console.ForegroundColor = previousColor; return true; } else { return false; } }
public string Parse(MessageSource sender, CommandArgs args) { var stream = _handler.GetStream(sender.Nickname); if(stream == null) { return "Sorry you don't seem to own a stream."; } stream.Subject = args.Full; _handler.StreamSubjectChange(stream); if(string.IsNullOrWhiteSpace(args.Full)) { return "Cleared streaming subject"; } return null; }
public string Parse(MessageSource sender, CommandArgs args) { if(args.Args.Count != 1) { return string.Format("Error - Usage {0} <stream-name>", args.Name); } var stream = _handler.GetStream(args.Args[0]); if(stream == null) { return "No streamer by that name exists"; } var subject = ""; if(!string.IsNullOrWhiteSpace(stream.Subject)) { subject = " - Streaming: " + stream.Subject; } return string.Format("{0} - {1} - {2}{3}", stream.Name, stream.Url, stream.Online ? "Online" : "Offline", subject); }
public virtual void SendMessage(Character sender, string message, MessageType type = MessageType.Chat, MessageSource source = MessageSource.Local) { PushMessage(sender, message); }
public override void SendMessage(Character sender, string message, MessageType type = MessageType.Chat, MessageSource source = MessageSource.Local) { if (source == MessageSource.Local && type == MessageType.Chat) Character.SendMessage(message); PushMessage(sender, message, type, source); }
public MessageArgsLogger(MessageSource messageSource, string logMessage) { this.MessageSource = messageSource; this.LogMessage = logMessage; }
// This method required by the Parser internal void Error(MessageSource source, string filename, int line, int col, string msg) { var tok = new Token(line, col); tok.filename = filename; Error(source, tok, msg); }
public void AddMessage(MessageSource source, String msg) { if (!MessageBlock.Dispatcher.CheckAccess()) { AddMessageDelegate del = new AddMessageDelegate(AddMessage); MessageBlock.Dispatcher.Invoke(del, new object[] { source, msg }); } else { String adding = ""; switch (source) { case MessageSource.Info: adding += "[INFO] " + msg; break; case MessageSource.Local: adding += "[LOCAL] " + msg; break; case MessageSource.Error: adding += "[ERROR] " + msg; break; case MessageSource.Remote: adding += "[REMOTE] " + msg; break; default: break; } adding += "\n"; MessageBlock.AppendText(adding); MessageBlock.CaretIndex = MessageBlock.Text.Length; MessageBlock.ScrollToEnd(); //MessageBlock.Text += adding; } }
public static MessageWrapper Parse(string message, MessageSource msgSource) { //LST_OPER_TYPE|OK|20101118191412|BEMP12001|....... string[] result = KeepSocketOption.ME.Spliter.Split(message); //第1个域,命令字 if (result.Length <= 0 || string.IsNullOrEmpty(result[0])) return null; MessageWrapper wrapper = new MessageWrapper(); wrapper.Source = msgSource; wrapper.Command = result[0]; //第2个域,可能是“OK”,“ERR” if (result.Length <= 1) return wrapper; if (result[1].Equals("ERR")) wrapper.Status = MessageStatus.ERROR; else if (result[1].Equals("OK")) wrapper.Status = MessageStatus.OK; else { try { wrapper.Status = (MessageStatus)Enum.Parse(typeof(MessageStatus), result[1]); } catch (Exception e) { wrapper.Status = MessageStatus.ERROR; } } //第3个域,可能是“OK”,“ERR” if (result.Length <= 2) return wrapper; wrapper._TimeTicks = result[2].Trim(); //第4个域,本次交易(对话)的ID if (result.Length <= 3) return wrapper; wrapper._TalkId = result[3].Trim(); //第5个域,实际数据 if (result.Length <= 4) return wrapper; //实际数据的具体解析交由Protocol组件中的解析器去解析 wrapper.Data = result[4].Trim().TrimEnd('@'); return wrapper; }
private void LoadMessageToSource(MessageSource source, JToken message, string cloudId) { message["orgcontent"] = message["content"] = message["content"].ToString().UnescapeLiteral().RegexReplace(@"[ ]+", " "); lock (source) { JToken lastMsg; if (source.Messages.Any() && (string) (lastMsg = source.Messages.Last())["author"]["id"] == (string) message["author"]["id"] && !lastMsg["orgcontent"].ToString().StartsWith("/me") && !message["content"].ToString().StartsWith("/me")) { lastMsg["content"] += "\n" + message["content"]; lastMsg["drops"] = new JArray(lastMsg["drops"].Concat(message["drops"])); source.Messages.RemoveAt(source.Messages.Count - 1); source.Messages.Add(lastMsg); } else { message["content"] = message["content"] .ToString().RegexReplace("^/me", (string) message["author"]["name"]); source.AddMessage(message); } if (LoggedIn) { NotificationControl.ShowSimple(cloudId, (string)message["author"]["id"]); } } }
public MessageEventArgs(NetUser from, string message, MessageSource source) : this(from,message,source,null) { }
public override void SendMessage(Character sender, string message, MessageType type = MessageType.Chat, MessageSource source = MessageSource.Local) { if (source == MessageSource.Local) switch (type) { case MessageType.Chat: Channel.SendMessage(message); break; case MessageType.LFRP: Channel.SendLFRP(message); break; case MessageType.Roll: Channel.SendRoll(message); return; } PushMessage(sender, message, type, source); }
public void Warning(MessageSource source, IToken tok, string msg) { Contract.Requires(tok != null); Contract.Requires(msg != null); Message(source, ErrorLevel.Warning, tok, msg); }
public void PushMessage(Character sender, string message, MessageType type = MessageType.Chat, MessageSource source = MessageSource.Local, DateTime? timestamp = null) { lock (this) { _Messages.Add(new MessageData { Timestamp = timestamp ?? DateTime.Now, Sender = sender, RawMessage = new Parser { Validity = NodeValidity.FChat }.ParseMessage(message), Type = type, Source = source }); while (_Messages.Count >= MaxMessages) _Messages.RemoveAt(0); } OnMessage?.Invoke(this, _Messages.Last()); }
public void Warning(MessageSource source, IToken tok, string msg, params object[] args) { Contract.Requires(tok != null); Contract.Requires(msg != null); Warning(source, tok, String.Format(msg, args)); }