⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dog.java

📁 java开源邮件服务器 smtp pop3
💻 JAVA
字号:
import java.util.*;
import java.awt.*;

/**
 Auto reply server
 **/

public class Dog extends Extension implements Runnable
{
    String name = "Dixie"; /** The dog's name **/

    public Dog( dixie logx )
    {
        log           = logx;
        extensionName = "Dog";
    }

    public void execute( dixie  logx, String thisDomainx, String tox,
                         String fromx, String letterx, String datax )
    {
        log        = logx;
        thisDomain = thisDomainx;
        to         = tox;
        from       = fromx;
        letter     = letterx;
        data       = datax;

        Thread listener = new Thread( this );
        listener.start();
    }

    public void run()
    {
        StringBuffer newLetter = new StringBuffer();
        String name = smtp.subnetUser( to );
        boolean inMessage = false;
        String word;
        int inx;

        newLetter.append( "To: "+from+cr );
        newLetter.append( "From: "+to+cr );
        newLetter.append( "Subject: "+name+"'s reply"+cr+cr );

        for ( inx = 0; inx < numberOfLines( letter ); inx++ )
        {
            String thisLine = getLine( letter, inx );

            if ( inMessage )
            {
                StringTokenizer st = new StringTokenizer(thisLine);

                if ( st.hasMoreTokens() )
                {
                    newLetter.append( "> "+thisLine+cr );
                }

                while ( st.hasMoreTokens() )
                {
                    word = st.nextToken().toLowerCase();

                    if ( ( word.startsWith( name.toLowerCase() ) ) ||
                         ( word.startsWith( "dog" ) ) ||
                         ( word.startsWith( "hund" ) ) )
                    {
                        newLetter.append("WOOF!! ");
                    }
                    else if ( word.startsWith( "sit" ) )
                    {
                        newLetter.append( "("+name+" sits up) " );
                    }
                    else if ( ( word.startsWith( "stay" ) ) ||
                              ( word.startsWith( "plats" ) ) )
                    {
                        newLetter.append( "("+name+" stays) " );
                    }
                    else if ( ( word.startsWith( "come" ) ) ||
                              ( word.startsWith( "kom" ) ) )
                    {
                        newLetter.append( "("+name+" comes to you) " );
                    }
                    else if ( word.startsWith( "fetch" ) )
                    {
                        newLetter.append( "("+name+" fetches) " );
                    }
                    else if ( word.startsWith( "heel" ) )
                    {
                        newLetter.append( "("+name+" heels) " );
                    }
                    else if ( word.startsWith( "foot" ) )
                    {
                        newLetter.append( "("+name+" stays by your side) " );
                    }
                    else if ( word.startsWith( "gubbe" ) )
                    {
                        newLetter.append( "Woof!  Woof! " );
                    }
                    else if ( ( word.startsWith( "toy" ) ) ||
                              ( word.startsWith( "fun" ) ) ||
                              ( word.startsWith( "food" ) ) ||
                              ( word.startsWith( "snacks" ) ) ||
                              ( word.startsWith( "treat" ) ) ||
                              ( word.startsWith( "ride" ) ) ||
                              ( word.startsWith( "stick" ) ) ||
                              ( word.startsWith( "pinne" ) ) ||
                              ( word.startsWith( "frisbe" ) ) ||
                              ( word.startsWith( "ball" ) ) ||
                              ( word.startsWith( "lek" ) ) ||
                              ( word.startsWith( "play" ) ) ||
                              ( word.startsWith( "walk" ) ) ||
                              ( word.startsWith( "go" ) ) ||
                              ( word.startsWith( "mat" ) ) ||
                              ( word.startsWith( "promenad" ) ) ||
                              ( word.startsWith( "want" ) ) ||
                              ( word.startsWith( "sleep" ) ) ||
                              ( word.startsWith( "bil" ) ) ||
                              ( word.startsWith( "go" ) ) ||
                              ( word.startsWith( "car" ) ) )
                    {
                        newLetter.append( "Whine.... " );
                    }
                    else if ( ( word.startsWith( "james" ) ) ||
                              ( word.startsWith( "gith" ) ) ||
                              ( word.startsWith( "peter" ) ) )
                    {
                        newLetter.append( "Arooooooo!!!! ARRROOOOOO! " );
                    }
                    else if ( ( word.startsWith( "good" ) ) ||
                              ( word.startsWith( "nice" ) ) ||
                              ( word.startsWith( "duktig" ) ) ||
                              ( word.startsWith( "sweet" ) ) ||
                              ( word.startsWith( "cute" ) ) ||
                              ( word.startsWith( "love" ) ) ||
                              ( word.startsWith( "刲ska" ) ) ||
                              ( word.startsWith( "bra" ) ) )
                    {
                        newLetter.append( "Woof!  WOOF!!  Wooof! " );
                    }

                    else if ( ( word.startsWith( "bad" ) ) ||
                              ( word.startsWith( "mean" ) ) ||
                              ( word.startsWith( "work" ) ) )
                    {
                        newLetter.append( "GRRRRR!!!!! " );
                    }



                    // Dogs ignore articles, prepositions

                    else if ( ( word.startsWith( "for" ) ) ||
                              ( word.startsWith( "a" ) ) ||
                              ( word.startsWith( "an" ) ) ||
                              ( word.startsWith( "the" ) ) ||
                              ( word.startsWith( "and" ) ) ||
                              ( word.startsWith( "of" ) ) )
                    {
                    }
                    else if ( ( word.startsWith( "a" ) ) ||
                              ( word.startsWith( "e" ) ) ||
                              ( word.startsWith( "i" ) ) ||
                              ( word.startsWith( "o" ) ) ||
                              ( word.startsWith( "u" ) ) ||
                              ( word.startsWith( "n" ) ) ||
                              ( word.startsWith( "l" ) ) ||
                              ( word.startsWith( "r" ) ) ||
                              ( word.startsWith( "s" ) ) ||
                              ( word.startsWith( "t" ) ) )
                    {
                        newLetter.append( "Grrr " );
                    }
                    else
                    {
                        newLetter.append( "Arf " );
                    }
                }

                newLetter.append(cr);
            }

            if ( thisLine.trim().length() == 0 )
            {
                inMessage = true;
            }
        }

        newLetter.append(cr+"    "+name+cr );

        // Send but don't save dead letters or return to sender

        Forwarder forwarder = new Forwarder(
            thisDomain, from, to, newLetter.toString(), log,
            "Dog to "+from, null, false );
    }
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -