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

📄 iaclient.java

📁 MSN聊天机器人,可以自由聊天对话,可以做很多使用的应用
💻 JAVA
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   IAClient.java

package com.barryliu.ia;

import java.sql.*;

// Referenced classes of package com.barryliu.ia:
//            IAHttp

public class IAClient
{

    public IAClient()
    {
    }

    public static String getMsg(String s, Connection connection, String s1)
    {
        String s2 = null;
        try
        {
            String s3 = filterQuestion(s);
            s2 = IAHttp.getInstance().getLTCon(s3);
            if(s2 != null && !s2.trim().equals("") && s2.length() < 140)
            {
                recordLTLog(connection, s3, s2, s1);
            } else
            {
                s2 = null;
                s2 = randValue(s3, connection);
                if(s2 != null)
                    if(s2.equals(""));
            }
        }
        catch(Exception exception)
        {
            exception.printStackTrace();
        }
        if(s2 == null)
            s2 = "你好";
        return s2;
    }

    public static String filterQuestion(String s)
    {
        String s1 = s;
        replace(s1, ",", ",");
        replace(s1, "?", "?");
        replace(s1, "。", ".");
        replace(s1, ":", ":");
        replace(s1, ";", ";");
        replace(s1, "!", "!");
        replace(s1, "'", "\"");
        return s1;
    }

    public static String replace(String s, String s1, String s2)
    {
        int i = 0;
        if(s == null || s1 == null)
            return null;
        if((i = s.indexOf(s1, i)) >= 0)
        {
            int j = s1.length();
            int k = s2.length();
            StringBuffer stringbuffer = new StringBuffer();
            stringbuffer.append(s.substring(0, i)).append(s2);
            i += j;
            int l;
            for(l = i; (i = s.indexOf(s1, i)) > 0; l = i)
            {
                stringbuffer.append(s.substring(l, i)).append(s2);
                i += j;
            }

            stringbuffer.append(s.substring(l));
            return stringbuffer.toString();
        } else
        {
            return s;
        }
    }

    public static void recordLTLog(Connection connection, String s, String s1, String s2)
    {
        try
        {
            String s3 = "Select 1 From IALT_Backup Where Answer='" + s1 + "'";
            Statement statement = connection.createStatement();
            ResultSet resultset = statement.executeQuery(s3);
            if(!resultset.next())
            {
                String s4 = "insert into IALT_Backup (Phone,Question,Answer)  Values ('" + s2 + "','" + s + "','" + s1 + "')";
                statement.executeUpdate(s4);
            }
            statement.close();
        }
        catch(Exception exception)
        {
            exception.printStackTrace();
        }
    }

    public static String randValue(String s, Connection connection)
    {
        String s1 = null;
        try
        {
            CallableStatement callablestatement = connection.prepareCall("{call Prc_GetResult(?,?)}");
            callablestatement.setString(1, s);
            callablestatement.registerOutParameter(2, 12);
            callablestatement.executeUpdate();
            s1 = callablestatement.getString(2);
            callablestatement.close();
        }
        catch(Exception exception)
        {
            exception.printStackTrace();
        }
        return s1;
    }
}

⌨️ 快捷键说明

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