EasyBotter.phpの下記部分を編集します。
//文章を変換する
private function convertText($text, $reply = FALSE){
// 一部省略
if(strpos($text,"{tweet}") !== FALSE && !empty($reply)){
$tweet = preg_replace("@\.?\@[a-zA-Z0-9-_]+\s@u","",$reply->text);
$text = str_replace("{tweet}",$tweet,$text);
}
//この下から追加
if(strpos($text,"{place}") !== FALSE) {
if(!empty($reply)){
if(!empty($reply->user->location)) {
$text = str_replace("{place}",$reply->user->location,$text);
} else {
$text = str_replace("{place}","目標施設",$text);
}
}else{
$randomTweet = $this->getRandomTweet();
if(!empty($randomTweet->user->location)) {
$text = str_replace("{place}",$randomTweet->user->location,$text);
} else {
$text = str_replace("{place}","目標施設",$text);
}
}
}
//ここまで追加
//フッターを追加
$text .= $this->_footer;
return $text;
}
文中の「目標施設」というのは、相手の場所が取得できなかった場合のデフォルトですので、適宜botのイメージに合うように置き換えるといいと思います。
使用データ
- user->location
相手の「場所」が格納されている。