예제 #1
0
파일: api.php 프로젝트: WingLim/TieBaRobot
function talk($content, $name, $api, $apikey = '')
{
    $content = str_ireplace("@{$name}", '', $content);
    $content = str_ireplace("回复 {$name} :", '', $content);
    $content = urlencode($content);
    switch ($api) {
        case 'xiaoji':
            $re = xiaoji($content);
            break;
        case 'xiaoi3':
            $re = xiaoi3($content);
            break;
        case 'tuling':
            $re = tuling($content, $apikey);
            break;
        case 'simsimi3':
            $re = simsimi3($content);
            break;
        case 'simsimi':
            $re = simsimi($content);
            break;
        default:
            $re = xiaoji($content);
    }
    return $re;
}
예제 #2
0
파일: api.php 프로젝트: crushway/TieBaRobot
function talk($content, $name, $api, $apikey = '')
{
    $content = preg_replace("/@{$name}\\s*?|回复(\\s|@)*?{$name}\\s*?(:|:)/i", '', $content);
    $content = urlencode($content);
    $re = '';
    switch ($api) {
        case 'xiaoji':
            $re = xiaoji($content);
            break;
        case 'xiaoi3':
            $re = xiaoi3($content);
            break;
        case 'tuling':
            $re = tuling($content, $apikey);
            break;
        case 'simsimi3':
            $re = simsimi3($content);
            break;
        case 'simsimi':
            $re = simsimi($content);
            break;
        case 'baidurobot':
            $re = baidurobot($content, $apikey);
            break;
        default:
            $re = xiaoji($content);
    }
    return $re;
}
예제 #3
0
function talk($content)
{
    global $con, $api;
    if ($con) {
        return $con;
    }
    $content = str_replace(' ', '', $content);
    if ($api) {
        return tuling($content, $api);
    }
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'http://www.simsimi.com/talk.htm');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_NOBODY, false);
    $rs = curl_exec($ch);
    preg_match_all('/Set-Cookie: (.+)=(.+)$/m', $rs, $regs);
    foreach ($regs[1] as $i => $k) {
    }
    $cc = str_replace(' Path', '', $k);
    $cc = 'simsimi_uid=507454034223;' . $cc;
    $re = HTTPClient('http://www.simsimi.com/func/reqN?lc=ch&ft=1.0&req=' . $content . '&fl=http%3A%2F%2Fwww.simsimi.com%2Ftalk.htm', $cc);
    $re = json_decode($re, true);
    return $re['sentence_resp'];
}
예제 #4
0
        echo $weixin->postText($weixin->fromUser);
    } else {
        $msgArr = explode('/', str_replace(' ', '', $content));
        if (count($msgArr) == 2) {
            preg_match('/(^0371\\d{8}$)|(^\\d{8}$)|(^1[34578]\\d{9}$)/', $msgArr[0], $phone);
            preg_match('/^[\\x{4e00}-\\x{9fa5}]{2,}/u', $msgArr[1], $name);
            if (count($phone) && count($name)) {
                //存入数据库
                echo $weixin->postText(post_recommend($weixin->fromUser, $phone[0], $name[0]));
            } else {
                echo $weixin->postText('您发送的信息格式不正确,请重新发送');
            }
        } else {
            // echo $weixin->postText('您发送的信息格式不正确,请重新发送');
            //图灵机器人
            echo $weixin->postText(tuling($weixin->fromUser, $content));
        }
    }
}
if ($weixin->msgType == 'event') {
    //点击事件
    switch ($weixin->eventKey) {
        case 'want_recommend':
            //我要推荐
            $retContent = want_recommend($weixin->fromUser);
            // $retContent = "请输入电话和姓名,格式为:15211223344/李晓明";
            break;
        case 'personal_info':
            //个人信息
            // $retContent =  '个人信息';
            $retContent = requestUserInfo($weixin->fromUser);
예제 #5
0
     if (substr($content, 0, 12) == "谁是卧底") {
         $lock = "under_cover";
         upuserlock($lock, $username);
         $content = substr($content, 12);
     }
     if ($lock == "idioms") {
         $reply = idioms($content, $username);
         $weObj->text($reply)->reply();
     } elseif ($lock == "under_cover") {
         $reply = UnderCover($content, $username);
         $weObj->text($reply)->reply();
     } else {
         if (strcasecmp($content) == "help" || $content == "帮助") {
             $weObj->text("hello, I'm wechat\n平台现有功能:\n智能聊天,成语接龙,谁是卧底游戏")->reply();
         } else {
             $reply = tuling($content);
             if (gettype($reply) == string) {
                 $weObj->text($reply)->reply();
             } else {
                 if (is_array($reply)) {
                     $weObj->news($reply)->reply();
                 }
             }
         }
     }
     exit;
     break;
     /*地理事件回复*/
 /*地理事件回复*/
 case Wechat::MSGTYPE_LOCATION:
     $weObj->text("地理事件")->reply();