private string GetMD5() { string str = this.instance.Config.CurrentConfig.GroupManPro; METAMD5 md5 = new METAMD5(); return(md5.MD5(str)); }
private string GetMD5() { string str = this.instance.Config.CurrentConfig.GroupManPro; METAMD5 md5 = new METAMD5(); return md5.MD5(str); }
public void ProcessBufferItem(ChatBufferItem item, bool addToBuffer) { try { if (instance.IsAvatarMuted(item.FromUUID, item.FromName)) return; } catch { ; } string smsg = item.Text; string prefix = string.Empty; //if (addToBuffer) //{ // textBuffer.Add(item); // //int lines = textBuffer.Count; // //int maxlines = this.instance.Config.CurrentConfig.lineMax; // //if (lines > maxlines && maxlines > 0) // //{ // // CheckBufferSize(); // // return; // //} //} DateTime dte = item.Timestamp; if (classiclayout) { if (showTimestamps) { dte = this.instance.State.GetTimeStamp(dte); //if (instance.Config.CurrentConfig.UseSLT) //{ // string _timeZoneId = "Pacific Standard Time"; // DateTime startTime = DateTime.UtcNow; // TimeZoneInfo tst = TimeZoneInfo.FindSystemTimeZoneById(_timeZoneId); // dte = TimeZoneInfo.ConvertTime(startTime, TimeZoneInfo.Utc, tst); //} textPrinter.SetSelectionForeColor(Color.Gray); if (item.Style == ChatBufferTextStyle.StatusDarkBlue || item.Style == ChatBufferTextStyle.Alert) { //textPrinter.PrintText("\n" + dte.ToString("[HH:mm] ")); prefix = "\n" + dte.ToString("[HH:mm] ", CultureInfo.CurrentCulture); } else { if (item.Style != ChatBufferTextStyle.StartupTitle) { //textPrinter.PrintText(dte.ToString("[HH:mm] ")); prefix = dte.ToString("[HH:mm] ", CultureInfo.CurrentCulture); } } } else { prefix = string.Empty; } } else { try { if (lastspeaker != item.FromName) { //textPrinter.SetFontStyle(FontStyle.Bold); textPrinter.PrintHeader(item.FromName); // + buff); lastspeaker = item.FromName; } } catch { ; } textPrinter.SetFontStyle(FontStyle.Regular); textPrinter.SetSelectionBackColor(Color.White); //textPrinter.SetSelectionBackColor(instance.Config.CurrentConfig.BgColour); if (showTimestamps) { if (item.Style != ChatBufferTextStyle.StartupTitle) { dte = this.instance.State.GetTimeStamp(dte); //if (instance.Config.CurrentConfig.UseSLT) //{ // string _timeZoneId = "Pacific Standard Time"; // DateTime startTime = DateTime.UtcNow; // TimeZoneInfo tst = TimeZoneInfo.FindSystemTimeZoneById(_timeZoneId); // dte = TimeZoneInfo.ConvertTime(startTime, TimeZoneInfo.Utc, tst); //} //textPrinter.ForeColor = Color.Gray; if (item.Style == ChatBufferTextStyle.StatusDarkBlue || item.Style == ChatBufferTextStyle.Alert) { prefix = "\n" + dte.ToString("[HH:mm] ", CultureInfo.CurrentCulture); //prefix = dte.ToString("[HH:mm] "); } else { // if (item.FromName == client.Self.Name) //FirstName + " " + client.Self.LastName) // { prefix = dte.ToString("[HH:mm] ", CultureInfo.CurrentCulture); // } // else // { // prefix = dte.ToString("[HH:mm] ", CultureInfo.CurrentCulture); // } } } } else { prefix = string.Empty; } } // Check to see if it is an in-world plugin first //current possibilities are GroupManager or ChairAnnouncer if (smsg.Contains(gmu)) { roles = new List<UUID>(); char[] deli = ",".ToCharArray(); string[] sGrp = smsg.Split(deli); try //trap the cast to UUID bug if passed string is malformed { igroup = (UUID)sGrp[2]; iperson = (UUID)sGrp[1]; } catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Error); return; } int ielems = sGrp.Length; // This is a hack for backward GroupMan Pro compatibility if (ielems > 6) { gavname = sGrp[5]; gmanlocation = sGrp[6]; } else { gavname = string.Empty; gmanlocation = string.Empty; } string pwd = string.Empty; try { pwd = sGrp[3]; } catch { pwd = "invalid"; } // the MD5 stuff (as of V 0.9.3) string str = this.instance.Config.CurrentConfig.GroupManPro; METAMD5 md5 = new METAMD5(); string metapwd = md5.MD5(str); if (pwd != metapwd) { string gmsg = string.Empty; if (pwd == "invalid") { gmsg = "IMPORTANT WARNING: A group invite could not be sent out. Your GroupMan Pro is out of date."; } else { gmsg = "IMPORTANT WARNING: A group invite request with an invalid password has been received. Either the passwords in METAbolt & GroupMan Pro don't match or someone is trying to get unauthorised access. This is for information purposes only. DO NOT PANIC. The request has been discarded. \n\nRequest received from: " + item.FromName + " (" + item.FromUUID + ")\nThe password used is: " + pwd + ".\nThe requested invite is for group: " + igroup; } textPrinter.PrintTextLine(gmsg); return; } //roles.Add("00000000-0000-0000-0000-000000000000"); // Check if being invited to a specific role if (ielems > 4) { try //trap the cast to UUID bug if passed string is malformed { irole = (UUID)sGrp[4].Trim(); } catch { ;} roles.Add(irole); } else { roles.Add(UUID.Zero); } try { textPrinter.SetSelectionForeColor(Color.DarkCyan); if (this.instance.State.Groups.ContainsKey(igroup)) { // check if already member of the group client.Groups.GroupMembersReply += new EventHandler<GroupMembersReplyEventArgs>(GroupMembersHandler); GroupRequestID = client.Groups.RequestGroupMembers(igroup); } return; } catch (Exception excp) { textPrinter.PrintTextLine(String.Format(CultureInfo.CurrentCulture, "\n(GroupMan Pro @ " + gmanlocation + ")\nGroupMan Pro has encountered an error and a group invite could not be sent to: " + gavname)); OpenMetaverse.Logger.Log(String.Format(CultureInfo.CurrentCulture, "GroupMan Pro Error: {0}", excp), Helpers.LogLevel.Error); return; } } //added by GM on 2-JUL-2009 else if (item.FromUUID == cau && cau != UUID.Zero) { if (!chairAnnEnabled) return; if (nextCallTime <= DateTime.Now) { textPrinter.SetSelectionForeColor(Color.DarkOrange); if (chairAnnChat) textPrinter.PrintText(prefix); // the MD5 stuff (as of V 0.9.3) //chop out the Password if there is one string[] chops = smsg.Split(new char[] { '|' }, StringSplitOptions.None); string pwd; if (chops.Length == 3) { pwd = chops[1]; } else { pwd = "invalid"; } string str = this.instance.Config.CurrentConfig.GroupManPro; //GM: actually it is the METAbolt password METAMD5 md5 = new METAMD5(); string metapwd = md5.MD5(str); if (pwd != metapwd) { string gmsg = string.Empty; if (pwd == "invalid") { gmsg = "IMPORTANT WARNING: A chair announcement could not be sent out. Your Chair Announcer is out of date. \nThe password used is: " + pwd + "."; } else { gmsg = "IMPORTANT WARNING: A chair announcement with an invalid password has been received. Either the passwords in METAbolt & Chair Announcer don't match or someone is trying to get unauthorised access. This is for information purposes only. DO NOT PANIC. The request has been discarded. \nThe password used is: " + pwd; } textPrinter.PrintTextLine(gmsg); //always print even if chairAnnChat is turned off return; } //fixup the text //chop off before the ChairPrefix string cp = METAbolt.Properties.Resources.ChairPrefix; int pos = smsg.IndexOf(cp, 2, StringComparison.CurrentCultureIgnoreCase); pos = pos < 0 ? 0 : pos; StringBuilder sb = new StringBuilder(smsg.Substring(pos)); //include the advert on a new line // modified by GM on 1-APR-2010 //was string ca = METAbolt.Properties.Resources.ChairAdvert; string ca = chairAnnAdvert; sb.Append(" \n"); sb.Append(ca); //work out which group to IM between 0 and 5 indexGroup++; if (indexGroup == 6 || chairAnnouncerGroups[indexGroup] == UUID.Zero) indexGroup = 0; nextCallTime = DateTime.Now.AddMinutes(1); //callbacks client.Self.GroupChatJoined += new EventHandler<GroupChatJoinedEventArgs>(Self_OnGroupChatJoin); //calculate the interval int perGroupInterval = (int)Math.Round(((decimal)(chairAnnouncerInterval / chairAnnouncerActives))); perGroupInterval = perGroupInterval < 1 ? 1 : perGroupInterval; //find if already in the group UUID grp = chairAnnouncerGroups[indexGroup]; if (client.Self.GroupChatSessions.ContainsKey(grp)) { client.Self.InstantMessageGroup(grp, sb.ToString()); if (chairAnnChat) textPrinter.PrintTextLine("Chair Announcer: IM to existing group " + chairAnnouncerGroupNames[indexGroup]); nextCallTime = nextCallTime.AddMinutes(perGroupInterval - 1); } else { targetIndex = indexGroup; client.Self.RequestJoinGroupChat(grp); waitGroupIMSession.Reset(); if (waitGroupIMSession.WaitOne(30000, false)) //30 seconds { client.Self.InstantMessageGroup(grp, sb.ToString()); if (chairAnnChat) textPrinter.PrintTextLine("Chair Announcer: IM to new group " + chairAnnouncerGroupNames[indexGroup]); nextCallTime = nextCallTime.AddMinutes(perGroupInterval - 1); } else { Logger.Log("Chair Announcer: timeout after 30 seconds on group " + indexGroup.ToString(CultureInfo.CurrentCulture), Helpers.LogLevel.Warning); } } client.Self.GroupChatJoined -= new EventHandler<GroupChatJoinedEventArgs>(Self_OnGroupChatJoin); } else { Logger.Log("Chair Announcer: skipped", Helpers.LogLevel.Info); } OpenMetaverse.Logger.Log(String.Format(CultureInfo.CurrentCulture, "AddIn: {0} called {1}", cau.ToString(), smsg), Helpers.LogLevel.Debug); return; } if (classiclayout) { textPrinter.SetSelectionForeColor(Color.Gray); textPrinter.PrintClassicTextDate(prefix); //textPrinter.PrintDate(prefix); } else { //textPrinter.SetSelectionForeColor(Color.Gray); //textPrinter.PrintText(dte.ToString("[HH:mm] ")); //textPrinter.SetOffset(6); //textPrinter.SetFontSize(6.5f); textPrinter.PrintDate(prefix); //textPrinter.SetFontSize(8.5f); //textPrinter.SetOffset(0); } bool islhdr = false; switch (item.Style) { case ChatBufferTextStyle.Normal: textPrinter.SetSelectionForeColor(Color.Black); break; case ChatBufferTextStyle.StatusBlue: textPrinter.SetSelectionForeColor(Color.Blue); break; case ChatBufferTextStyle.StatusBold: textPrinter.SetFontStyle(FontStyle.Bold); break; case ChatBufferTextStyle.StatusBrown: textPrinter.SetSelectionForeColor(Color.Brown); break; case ChatBufferTextStyle.StatusDarkBlue: textPrinter.SetSelectionForeColor(Color.Gray); //textPrinter.BackColor = Color.LightSeaGreen; break; case ChatBufferTextStyle.LindenChat: textPrinter.SetSelectionForeColor(Color.DarkGreen); textPrinter.SetSelectionBackColor(Color.LightYellow); break; case ChatBufferTextStyle.ObjectChat: textPrinter.SetSelectionForeColor(Color.DarkCyan); //item.Text = "\n" + item.Text; break; case ChatBufferTextStyle.OwnerSay: textPrinter.SetSelectionForeColor(Color.FromArgb(255, 211, 75, 0)); //item.Text = "\n" + item.Text; break; case ChatBufferTextStyle.RegionSay: textPrinter.SetSelectionForeColor(Color.Green); //item.Text = "\n" + item.Text; break; case ChatBufferTextStyle.StartupTitle: textPrinter.SetSelectionForeColor(Color.Black); textPrinter.SetFontStyle(FontStyle.Bold); break; case ChatBufferTextStyle.Alert: textPrinter.SetSelectionForeColor(Color.White); //textPrinter.SetSelectionBackColor(Color.BlueViolet); textPrinter.SetSelectionBackColor(Color.SteelBlue); item.Text = item.Text; // +"\n"; break; case ChatBufferTextStyle.Error: textPrinter.SetSelectionForeColor(Color.Yellow); textPrinter.SetSelectionBackColor(Color.Red); break; case ChatBufferTextStyle.LoginReply: textPrinter.PrintHeader(":: Grid Login Message ::"); textPrinter.SetSelectionForeColor(Color.Black); //textPrinter.SetSelectionBackColor(Color.LightSteelBlue); textPrinter.SetSelectionBackColor(instance.Config.CurrentConfig.HeaderBackColour); textPrinter.SetFontStyle(FontStyle.Bold); //textPrinter.SetFontSize(12); textPrinter.SetOffset(8); islhdr = true; if (item.Text.Contains("http://")) { item.Text = instance.CleanReplace("http://", "\nhttp://", item.Text); } if (item.Text.Contains("https://")) { item.Text = instance.CleanReplace("https://", "\nhttps://", item.Text); } break; } textPrinter.PrintTextLine(item.Text); if (islhdr) textPrinter.PrintHeader(" "); //// Handle chat tweets //if (TEnabled) //{ // if (instance.Config.CurrentConfig.EnableChatTweets) // { // Yedda.Twitter twit = new Yedda.Twitter(); // string resp = string.Empty; // if (tweet) // { // // if enabled print to Twitter // resp = twit.UpdateAsJSON(tName, tPwd, item.Text); // } // else // { // // it's a direct message // resp = twit.Send(tName, tPwd, tweetname, item.Text); // } // if (resp != "OK") // { // Logger.Log("Twitter error: " + resp, Helpers.LogLevel.Warning); // } // } //} if (reprinting) { reprinting = false; return; } if (!classiclayout) { string txt = item.FromName + ": " + item.Text; LogMessage(dte, item.FromUUID.ToString(), item.FromName, txt); } else { LogMessage(dte, item.FromUUID.ToString(), item.FromName, item.Text); } }