public bool Attach(MessageVector MV) { if (IsDead()) { throw new Exceptions.SimObjectPointerInvalidException(); } return(InternalUnsafeMethods.GuiMessageVectorCtrlAttach(ObjectPtr->ObjPtr, MV.ObjectPtr->ObjPtr)); }
public void AddLine(string text) { int textHeight = console.GetVarInt(string.Format("{0}.profile.fontSize", this)) + console.GetVarInt(string.Format("{0}.lineSpacing", this)); if (textHeight <= 0) { textHeight = 12; } string scrollBox = getGroup(); //See if the two are eqaul, and if they are use the split instead of the getword. //int chatScrollHeight = Util.getWord(con.GetVarString(string.Format("{0}.extent", scrollBox)), 1).AsInt() - // 2 * con.GetVarInt(string.Format("{0}.profile.borderThickness", scrollBox)); int chatScrollHeight = console.GetVarString(string.Format("{0}.extent", scrollBox)).Split(' ')[1].AsInt() - 2 * console.GetVarInt(string.Format("{0}.profile.borderThickness", scrollBox)); int chatPosition = Util.getWord(console.GetVarString(string.Format("{0}.extent", this)), 1).AsInt() - chatScrollHeight + Util.getWord(console.GetVarString(string.Format("{0}.position", this)), 1).AsInt() - console.GetVarInt(string.Format("{0}.profile.borderThickness", scrollBox)); int linesToScroll = (int)Math.Floor(((chatPosition) / ((double)textHeight) + .5)); string origPosition = ""; if (linesToScroll > 0) { origPosition = console.GetVarString(string.Format("{0}.position", this)); } GuiButtonCtrl chatPageDown = "chatPageDown"; MessageVector HudMessageVector = "HudMessageVector"; //remove old messages from the top only if scrolled down all the way while (!chatPageDown.isVisible() && HudMessageVector.getNumLines() > 0 && HudMessageVector.getNumLines() >= iGlobal["$pref::HudMessageLogSize"]) { string tag = ((MessageVector)"HudMessageVector").getLineTag(0).AsString(); if (tag.AsInt() != 0) { tag.delete(); } ((MessageVector)"HudMessageVector").popFrontLine(); } //add the message... ((MessageVector)"HudMessageVector").pushBackLine(text, console.GetVarInt("$LastHudTarget")); console.SetVar("$LastHudTarget", 0); //now that we've added the message, see if we need to reset the position if (linesToScroll > 0) { ((GuiControl)"ChatPageDown").setVisible(true); console.SetVar(this + ".position", origPosition); } else { ((GuiControl)"ChatPageDown").setVisible(false); } }
public int predict(string pyLocation, MessageVector mv) { string args = (path + pyNeuralPredictorPath + " " + path + neuralclf + " " + string.Format("{0},{1},{2},{3},{4}", mv.CharsToLim.ToString().Replace(',', '.'), mv.CapsToChars.ToString().Replace(',', '.'), mv.NonAlphaToChars.ToString().Replace(',', '.'), mv.UnintelligibilityLevel.ToString().Replace(',', '.'), mv.EmotesToWords.ToString().Replace(',', '.'))) + " " + path + "\\tempPredict.txt"; ProcessStartInfo start = new ProcessStartInfo(); start.FileName = pyLocation; start.Arguments = args; start.UseShellExecute = false; start.RedirectStandardOutput = false; start.RedirectStandardError = false; Process process = Process.Start(start); Thread.Sleep(1000); return(Convert.ToInt16(File.ReadAllText(path + "\\tempPredict.txt"))); }
public MessageVector messageVector(ChatMessage cm, double UnintelligibilityLevel) { MessageVector Vector = new MessageVector(); double CharCount = Convert.ToDouble(cm.Message.Length); double AlphaCount = Convert.ToDouble(cm.Message.Count(c => char.IsLetter(c))); double CapsCount = Convert.ToDouble(cm.Message.Count(c => char.IsLetter(c) & char.IsUpper(c))); double WordCount = Convert.ToDouble(cm.Message.Split(' ').Count()); double EmoteCount = Convert.ToDouble(cm.EmoteSet.Emotes.Count()); Vector.CharsToLim = CharCount / 500; Vector.CapsToChars = CapsCount / CharCount; Vector.NonAlphaToChars = (CharCount - AlphaCount) / CharCount; Vector.UnintelligibilityLevel = UnintelligibilityLevel; return(Vector); }
private void onMessageReceieved(object sender, OnMessageReceivedArgs e, string pyLocation, Socket socket, pyCalc calc) { double unintelligibleProbability = calc.tcpUnintelligibilityProbability(e.ChatMessage.Message, socket); isFirst = false; MessageVector msgVector = new MessageVector(); MessageVectorGenerator msgGen = new MessageVectorGenerator(); msgVector = msgGen.messageVector(e.ChatMessage, unintelligibleProbability); int prediction = calc.predict(pyLocation, msgVector); if (prediction == 1) { client.SendMessage(e.ChatMessage.Channel, string.Format("stop, {0}", e.ChatMessage.DisplayName)); } }
/// <summary> /// Delivers a single message, calling the SendMessage method of all appropriate /// Mobs in both the actor's and target's rooms ("appropriate" determined by /// messageType). /// </summary> /// <param name="actor">Mob performing the narrated action (if any!)</param> /// <param name="target">Mob receiving the narrated action (if any!)</param> /// <param name="messageType">Vector for the message (who it is sent to)</param> /// <returns>false if any error conditions are met or any messages fail to send</returns> public static bool DeliverMessage(Mob actor, Mob target, MessageVector messageType, String message, String mobileMessage) { // Early exit conditions if (message == null || message.Equals("")) return false; if (actor == null && target == null) return false; if (messageType == MessageVector.NotCharacter && actor == null) return false; if (messageType == MessageVector.NotTarget && target == null) return false; bool returner = true; // Format all of the $ arguments in message message = formatMessage(actor, target, message, mobileMessage); // Handle the easy ones first: Character & Target; no need to loop for these. if (messageType == MessageVector.Character) { if (actor == null) return false; return actor.SendMessage(message, mobileMessage); } else if (messageType == MessageVector.Target) { if (target == null) return false; return target.SendMessage(message, mobileMessage); } // Now we loop through the contents of the room. if (actor != null) { if (((Room)actor.Location) != null && ((Room)actor.Location).Contents != null) { foreach (Mob audience in ((Room)actor.Location).Contents) { if (messageType == MessageVector.NotCharacter && audience == actor) continue; if (messageType == MessageVector.NotTarget && audience == target) continue; if (messageType == MessageVector.ThirdParty && (audience == actor || audience == target)) continue; if (audience.SendMessage(message, mobileMessage) == false) returner = false; } } else { return false; } } // If the actor is null (for whatever reason) or the target is in a different room, we // need to display the message to the appropriate audience in the target's room. if (target != null && (actor == null || ((Room)target.Location).IndexNumber != ((Room)actor.Location).IndexNumber)) { if (((Room)target.Location) != null && ((Room)target.Location).Contents != null) { foreach (Mob audience in ((Room)target.Location).Contents) { if (messageType == MessageVector.NotCharacter && audience == actor) continue; if (messageType == MessageVector.NotTarget && audience == target) continue; if (messageType == MessageVector.ThirdParty && (audience == actor || audience == target)) continue; if (audience.SendMessage(message, mobileMessage) == false) returner = false; } } else { return false; } } return returner; }
/// <summary> /// Delivers a single message, calling the SendMessage method of all appropriate /// Mobs in both the actor's and target's rooms ("appropriate" determined by /// messageType). /// </summary> /// <param name="actor">Mob performing the narrated action (if any!)</param> /// <param name="target">Mob receiving the narrated action (if any!)</param> /// <param name="messageType">Vector for the message (who it is sent to)</param> /// <returns>false if any error conditions are met or any messages fail to send</returns> public static bool DeliverMessage(Mob actor, Mob target, MessageVector messageType, String message, String mobileMessage) { // Early exit conditions if (message == null || message.Equals("")) { return(false); } if (actor == null && target == null) { return(false); } if (messageType == MessageVector.NotCharacter && actor == null) { return(false); } if (messageType == MessageVector.NotTarget && target == null) { return(false); } bool returner = true; // Format all of the $ arguments in message message = formatMessage(actor, target, message, mobileMessage); // Handle the easy ones first: Character & Target; no need to loop for these. if (messageType == MessageVector.Character) { if (actor == null) { return(false); } return(actor.SendMessage(message, mobileMessage)); } else if (messageType == MessageVector.Target) { if (target == null) { return(false); } return(target.SendMessage(message, mobileMessage)); } // Now we loop through the contents of the room. if (actor != null) { if (actor.Room != null && actor.Room.Contents != null) { foreach (Mob audience in actor.Room.Contents) { if (messageType == MessageVector.NotCharacter && audience == actor) { continue; } if (messageType == MessageVector.NotTarget && audience == target) { continue; } if (messageType == MessageVector.ThirdParty && (audience == actor || audience == target)) { continue; } if (audience.SendMessage(message, mobileMessage) == false) { returner = false; } } } else { return(false); } } // If the actor is null (for whatever reason) or the target is in a different room, we // need to display the message to the appropriate audience in the target's room. if (target != null && (actor == null || target.Room.IndexNumber != actor.Room.IndexNumber)) { if (target.Room != null && target.Room.Contents != null) { foreach (Mob audience in target.Room.Contents) { if (messageType == MessageVector.NotCharacter && audience == actor) { continue; } if (messageType == MessageVector.NotTarget && audience == target) { continue; } if (messageType == MessageVector.ThirdParty && (audience == actor || audience == target)) { continue; } if (audience.SendMessage(message, mobileMessage) == false) { returner = false; } } } else { return(false); } } return(returner); }