private void Eval_Redirect(TCPPacketReader packet, uint time) { if (Settings.GetReg <bool>("block_redirect", false)) { return; } Redirect redirect = new Redirect(); redirect.IP = packet; redirect.Port = packet; packet.SkipBytes(4); redirect.Name = packet.ReadString(this.crypto); redirect.Hashlink = Hashlink.EncodeHashlink(redirect); if (ScriptEvents.OnRedirecting(this, redirect)) { this.Credentials.IP = redirect.IP; this.Credentials.Port = redirect.Port; this.Credentials.Name = redirect.Name; this.ticks = (time - 19); this.state = SessionState.Sleeping; this.sock.Disconnect(); this.Panel.AnnounceText(StringTemplate.Get(STType.Messages, 15).Replace("+x", redirect.Name)); } }
private void Eval_Part(TCPPacketReader packet) { String name = packet.ReadString(this.crypto); User u = this.users.Find(x => x.Name == name); this.users.RemoveAll(x => x.Name == name); if (u != null) { if (u.Writing) { u.Writing = false; this.Panel.UpdateWriter(u); } this.Panel.Userlist.RemoveUserItem(u); if (ScriptEvents.OnUserParting(this, u)) { this.Panel.AnnounceText(GlobalSettings.GetDefaultColorString(GlobalSettings.DefaultColorType.Part, this.BlackBG) + StringTemplate.Get(STType.Messages, 12).Replace("+x", u.Name)); } ScriptEvents.OnUserParted(this, u); Scripting.ScriptManager.RemoveUser(this.EndPoint, u); u.Dispose(); u = null; } }
private void Eval_Avatar(TCPPacketReader packet) { String name = packet.ReadString(this.crypto); User u = this.users.Find(x => x.Name == name); if (u != null) { if (!ScriptEvents.OnUserAvatarReceiving(this, u)) { return; } byte[] data = packet; if (data.Length <= 10) { u.ClearAvatar(); } else { u.SetAvatar(data); } this.Panel.Userlist.UpdateUserAppearance(u); } }
private void Eval_VC_PM_First(TCPPacketReader packet) { VoicePlayerInboundItem item = new VoicePlayerInboundItem(packet, this.crypto, this.EndPoint); VoicePlayer.Inbound.RemoveAll(x => x.Ident == item.Ident && x.EndPoint.Equals(this.EndPoint)); if (item.Received) { item.Save(); if (!String.IsNullOrEmpty(item.FileName)) { VoicePlayerItem vc = item.ToVoicePlayerItem(++VoicePlayer.NEXT_SHORTCUT, this.BlackBG); VoicePlayer.Records.Add(vc); User u = this.users.Find(x => x.Name == vc.Sender); if (u != null) { if (!u.Ignored) { if (ScriptEvents.OnVoiceClipReceiving(this, u, true)) { this.Panel.PMTextReceived(this, u, vc.Sender, GlobalSettings.GetDefaultColorString(GlobalSettings.DefaultColorType.Server, this.BlackBG) + "--- \\\\voice_clip_#" + vc.ShortCut + " " + StringTemplate.Get(STType.Messages, 8).Replace("+x", vc.Sender), null, PMTextReceivedType.Announce); ScriptEvents.OnVoiceClipReceived(this, u, true); } } } } } else { VoicePlayer.Inbound.Add(item); } }
private void Eval_Emote(TCPPacketReader packet) { String name = packet.ReadString(this.crypto); String text = packet.ReadString(this.crypto); User u = this.users.Find(x => x.Name == name); AresFont font = null; if (u != null) { if (u.Ignored) { return; } if (u.Font != null) { font = u.Font; } } text = ScriptEvents.OnEmoteReceiving(this, name, text); if (!String.IsNullOrEmpty(text)) { this.Panel.EmoteText(name, text, font); this.Panel.CheckUnreadStatus(); ScriptEvents.OnEmoteReceived(this, name, text); } }
private void Eval_Scribble(User user) { byte[] data = user.ScribbleBuffer.ToArray(); user.ScribbleBuffer = new List <byte>(); if (Settings.GetReg <bool>("receive_scribbles", true) && !user.Ignored) { if (ScriptEvents.OnScribbleReceiving(this, user)) { data = Zip.Decompress(data); if (user.Name == this.users[0].Name) { this.Panel.Scribble(data); } else if (!user.Ignored) { this.Panel.PMScribbleReceived(this, user, user.Name, data); } else { return; } this.Panel.CheckUnreadStatus(); ScriptEvents.OnScribbleReceived(this, user); } } }
public static void AddRoom(IPEndPoint ep, FavouritesListItem creds) { foreach (JSScript script in Scripts) { script.Rooms.Add(new Objects.JSRoom(script.JS.Object.InstancePrototype, ep, creds)); } ScriptEvents.OnRoomOpened(ep); }
private void Eval_Font(TCPPacketReader packet) { String name = packet.ReadString(this.crypto); User u = this.users.Find(x => x.Name == name); if (u != null) { if (packet.Remaining > 2) { AresFont f = new AresFont(); f.Size = (int)((byte)packet); f.FontName = packet.ReadString(this.crypto); byte oldN = packet; byte oldT = packet; if (oldN == 255 || oldT == 255) { u.Font = null; return; } if (this.new_sbot) { if (packet.Remaining > 0) { f.NameColor = packet.ReadString(this.crypto); } if (packet.Remaining > 0) { f.TextColor = packet.ReadString(this.crypto); } } if (String.IsNullOrEmpty(f.NameColor)) { f.NameColor = Helpers.AresColorToHTMLColor(oldN); } if (String.IsNullOrEmpty(f.TextColor)) { f.TextColor = Helpers.AresColorToHTMLColor(oldT); } if (ScriptEvents.OnUserFontChanging(this, u, f)) { u.Font = f; } } else { u.Font = null; } } }
public void Load(Script script) { var source = Engine.CreateScriptSourceFromString(script.Source); try { var compiled = source.Compile(); compiled.Execute(Scope); ScriptEvents.Load(script); } catch (Exception e) { this.Log(e.Message); } }
internal void PMScribbleReceived(Room room, User user, String name, byte[] data) { this.tabControl1.BeginInvoke((Action)(() => { for (int i = 0; i < this.tabControl1.TabPages.Count; i++) { if (this.tabControl1.TabPages[i] is PMTab) { if (this.tabControl1.TabPages[i].Text == name) { PMTab tab = (PMTab)this.tabControl1.TabPages[i]; tab.Scribble(data); tab.SetRead(this.Mode == ScreenMode.PM && this.PMName == name); if (!tab.First) { tab.First = true; if (room != null && user != null) { ScriptEvents.OnPmFirstReceived(room, user); } } return; } } } PMTab new_tab = new PMTab(name, this.EndPoint); if (this.IsBlack) { new_tab.SetToBlack(); } new_tab.HashlinkClicked += this.LinkHashlinkClicked; new_tab.EditScribbleClicked += this.DoEditScribbleClicked; new_tab.ImageIndex = 2; this.tabControl1.TabPages.Add(new_tab); new_tab.Scribble(data); new_tab.First = true; if (room != null && user != null) { ScriptEvents.OnPmFirstReceived(room, user); } })); }
private void Eval_VC_Chunk(TCPPacketReader packet) { String sender = packet.ReadString(this.crypto); uint ident = packet; int index = VoicePlayer.Inbound.FindIndex(x => x.EndPoint.Equals(this.EndPoint) && x.Ident == ident); byte[] chunk = packet; if (index > -1) { VoicePlayerInboundItem item = VoicePlayer.Inbound[index]; item.AddChunk(chunk); if (item.Received) { VoicePlayer.Inbound.RemoveAt(index); item.Save(); if (!String.IsNullOrEmpty(item.FileName)) { VoicePlayerItem vc = item.ToVoicePlayerItem(++VoicePlayer.NEXT_SHORTCUT, this.BlackBG); VoicePlayer.Records.Add(vc); User u = this.users.Find(x => x.Name == vc.Sender); if (u != null) { if (!u.Ignored) { if (ScriptEvents.OnVoiceClipReceiving(this, u, false)) { if (this.CanAutoPlayVC) { vc.Auto = true; VoicePlayer.QueueItem(vc); } else { this.Panel.ShowVoice(vc.Sender, vc.ShortCut); } ScriptEvents.OnVoiceClipReceived(this, u, false); } } } } } } }
private void Eval_URL(TCPPacketReader packet) { String addr = packet.ReadString(this.crypto); String check = addr.ToUpper(); if (check.StartsWith("HTTP://") || check.StartsWith("ARLNK://") || check.StartsWith("WWW") || check.StartsWith("HTTPS://")) { String text = packet.ReadString(this.crypto); text = ScriptEvents.OnUrlReceiving(this, text, addr); if (!String.IsNullOrEmpty(text)) { this.Panel.SetURL(text, addr); } } }
/// <inheritdoc /> protected override int Execute(IInput input, IOutput output) { if (input.GetOption("list")) { return(ListScripts(output)); } string script = input.GetArgument("script"); if (string.IsNullOrEmpty(script)) { throw new RuntimeException("Missing required argument \"script\""); } var defiendEvents = new HashSet <string>(ScriptEvents.GetEvents()); var disabledScript = script.ToUpper().Replace("-", "_"); if (!defiendEvents.Contains(script) && defiendEvents.Contains(disabledScript)) { throw new RuntimeException($"Script \"{script}\" cannot be run with this command"); } var bucket = GetBucket(); var devMode = input.GetOption("dev") || !input.GetOption("no-dev"); var eventDispatcher = bucket.GetEventDispatcher(); if (!eventDispatcher.HasListener(script)) { throw new RuntimeException($"Script \"{script}\" is not defined in this package"); } string[] args = input.GetArgument("args"); string timeout = input.GetOption("timeout"); if (timeout != null) { BucketProcessExecutor.SetDefaultTimeout(int.Parse(timeout)); } var eventArgs = new ScriptEventArgs(script, bucket, GetIO(), devMode, args); eventDispatcher.Dispatch(this, eventArgs); return(eventArgs.ExitCode); }
private void Eval_VC_First(TCPPacketReader packet) { VoicePlayerInboundItem item = new VoicePlayerInboundItem(packet, this.crypto, this.EndPoint); VoicePlayer.Inbound.RemoveAll(x => x.Ident == item.Ident && x.EndPoint.Equals(this.EndPoint)); if (item.Received) { item.Save(); if (!String.IsNullOrEmpty(item.FileName)) { VoicePlayerItem vc = item.ToVoicePlayerItem(++VoicePlayer.NEXT_SHORTCUT, this.BlackBG); VoicePlayer.Records.Add(vc); User u = this.users.Find(x => x.Name == vc.Sender); if (u != null) { if (!u.Ignored) { if (ScriptEvents.OnVoiceClipReceiving(this, u, false)) { if (this.CanAutoPlayVC) { vc.Auto = true; VoicePlayer.QueueItem(vc); } else { this.Panel.ShowVoice(vc.Sender, vc.ShortCut); } ScriptEvents.OnVoiceClipReceived(this, u, false); } } } } } else { VoicePlayer.Inbound.Add(item); } }
private void Eval_PersonalMessage(TCPPacketReader packet) { String name = packet.ReadString(this.crypto); String text = packet.ReadString(this.crypto); if (!String.IsNullOrEmpty(text)) { text = Helpers.FormatAresColorCodes(text); } User u = this.users.Find(x => x.Name == name); if (u != null) { if (ScriptEvents.OnUserMessageReceiving(this, u, text)) { u.PersonalMessage = text; this.Panel.Userlist.UpdateUserAppearance(u); } } }
private void Eval_Topic(String text, bool updated) { String str = ScriptEvents.OnTopicReceiving(this, text); if (updated) { this.Panel.ServerText(StringTemplate.Get(STType.Messages, 11) + ": " + text); this.Credentials.Topic = text; this.Panel.SetTopic(text); } else if (!String.IsNullOrEmpty(str)) { this.Credentials.Topic = str; this.Panel.SetTopic(text); } if (this.should_check_for_current_topic_update) { this.should_check_for_current_topic_update = false; this.TopicChanged(this.Credentials, EventArgs.Empty); } }
private void Eval_Announce(TCPPacketReader packet) { String str = packet.ReadString(this.crypto); str = str.Replace("\r\n", "\0"); str = str.Replace("\r", "\0"); str = str.Replace("\n", "\0"); String[] lines = str.Split(new String[] { "\0" }, StringSplitOptions.None); String text; foreach (String l in lines) { text = l; text = ScriptEvents.OnAnnounceReceiving(this, text); if (text != null) { this.Panel.AnnounceText(text); ScriptEvents.OnAnnounceReceived(this, text); } } }
public virtual void ProcessObjectDeGrab(uint localID, IClientAPI remoteClient, List <SurfaceTouchEventArgs> surfaceArgs) { SurfaceTouchEventArgs surfaceArg = null; if (surfaceArgs != null && surfaceArgs.Count > 0) { surfaceArg = surfaceArgs[0]; } SceneObjectGroup obj = this.GetGroupByPrim(localID); // Is this prim part of the group if (obj != null && obj.HasChildPrim(localID)) { SceneObjectPart part = obj.GetChildPart(localID); SceneObjectGroup group = part.ParentGroup; if (part != null) { // If the touched prim handles touches, deliver it // If not, deliver to root prim ScriptEvents eventsThatNeedDegrab = (ScriptEvents.touch_end | ScriptEvents.touch); if ((part.ScriptEvents & eventsThatNeedDegrab) != 0) { EventManager.TriggerObjectDeGrab(part.LocalId, 0, remoteClient, surfaceArg); } else if ((group.RootPart.ScriptEvents & eventsThatNeedDegrab) != 0) { EventManager.TriggerObjectDeGrab(obj.RootPart.LocalId, part.LocalId, remoteClient, surfaceArg); } // Always send an object degrab. m_sceneGraph.DegrabObject(localID, remoteClient, surfaceArgs); return; } return; } }
private void Eval_Nudge(User user, byte[] data, uint time) { if (data.Length == 4) { if (data.SequenceEqual(new byte[] { 78, 65, 61, 61 })) { this.Panel.AnnounceText(GlobalSettings.GetDefaultColorString(GlobalSettings.DefaultColorType.Server, this.BlackBG) + "--- " + StringTemplate.Get(STType.Messages, 6).Replace("+x", user.Name)); return; } } if (Settings.GetReg <bool>("receive_nudge", true) && !user.Ignored) { if (time > this.last_nudge) { this.last_nudge = time; } else { return; } if (ScriptEvents.OnNudgeReceiving(this, user)) { this.Panel.AnnounceText(GlobalSettings.GetDefaultColorString(GlobalSettings.DefaultColorType.Server, this.BlackBG) + "--- " + StringTemplate.Get(STType.Messages, 5).Replace("+x", user.Name)); this.owner_frm.Nudge(); this.ShowPopup("cb0t :: " + StringTemplate.Get(STType.Messages, 3), StringTemplate.Get(STType.Messages, 5).Replace("+x", user.Name), PopupSound.None); } else { this.sock.Send(TCPOutbound.NudgeReject(user.Name, this.crypto)); } } else { this.sock.Send(TCPOutbound.NudgeReject(user.Name, this.crypto)); } }
private void Eval_cb0t_pm_msg(User user, byte[] data) { if (!Settings.GetReg <bool>("can_receive_pms", true)) { return; } String name = user.Name; String text = Encoding.UTF8.GetString(PMCrypto.SoftDecrypt(this.MyName, data)); User u = this.users.Find(x => x.Name == name); if (u == null) { return; } if (u.Ignored) { return; } AresFont font = null; if (u.Font != null) { font = u.Font; } text = ScriptEvents.OnPmReceiving(this, u, text); if (!String.IsNullOrEmpty(text)) { this.Panel.PMTextReceived(this, u, name, text, font, PMTextReceivedType.Text); this.Panel.CheckUnreadStatus(); ScriptEvents.OnPmReceived(this, u, text); } }
private void Eval_Private(TCPPacketReader packet) { if (!Settings.GetReg <bool>("can_receive_pms", true)) { return; } String name = packet.ReadString(this.crypto); String text = packet.ReadString(this.crypto); User u = this.users.Find(x => x.Name == name); if (u == null) { return; } AresFont font = null; if (u.Font != null) { font = u.Font; } if (u.Ignored) { return; } text = ScriptEvents.OnPmReceiving(this, u, text); if (!String.IsNullOrEmpty(text)) { this.Panel.PMTextReceived(this, u, name, text, font, PMTextReceivedType.Text); this.Panel.CheckUnreadStatus(); ScriptEvents.OnPmReceived(this, u, text); } }
private void Eval_UpdateUserStatus(TCPPacketReader packet) { String name = packet.ReadString(this.crypto); User u = this.users.Find(x => x.Name == name); if (u != null) { packet.SkipBytes(13); byte level = packet; if (u.Level != level) { byte before = u.Level; u.Level = level; this.Panel.Userlist.UpdateUserLevel(u, before); ScriptEvents.OnUserLevelChanged(this, u); } if (u.Name == this.MyName) { this.Panel.Userlist.MyLevel = u.Level; } } }
public Title(ScriptEvents events, string title, int time) { this.events = events; this.title = title; this.time = time; }
public void aggregateScriptEvents() { uint objectflagupdate = (uint)RootPart.GetEffectiveObjectFlags(); ScriptEvents aggregateScriptEvents = 0; lock (m_parts) { foreach (SceneObjectPart part in m_parts.Values) { if (part == null) continue; if (part != RootPart) part.ObjectFlags = objectflagupdate; aggregateScriptEvents |= part.AggregateScriptEvents; } } m_scriptListens_atTarget = (aggregateScriptEvents & ScriptEvents.at_target) != 0; m_scriptListens_notAtTarget = (aggregateScriptEvents & ScriptEvents.not_at_target) != 0; m_scriptListens_atRotTarget = (aggregateScriptEvents & ScriptEvents.at_rot_target) != 0; m_scriptListens_notAtRotTarget = (aggregateScriptEvents & ScriptEvents.not_at_rot_target) != 0; if (!(m_scriptListens_atTarget || m_scriptListens_notAtTarget)) { ClearTargetWaypoints(); } if (!(m_scriptListens_atRotTarget || m_scriptListens_notAtRotTarget)) { ClearRotWaypoints(); } m_aggregateScriptEvents = aggregateScriptEvents; ScheduleGroupForFullUpdate(); }
internal void PMTextReceived(Room room, User user, String name, String text, AresFont font, PMTextReceivedType type) { this.tabControl1.BeginInvoke((Action)(() => { for (int i = 0; i < this.tabControl1.TabPages.Count; i++) { if (this.tabControl1.TabPages[i] is PMTab) { if (this.tabControl1.TabPages[i].Text == name) { PMTab tab = (PMTab)this.tabControl1.TabPages[i]; if (type == PMTextReceivedType.Announce) { tab.Announce(text); if (text.Contains("voice_clip")) { tab.SetRead(this.Mode == ScreenMode.PM && this.PMName == name); } } else { tab.PM(name, text, font); tab.SetRead(this.Mode == ScreenMode.PM && this.PMName == name); if (!tab.AutoReplySent) { if (Settings.GetReg <bool>("can_pm_reply", true)) { this.SendAutoReply(name, EventArgs.Empty); String[] lines = Settings.GetReg <String>("pm_reply", "Hello +n, please leave a message.").Split(new String[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); AresFont f = null; if (Settings.MyFont != null) { f = Settings.MyFont.Copy(); } foreach (String str in lines) { String rtext = str.Replace("+n", name); if (!String.IsNullOrEmpty(rtext)) { while (Encoding.UTF8.GetByteCount(rtext) > 200) { rtext = rtext.Substring(0, rtext.Length - 1); } tab.PM(this.MyName, rtext, f); } } } tab.AutoReplySent = true; } } if (!tab.First) { tab.First = true; if (room != null && user != null) { ScriptEvents.OnPmFirstReceived(room, user); } } return; } } } PMTab new_tab = new PMTab(name, this.EndPoint); if (this.IsBlack) { new_tab.SetToBlack(); } new_tab.HashlinkClicked += this.LinkHashlinkClicked; new_tab.EditScribbleClicked += this.DoEditScribbleClicked; new_tab.ImageIndex = 2; this.tabControl1.TabPages.Add(new_tab); if (type == PMTextReceivedType.Announce) { new_tab.Announce(text); } else { new_tab.PM(name, text, font); if (Settings.GetReg <bool>("can_pm_reply", true)) { this.SendAutoReply(name, EventArgs.Empty); String[] lines = Settings.GetReg <String>("pm_reply", "Hello +n, please leave a message.").Split(new String[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); AresFont f = null; if (Settings.MyFont != null) { f = Settings.MyFont.Copy(); } foreach (String str in lines) { String rtext = str.Replace("+n", name); if (!String.IsNullOrEmpty(text)) { while (Encoding.UTF8.GetByteCount(rtext) > 200) { rtext = rtext.Substring(0, rtext.Length - 1); } new_tab.PM(this.MyName, rtext, f); } } } new_tab.AutoReplySent = true; new_tab.First = true; if (room != null && user != null) { ScriptEvents.OnPmFirstReceived(room, user); } } })); }
public FadeOut(ScriptEvents events, int time) { this.events = events; this.time = time; }
public ExecuteEvent(ScriptEvents events, Enum eventName) { this.events = events; this.eventName = eventName; }
public void aggregateScriptEvents() { uint objectflagupdate = (uint)RootPart.GetEffectiveObjectFlags(); ScriptEvents aggregateScriptEvents = 0; m_childParts.ForEachPart((SceneObjectPart part) => { if (part == null) return; if (part != RootPart) { // Preserve the Scripted flag status for each part. bool isScripted = (part.Flags & PrimFlags.Scripted) != 0; part.ObjectFlags = objectflagupdate; // update // Now restore the per-part Scripted flag. if (isScripted) part.ObjectFlags |= (uint)PrimFlags.Scripted; else part.ObjectFlags &= ~(uint)PrimFlags.Scripted; } aggregateScriptEvents |= part.AggregateScriptEvents; }); m_scriptListens_atTarget = (aggregateScriptEvents & ScriptEvents.at_target) != 0; m_scriptListens_notAtTarget = (aggregateScriptEvents & ScriptEvents.not_at_target) != 0; m_scriptListens_atRotTarget = (aggregateScriptEvents & ScriptEvents.at_rot_target) != 0; m_scriptListens_notAtRotTarget = (aggregateScriptEvents & ScriptEvents.not_at_rot_target) != 0; if (!(m_scriptListens_atTarget || m_scriptListens_notAtTarget)) { ClearTargetWaypoints(); } if (!(m_scriptListens_atRotTarget || m_scriptListens_notAtRotTarget)) { ClearRotWaypoints(); } m_aggregateScriptEvents = aggregateScriptEvents; ScheduleGroupForFullUpdate(PrimUpdateFlags.FindBest); }
private void CustomProtoReceived(TCPPacketReader packet, uint time) { String command = packet.ReadString(this.crypto); String sender = packet.ReadString(this.crypto); User u = this.users.Find(x => x.Name == sender); ulong lag; bool b; switch (command) { case "cb0t_writing": if (u == null) { return; } b = ((byte)packet) == 2; if (b != u.Writing) { u.Writing = b; this.Panel.UpdateWriter(u); ScriptEvents.OnUserWritingStatusChanged(this, u); } break; case "cb0t_latency_check": lag = (Helpers.UnixTimeMS - ((ulong)packet)); this.Panel.Userlist.UpdateLag(lag); break; case "cb0t_latency_mcheck": lag = (Helpers.UnixTimeMS - ((ulong)packet)); this.sock.Send(TCPOutbound.Public(StringTemplate.Get(STType.Messages, 7) + ": " + lag + " milliseconds", this.crypto)); break; case "cb0t_online_status": if (u == null) { return; } b = ((byte)packet) != 1; if (u.IsAway != b) { u.IsAway = b; this.Panel.Userlist.UpdateUserAppearance(u); ScriptEvents.OnUserOnlineStatusChanged(this, u); } break; case "cb0t_nudge": if (u == null) { return; } this.Eval_Nudge(u, ((byte[])packet), time); break; case "cb0t_pm_msg": if (u == null) { return; } this.Eval_cb0t_pm_msg(u, ((byte[])packet)); break; case "cb0t_scribble_once": if (u != null) { u.ScribbleBuffer = new List <byte>(); u.ScribbleBuffer.AddRange((byte[])packet); this.Eval_Scribble(u); } else if (String.IsNullOrEmpty(sender)) { this.unknown_scribble_buffer = new List <byte>(); this.unknown_scribble_buffer.AddRange((byte[])packet); this.Eval_Scribble_Unknown(); } break; case "cb0t_scribble_first": if (u != null) { u.ScribbleBuffer = new List <byte>(); u.ScribbleBuffer.AddRange((byte[])packet); } else if (String.IsNullOrEmpty(sender)) { this.unknown_scribble_buffer = new List <byte>(); this.unknown_scribble_buffer.AddRange((byte[])packet); } break; case "cb0t_scribble_chunk": if (u != null) { u.ScribbleBuffer.AddRange((byte[])packet); } else if (String.IsNullOrEmpty(sender)) { this.unknown_scribble_buffer.AddRange((byte[])packet); } break; case "cb0t_scribble_last": if (u != null) { u.ScribbleBuffer.AddRange((byte[])packet); this.Eval_Scribble(u); } else if (String.IsNullOrEmpty(sender)) { this.unknown_scribble_buffer.AddRange((byte[])packet); this.Eval_Scribble_Unknown(); } break; default: if (command.StartsWith("cb3_custom_")) { command = command.Substring(11); if (u != null) { String c_text = Encoding.UTF8.GetString((byte[])packet); ScriptEvents.OnCustomDataReceived(this, u, command, c_text); } } break; } }
private void Eval_HTML(TCPPacketReader packet) { if (!Settings.CanHTML) { return; } String html = packet.ReadString(); if (html == "<!--MOTDSTART-->") { this.Panel.SetScreenWidth(true); this.IsMOTDReceiving = true; } else if (html == "<!--MOTDEND-->") { this.Panel.SetScreenWidth(false); this.IsMOTDReceiving = false; } else { /* SANDBOXED CUSTOM HTML CONTENT */ // images if (html.StartsWith("<img")) { if (Settings.GetReg <bool>("receive_scribbles", true)) { if (html.StartsWith("<img ") && !html.Contains("onload=")) { html = "<img onload=\"imageLoaded(this)\" " + html.Substring(5); } if (html.LastIndexOf("<") == 0) { this.Panel.ShowCustomHTML(html); } } } // audio else if (html.StartsWith("<audio") && this.IsMOTDReceiving) { if (html.LastIndexOf("<") == 0) { this.Panel.ShowCustomHTML(html); } } // video else if (html.StartsWith("<video") && this.IsMOTDReceiving) { if (html.LastIndexOf("<") == 0) { this.Panel.ShowCustomHTML(html); } } // youtube else if (html.StartsWith("<!--EMBEDYOUTUBE:") && this.IsMOTDReceiving) { html = html.Substring(17); if (html.EndsWith("-->")) { html = html.Substring(0, html.Length - 3); if (html.Length > 0) { StringBuilder sb = new StringBuilder(); sb.Append("<iframe width=\"420\" height=\"315\" src=\"http://www.youtube.com/embed/"); sb.Append(html); sb.Append("\" frameborder=\"0\" allowfullscreen></iframe>"); this.Panel.ShowCustomHTML(sb.ToString()); sb.Clear(); } } } // let the script engine decide... else if (!html.ToUpper().Contains("<object")) { ScriptEvents.OnHTMLReceived(this, html); } } }
public void RemoveScriptEvents(UUID scriptid) { bool hadScript = false; lock (m_scriptEvents) { if (m_scriptEvents.ContainsKey(scriptid)) { ScriptEvents oldparts = ScriptEvents.None; oldparts = (ScriptEvents) m_scriptEvents[scriptid]; // remove values from aggregated script events AggregateScriptEvents &= ~oldparts; m_scriptEvents.Remove(scriptid); hadScript = true; } } if (hadScript) { DoAggregateScriptEvents(); } }
public static void EventCycle(ulong time) { JSTimers.ServiceTimers(time); if (PendingTerminators.Pending) { IPEndPoint ep = null; while (PendingTerminators.TryDequeue(out ep)) { ClearUsers(ep); ScriptEvents.OnRoomClosed(ep); foreach (JSScript script in Scripts) { script.Rooms.RemoveAll(x => x.EndPoint.Equals(ep)); } } } if (PendingUIText.Pending) { JSOutboundTextItem item = null; while (PendingUIText.TryDequeue(out item)) { Room r = RoomPool.Rooms.Find(x => x.EndPoint.Equals(item.EndPoint)); if (r != null) { if (item.Type == JSOutboundTextItemType.Command) { String str = ScriptEvents.OnCommandSending(r, item.Text); if (!String.IsNullOrEmpty(str)) { r.SendCommand(str); } } else if (item.Type == JSOutboundTextItemType.Public) { String str = ScriptEvents.OnTextSending(r, item.Text); if (!String.IsNullOrEmpty(str)) { r.SendText(str); } } else if (item.Type == JSOutboundTextItemType.Emote) { String str = ScriptEvents.OnEmoteSending(r, item.Text); if (!String.IsNullOrEmpty(str)) { r.SendEmote(str); } } else if (item.Type == JSOutboundTextItemType.Private) { String str = ScriptEvents.OnPmSending(r, item.Name, item.Text); if (!String.IsNullOrEmpty(str)) { r.SendPM(item.Name, str); } } else if (item.Type == JSOutboundTextItemType.Link) { if (ScriptEvents.OnLinkClicked(r, item.Text)) { try { Process.Start(item.Text); } catch { } } } else if (item.Type == JSOutboundTextItemType.ChatScreenCallback) { ScriptEvents.OnScreenCallback(r, item.Name, item.Text); } } } } if (PendingUIEvents.Pending) { JSUIEventItem item = null; while (PendingUIEvents.TryDequeue(out item)) { if (item.EventType == JSUIEventType.KeyPressed) { item.Element.KeyPressCallback((int)item.Arg); } else if (item.EventType == JSUIEventType.ValueChanged) { item.Element.ValueChangedCallback(); } else if (item.EventType == JSUIEventType.Click) { item.Element.ClickCallback(); } else if (item.EventType == JSUIEventType.Select) { item.Element.SelectCallback(); } else if (item.EventType == JSUIEventType.ItemDoubleClick) { item.Element.ItemDoubleClickCallback(); } else if (item.EventType == JSUIEventType.SelectedItemChanged) { item.Element.SelectedItemChangedCallback(); } else if (item.EventType == JSUIEventType.UISelected) { ScriptEvents.OnUISelected((String)item.Arg); } else if (item.EventType == JSUIEventType.RoomOpened) { ScriptEvents.OnRoomOpened((IPEndPoint)item.Arg); } else if (item.EventType == JSUIEventType.RoomClosed) { ScriptEvents.OnRoomClosed((IPEndPoint)item.Arg); } } } if (PendingPopupCallbacks.Pending) { JSUIPopupCallback item = null; while (PendingPopupCallbacks.TryDequeue(out item)) { JSScript script = Scripts.Find(x => x.ScriptName == item.Callback.Engine.ScriptName); if (script != null) { Objects.JSRoom room = script.Rooms.Find(x => x.EndPoint.Equals(item.Room)); if (room != null) { try { item.Callback.Call(script.JS.Global, room); } catch (Jurassic.JavaScriptException je) { ScriptManager.ErrorHandler(script.ScriptName, je.LineNumber, je.Message); } }
private void Eval_Features(TCPPacketReader packet) { String version = packet.ReadString(this.crypto); this.Credentials.Server = version; this.Panel.ServerText(StringTemplate.Get(STType.Messages, 17) + ": " + version); this.Panel.Userlist.UpdateServerVersion(version); this.should_check_for_current_topic_update = true; if (version.StartsWith("sb0t 5.")) { version = version.Substring(version.IndexOf(" ") + 1).Split(' ')[0]; String vnum_str = new String(version.Where(x => Char.IsNumber(x)).ToArray()); uint vnum; if (!uint.TryParse(vnum_str, out vnum)) { vnum = 0; } this.new_sbot = (vnum >= 514); } else if (version.StartsWith("Ares 2.") || version.StartsWith("Ares_2.")) { this.new_sbot = true; // maybe future Ares Server will support cb0t Custom Fonts? } ServerFeatures flag = (ServerFeatures)((byte)packet); this.CanVC = ((flag & ServerFeatures.SERVER_SUPPORTS_VC) == ServerFeatures.SERVER_SUPPORTS_VC); bool has_html = ((flag & ServerFeatures.SERVER_SUPPORTS_HTML) == ServerFeatures.SERVER_SUPPORTS_HTML); bool has_scribble = ((flag & ServerFeatures.SERVER_SUPPORTS_ROOM_SCRIBBLES) == ServerFeatures.SERVER_SUPPORTS_ROOM_SCRIBBLES); bool has_pm_scribble = ((flag & ServerFeatures.SERVER_SUPPORTS_PM_SCRIBBLES) == ServerFeatures.SERVER_SUPPORTS_PM_SCRIBBLES); this.CanOpusVC = ((flag & ServerFeatures.SERVER_SUPPORTS_OPUS_VC) == ServerFeatures.SERVER_SUPPORTS_OPUS_VC); this.Panel.CanVC(this.CanVC); this.Panel.CanScribbleAll(has_scribble); this.Panel.CanScribblePM(has_pm_scribble); this.Panel.InitScribbleButton(); this.CanNP = true; if (has_html) { this.Panel.Userlist.AcquireServerIcon(this.EndPoint); } packet.SkipByte(); this.Panel.ServerText(StringTemplate.Get(STType.Messages, 16) + ": " + (RoomLanguage)((byte)packet)); uint cookie = packet; if (!String.IsNullOrEmpty(this.Credentials.Password)) { this.sock.Send(TCPOutbound.SecureAdminLogin(this.Credentials.Password, cookie, this.Credentials.IP)); } this.UpdatePersonalMessage(); if (Avatar.Data != null) { this.sock.SendTrickle(TCPOutbound.Avatar()); } if (Settings.GetReg <bool>("user_font_enabled", false)) { this.sock.SendTrickle(TCPOutbound.Font(this.new_sbot, this.crypto)); } if (Settings.GetReg <bool>("block_custom_names", false)) { this.sock.SendTrickle(TCPOutbound.BlockCustomNames(true)); } ScriptEvents.OnConnected(this); }
private void Eval_UserlistEnds() { this.Panel.Userlist.ResumeUserlist(); ScriptEvents.OnUserlistReceived(this); }
public void DoAggregateScriptEvents() { AggregateScriptEvents = 0; // Aggregate script events lock (m_scriptEvents) { foreach (ScriptEvents s in m_scriptEvents.Values) { AggregateScriptEvents |= s; } } uint objectflagupdate = 0; if ( ((AggregateScriptEvents & ScriptEvents.touch) != 0) || ((AggregateScriptEvents & ScriptEvents.touch_end) != 0) || ((AggregateScriptEvents & ScriptEvents.touch_start) != 0) ) { objectflagupdate |= (uint) PrimFlags.Touch; } if ((AggregateScriptEvents & ScriptEvents.money) != 0) { objectflagupdate |= (uint) PrimFlags.Money; } if (AllowedDrop) { objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; } if (! CheckForScriptCollisionEventsAndSubscribe()) { PhysicsActor physActor = PhysActor; if (physActor != null) { physActor.UnSubscribeEvents(); physActor.OnCollisionUpdate -= PhysicsCollision; } } if (m_parentGroup == null) { ScheduleFullUpdate(PrimUpdateFlags.FindBest); return; } LocalFlags=(PrimFlags)objectflagupdate; if (m_parentGroup != null && m_parentGroup.RootPart == this) m_parentGroup.aggregateScriptEvents(); else ScheduleFullUpdate(PrimUpdateFlags.FindBest); }
private void Eval_Join(TCPPacketReader packet) { User u = new User(); ushort files = packet; packet.SkipBytes(4); u.ExternalIP = packet; u.Port = packet; packet.SkipBytes(4); u.SupportsPMEnc = ((ushort)packet) == 65535; packet.SkipByte(); u.Name = packet.ReadString(this.crypto); u.LocalIP = packet; u.HasFiles = ((byte)packet) == 1 && files > 0; u.Level = packet; u.Age = packet; u.Gender = packet; byte country = packet; u.Country = Helpers.CountryCodeToString(country); u.Region = packet.ReadString(this.crypto); u.IsFriend = Friends.IsFriend(u.Name); if (packet.Remaining > 0) { ClientFeatures features = (ClientFeatures)((byte)packet); u.SupportsVC = ((features & ClientFeatures.CLIENT_SUPPORTS_VC) == ClientFeatures.CLIENT_SUPPORTS_VC); u.SupportsOpusVC = ((features & ClientFeatures.CLIENT_SUPPORTS_OPUS_VC) == ClientFeatures.CLIENT_SUPPORTS_OPUS_VC); if (u.SupportsOpusVC) { u.SupportsVC = true; } } User ghost = this.users.Find(x => x.Name == u.Name); if (ghost != null) { this.users.RemoveAll(x => x.Name == ghost.Name); if (ghost.Writing) { ghost.Writing = false; this.Panel.UpdateWriter(ghost); } this.Panel.Userlist.RemoveUserItem(ghost); if (ScriptEvents.OnUserParting(this, ghost)) { this.Panel.AnnounceText(GlobalSettings.GetDefaultColorString(GlobalSettings.DefaultColorType.Part, this.BlackBG) + StringTemplate.Get(STType.Messages, 12).Replace("+x", ghost.Name)); } ScriptEvents.OnUserParted(this, ghost); Scripting.ScriptManager.RemoveUser(this.EndPoint, u); ghost.Dispose(); ghost = null; } this.users.Add(u); this.Panel.Userlist.AddUserItem(u); Scripting.ScriptManager.AddUser(this.EndPoint, u); if (ScriptEvents.OnUserJoining(this, u)) { this.Panel.AnnounceText(GlobalSettings.GetDefaultColorString(GlobalSettings.DefaultColorType.Join, this.BlackBG) + StringTemplate.Get(STType.Messages, 13).Replace("+x", u.Name)); } if (u.Name == this.MyName) { u.IsAway = Settings.IsAway; this.Panel.Userlist.MyLevel = u.Level; } ScriptEvents.OnUserJoined(this, u); if (u.IsFriend) { if (!Settings.GetReg <bool>("block_friend_popup", false)) { this.ShowPopup("cb0t :: " + StringTemplate.Get(STType.Messages, 4), StringTemplate.Get(STType.Messages, 14).Replace("+x", u.Name).Replace("+y", this.Credentials.Name), PopupSound.Friend); } } }