Seite 3 von 3 Erste 123
  1. #21
    Avatar von iToxic
    Registriert seit
    18.11.2011
    Beiträge
    918
    Thanked 1.773 Times in 913 Posts

    Standard AW: [Tutorial][#3] Chatverlauf

    Zitat Zitat von getsha Beitrag anzeigen
    Ja aber der soll doch das bild anzeigen im bot also dieses MCM da ?! oO
    Dann probier selbst mal etwas rum?
    Mit deinem jetzigen Versuch klappt es ja nicht, wie du selbst bemerkt hast


  2. #22

    Registriert seit
    12.02.2012
    Beiträge
    78
    Thanked 11 Times in 5 Posts

    Standard AW: [Tutorial][#3] Chatverlauf

    Zitat Zitat von Sky.NET Beitrag anzeigen
    geht auch damit (ist jetzt für html-code ausgelegt, mit ein paar änderungen kann man damit aber auch machen was man will...):
    PHP-Code:
        private class KCodeItem
            
    {
                private 
    int id;
                private 
    string code;
                private 
    string html;
                
    //Eine Sammlung von Regular-Expressions für die Identifizierung der Knuddels-Links
                
    private Dictionary<stringstringregExCollection = new Dictionary<stringstring>();

                
    /// <summary>
                /// Konstruktor
                /// </summary>
                /// <param name="id">Die Nummer des Code-Elements</param>
                /// <param name="code">Der Inhalt des Code-Elements</param>            
                /// <param name="channel">Channelobjekt mit Styleeinstellungen des Channels</param>
                
    public KCodeItem(int idstring codeChannel c)
                {
                    
    this.id id;
                    
    this.code code;

                    
    #region regexCollection erstellen

                    //Reihenfolge ist Wichtig!!!

                    //Bild + Text + WebLink
                    
    regExCollection.Add("ImageTextWebLink""BB>(.+?)\\.(gif)<>(.*?)\\|((?:http|https)(?::\\/{2}[\\w]+)(?:[\\/|\\.]?)(?:[^\\s\"]*))<");
                    
    //Text + WebLink
                    
    regExCollection.Add("TextLink""BB>(.*?)(\\|)((?:http|https)(?::\\/{2}[\\w]+)(?:[\\/|\\.]?)(?:[^\\s\"]*))<");
                    
    //Bild + Text + Befehlssatz1 + Linktext + Befehlssatz2
                    
    regExCollection.Add("ParameterizedImageChatLink""BB >(.*?)< >--< >\\|(.*?)\\|(.*?)< >--< >(.*?)\\|(.*?)\\|(.*?)< r");

                    
    //Reihenfolge ist Wichtig!!!

                    //Links ohne Parameter
                    
    regExCollection.Add("LinkWithoutParams"">_h(.*?)\\|(.*?)\\|(.*?)<");
                    
    //Links mit Parametern
                    
    regExCollection.Add("ParameterizedChatLink"".*?>_h(.*?)\\|(.*?)\"\\|(.*?)\"<");
                    
    //Links mit selbem Parameter auf beiden Maustasten
                    
    regExCollection.Add("SimpleParamLink"">(.*?)\\|(.*?) \\\"<");
                    
    //Formatierter Link mit Text = Funktion und nur einer Funktion
                    
    regExCollection.Add("SingleParamLink""(.*?)>(.*?)\\|\"<(.*?)");

                    
    //Pics (doppelte)
                    
    regExCollection.Add("DoublePicture"">sm_(.*?)<>sm_(.*?)<");
                    
    //Pics (einzelne)
                    
    regExCollection.Add("SimplePicture"">(.+?)<");
                    
    #endregion

                    
    if (code.Length && code[0] == '>' || code.StartsWith("BB >") || code.StartsWith("BB>") && code[1] != '{')
                    {
                        foreach (
    KeyValuePair<stringstringkvp in regExCollection)
                        {
                            
    Match m = new Regex(kvp.ValueRegexOptions.IgnoreCase RegexOptions.Singleline).Match(code);

                            
    string fileName null;
                            
    string text null;
                            
    string url null;
                            
    string commandLeftClick null;
                            
    string commandRightClick null;
                            
    string imageName null;

                            if (
    m.Success)
                            {
                                switch (
    kvp.Key)
                                {
                                    
    #region LinkWithoutParams
                                    
    case "LinkWithoutParams":
                                        
    text m.Groups[1].ToString();
                                        
    text text.Replace("\\<""&lt;");
                                        
    text text.Replace("\\>""&gt;");
                                        
    commandLeftClick m.Groups[2].ToString().Replace("\""text);
                                        
    commandRightClick m.Groups[3].ToString().Replace("\""text);
                                        
    this.html "<a hidefocus=\"hidefocus\" class=\"leading\" href=\"#\" name=\"" commandLeftClick "|" commandRightClick "\">" text "</a>";
                                        break;
                                    
    #endregion
                                    #region TextLink
                                    
    case "TextLink":
                                        
    text m.Groups[1].ToString();
                                        
    text text.Replace("\\<""&lt;");
                                        
    text text.Replace("\\>""&gt;");
                                        
    url m.Groups[3].ToString();
                                        
    this.html "<a  hidefocus=\"hidefocus\" href=\"#\" name=\"\0" url "|\0" url "\">" text "</a>";

                                        break;
                                    
    #endregion
                                    #region ParameterizedImageChatLink
                                    
    case "ParameterizedImageChatLink":

                                        
    /* <------ NOT USED! ------>
                                        string str = "";
                                        for (int i = 0; i <= m.Groups.Count; i++)
                                        {
                                            str += "[" + i.ToString() + "]" + m.Groups[i].ToString() + "\r\n";
                                        }
                                        MessageBox.Show(str);*/

                                        
    fileName m.Groups[1].ToString();
                                        
    string command1Left m.Groups[2].ToString();
                                        
    string command1Right m.Groups[3].ToString();
                                        
    text m.Groups[4].ToString();
                                        
    text text.Replace("\\<""&lt;");
                                        
    text text.Replace("\\>""&gt;");
                                        
    string command2Left m.Groups[5].ToString();
                                        
    string command2Right m.Groups[6].ToString();
                                        
    //ClientHelper.imageLoader(fileName, ClientHelper.standartPicsDirectory + '/' + ClientHelper.standartPicsDirectory, rootDomain);
                                        //filePath = new FileInfo(ClientHelper.imageDirectory + @"\" + fileName);

                                        
    this.html "<img src=\"" "http://chat.knuddels.de/" fileName "\">" "<a hidefocus=\"hidefocus\" href=\"#\" name=\"" command2Left "|" command2Right "\">" text "</a>";
                                        break;
                                    
    #endregion
                                    #region ImageTextWebLink
                                    
    case "ImageTextWebLink":
                                        
    imageName m.Groups[1].ToString();
                                        if (
    imageName.Contains("..."))
                                            
    imageName imageName.Substring(0imageName.IndexOf("...")) + ".png";
                                        
    imageName imageName "." m.Groups[2];

                                        
    text m.Groups[3].ToString();
                                        
    text text.Replace("\\<""&lt;");
                                        
    text text.Replace("\\>""&gt;");
                                        
    url m.Groups[4].ToString();

                                        
    fileName imageName;
                                        
    //ClientHelper.imageLoader(fileName, ClientHelper.standartPicsDirectory + '/' + ClientHelper.standartPicsDirectory, rootDomain);
                                        //filePath = new FileInfo(ClientHelper.imageDirectory + @"\" + fileName);

                                        
    this.html "<img src=\"" "http://chat.knuddels.de/" url "\">" "<a hidefocus=\"hidefocus\" href=\"#\" name=\"\0" url "|\0" url "\">" text "</a>";

                                        break;
                                    
    #endregion
                                    #region ParameterizedChatLink
                                    
    case "ParameterizedChatLink":
                                        
    string param m.Groups[1].ToString();

                                        
    commandLeftClick m.Groups[2].ToString();
                                        
    commandRightClick m.Groups[3].ToString();

                                        
    param param.Replace("<""&lt;");
                                        
    param param.Replace(">""&gt;");

                                        
    this.html "<a hidefocus=\"hidefocus\" href=\"#\" name=\"" commandLeftClick param "|" commandRightClick param "\">" param "</a>";
                                        break;
                                    
    #endregion
                                    #region SimpleParamLink
                                    
    case "SimpleParamLink":
                                        
    text m.Groups[1].ToString();
                                        
    text text.Replace("\\<""&lt;");
                                        
    text text.Replace("\\>""&gt;");
                                        
    commandLeftClick m.Groups[2].ToString();
                                        
    commandRightClick m.Groups[2].ToString();
                                        
    this.html "<a style=\"text-decoration:underline;\" hidefocus=\"hidefocus\" class=\"leading\" href=\"#\" name=\"" commandLeftClick "|" commandRightClick "\">" text "</a>";
                                        break;
                                    
    #endregion
                                    #region SingleParamLink
                                    
    case "SingleParamLink":
                                        
    //regExCollection.Add("SingleParamLink", "(.*?)>(.*?)\\|\"<(.*?)");
                                        
    text m.Groups[2].ToString();
                                        
    text text.Replace("\\<""&lt;");
                                        
    text text.Replace("\\>""&gt;");
                                        
    commandLeftClick m.Groups[2].ToString();
                                        
    commandRightClick m.Groups[2].ToString();

                                        
    string add "";

                                        if (
    m.Groups[1].ToString() == "BB")
                                            
    add "color: " ColorTranslator.ToHtml(c.blue).Replace("#""") + ";";

                                        
    this.html "<a style=\"text-decoration:underline; font-weight:bold; " add "\" hidefocus=\"hidefocus\" class=\"leading\" href=\"#\" name=\"" commandLeftClick "|" commandRightClick "\">" text "</a>";
                                        break;
                                    
    #endregion
                                    #region DoublePicture
                                    
    case "DoublePicture":
                                        
    //ForeGround
                                        
    string pic1 "sm_" m.Groups[1];
                                        
    //Background
                                        
    string pic2 "sm_" m.Groups[2];
                                        
    this.html "<img style =\"background-image:url(file:///" ImageHandler.LoadImage(pic1).ImagePath ");\" src=\"file:///" ImageHandler.LoadImage(pic2).ImagePath "\">";
                                        break;
                                    
    #endregion
                                    #region SimplePicture
                                    
    case "SimplePicture":
                                        
    fileName m.Groups[1].ToString();
                                        try
                                        {
                                            
    this.html "<img src=\"file:///" ImageHandler.LoadImage(fileName).ImagePath "\">";
                                        }
                                        catch
                                        {
                                            
    this.html "[RegExNotImplemented]";
                                            
    File.AppendAllText("unparsed.txt"code Environment.NewLine);
                                        }
                                        break;
                                    
    #endregion
                                
    }
                                break;
                            }

                        }
                        if (
    this.html == null || this.html == "" || this.html == string.Empty)
                            
    this.html code "\n";
                    }
                    else if (
    code.Length && code[2] == '{')
                    {
                        
    File.AppendAllText("unparsed.txt"code Environment.NewLine);
                    }
                    
    #region RGB Color
                    
    else if (code.Length != && code[0] == '[')
                    {
                        try
                        {
                            
    code code.Substring(1);
                            
    code code.Remove(code.Length 1);
                            
    string[] rgb code.Split(new char[] { ',' });
                            
    Color color Color.FromArgb(
                                
    int.Parse(rgb[0]),
                                
    int.Parse(rgb[1]),
                                
    int.Parse(rgb[2]));
                            
    this.html =
                                
    "<span style=\"color: " +
                                
    ColorTranslator.ToHtml(color) +
                                
    ";\">";
                        }
                        catch
                        {

                        }
                    }
                    
    #endregion
                    #region ColorLetter, Size, Fehler
                    
    else
                    {  
    //ColorLetter / Size

                        
    string[] ChatColors = { "W""E""R""O""P""A""D""G""K""Y""C""B""N""M""BB""RR" };
                        
    string[] ChatSizes = new string[31];
                        for (
    int i 1<= 30i++)
                            
    ChatSizes[i] = i.ToString();

                        
    string[] HTMLColors = { "#FFFFFF""#00AC00""#FF0000""#FFC800""#FFAFAF""#808080""#404040""#00FF00""#000000""#FFFF00""#00FFFF""#0000FF""#964A00""#FF00FF"ColorTranslator.ToHtml(c.blue).Replace("#"""), ColorTranslator.ToHtml(c.red).Replace("#""") };

                        
    #region Check Colors
                        
    for (int i 1<= 16i++)
                            if (
    code == ChatColors[1])
                            {
                                
    this.html "<span style=\"color: " HTMLColors[1] + ";\">";
                                return;
                            }
                        
    #endregion

                        #region CheckFormatReset
                        
    if (code == "r")
                        {
                            
    this.html "</span></b></i><span style=\"font-size:" c.fontSize "px; color: " ColorTranslator.ToHtml(c.foreColor) + ";\">";
                            return;
                        }

                        
    #endregion

                        #region Check Points
                        
    if (code == "!")
                        {
                            
    this.html "<span style=\"letter-spacing: 2px; color: " ColorTranslator.ToHtml(c.foreColor) + "; font-size:7px;\">.........</span>";
                            return;
                        }
                        
    #endregion

                        #region Check Sizes
                        
    try
                        {
                            
    int.Parse(code);
                            
    this.html "<span style=\"font-size:" code "px\">";
                            return;
                        }
                        catch { }
                        
    #endregion

                        #region Size&Color
                        
    try
                        {
                            
    string re1 "(\\d+)";    // Integer Number 1
                            
    string re2 "([a-z])";    // Any Single Character 1

                            
    string size = new Regex(re1RegexOptions.IgnoreCase RegexOptions.Singleline).Match(code).Groups[1].ToString();
                            
    string color = new Regex(re2RegexOptions.IgnoreCase RegexOptions.Singleline).Match(code).Groups[1].ToString();

                            for (
    int i 1<= 16i++)
                                if (
    color == ChatColors[1])
                                    
    color HTMLColors[1];

                            
    this.html "<span style=\"font-size:" size "px; color: " color ";\">";
                            return;
                        }
                        catch (
    Exception ex) { MessageBox.Show(ex.ToString()); }
                        
    #endregion

                        
    this.html code;
                        
    //Konnte nichts mit anfangen, also erstmal zurück,
                        //damit man sieht, wenn Fehler auftauchen.
                    
    }

                    
    #endregion
                
    }

                public 
    int Id
                
    {
                    
    get { return this.id; }
                }
                public 
    string Code
                
    {
                    
    get { return this.code; }
                }
                public 
    string HTML
                
    {
                    
    get { return this.html; }
                }
            } 

    Und wo füge ich jetzt dein Code bei VB ein?
    Kapiere leider nicht wo. v.v

Seite 3 von 3 Erste 123

Ähnliche Themen

  1. GFX Tutorial's Basic uvm.
    Von Ricardo1337 im Forum Tutorials
    Antworten: 5
    Letzter Beitrag: 28.08.2013, 17:56
  2. Chatverlauf faken
    Von UnReal im Forum Fragen & Probleme
    Antworten: 5
    Letzter Beitrag: 29.07.2013, 08:36
  3. C++ Tutorial: Hello World
    Von x failstar im Forum C++
    Antworten: 11
    Letzter Beitrag: 04.07.2012, 14:48
  4. (.bat) Batch Tutorial
    Von MC Phlegmatisch im Forum Tutorials
    Antworten: 0
    Letzter Beitrag: 31.03.2012, 13:35
  5. [VB] - Chatverlauf farbig gestalten - Problem
    Von Pyromane im Forum Sourcecode
    Antworten: 1
    Letzter Beitrag: 26.03.2012, 14:12
Diese Seite nutzt Cookies, um das Nutzererlebnis zu verbessern. Klicken Sie hier, um das Cookie-Tracking zu deaktivieren.