首先需要一个表情包smilies.zip,也可以自己弄一个
表情包里的图片格式要统一,我是*.png
表情包里还有一个order.txt文件
它存放的内容是表情的顺序

然后来修改主题下的comments.php文件
<textarea>标签前添加下面这一段代码
注意:$url为表情包位置,请进行修改

<div id="smilies">
    <div id="smilies_btn" onclick="smilies_click();"><span>OωO表情</span></div>
    <div id="smilies_body">
        <ul>
            <?php
                $url = 'http://file.littlehands.site/smilies/img';//表情包位置
                $content = file_get_contents($url . '/order.txt');
                $contents = explode("\n",$content);
                foreach($contents as $value){
                    echo '<li onclick="smilies_write(this);"><img src="' . $url . '/' . $value . '"></li>';
                }
            ?>
        </ul>
    </div>
</div>

JS代码
需要jquery
注意:textarea元素id是否需要修改

function smilies_click(){
    $('#textarea').focus();//textarea元素id注意是否需要修改
    $('#smilies').toggleClass('smilies_popup');
}
function smilies_write(obj){
    var url = $(obj).find('img').attr('src');
    var name = url.replace(/(.*\/)*([^.]+).*/ig,"$2");
    var text = '@(';
    text += name + ')';//此行与上一行可合并一行,由于显示原因被分成两行
    var textarea = $('#textarea');//textarea元素id注意是否需要修改
    textarea.focus();
    var content = textarea.val();
    var start = textarea.get(0).selectionStart;
    var end = textarea.get(0).selectionEnd;
    textarea.val(content.substring(0,start) + text + content.substring(end,content.length));
    var position = start + text.length;
    $('#smilies_btn').click();
    textarea.get(0).setSelectionRange(position, position);
}

CSS代码有点多,我就不放出来了
调用:<link rel="stylesheet" href="http://www.littlehands.site/OwO/smilies.css">
下载:smilies.css

接着把符号替换成图片

修改评论输出内容
修改/var/Widget/Abstract/Comments.php文件,在100~150行左右
___content()函数,改成下面代码:

/**
 * 获取当前评论内容
 *
 * @access protected
 * @return string
 */
protected function ___content()
{
    $text = $this->parentContent['hidden'] ? _t('内容被隐藏') : $this->text;

    $text = $this->pluginHandle(__CLASS__)->trigger($plugged)->content($text, $this);
    if (!$plugged) {
        $text = $this->options->commentsMarkdown ? $this->markdown($text)
            : $this->autoP($text);
    }

    $text = $this->pluginHandle(__CLASS__)->contentEx($text, $this);
    $text = Typecho_Common::stripTags($text, '<p><br>' . $this->options->commentsHTMLTagAllowed);
    //return Typecho_Common::stripTags($text, '<p><br>' . $this->options->commentsHTMLTagAllowed);
    return preg_replace('#\@\((.*?)\)#','<img style="width:1.5rem;height:1.5rem;" src="http://file.littlehands.site/smilies/img/$1.png">',$text);
}

修改最近回复输出内容
也是/var/Widget/Abstract/Comments.php文件,在400~450行左右
excerpt()函数,改成下面代码:

/**
 * 输出评论摘要
 *
 * @access public
 * @param integer $length 摘要截取长度
 * @param string $trim 摘要后缀
 * @return void
 */
public function excerpt($length = 100, $trim = '...')
{
    //echo Typecho_Common::subStr(strip_tags($this->content), 0, $length, $trim);

    $content = $this->content;
    $t1 = strip_tags($content);
    $t2 = strip_tags($content,'<img>');
    $n2 = preg_match_all('/<img[^>]*>/',$t2,$a,PREG_OFFSET_CAPTURE);
    if ($n2 !== 0){
        $k = 0;
        $a[0][0][2] = $a[0][0][1] + 1;
        for($i= 1;$i < $n2;$i++){
            $k += mb_strlen($a[0][$i - 1][0],'utf-8');
            $a[0][$i][2] = $a[0][$i][3] - $k + $i;
        }
        for($i = 0;$i <$n2;$i++){
            if($a[0][$i][2] <= $length){
                $t1 = substr_replace($t1,$a[0][$i][0],$a[0][$i][4],0);
            }else{
                break;
            }
        }
        if($i == 0){
            echo mb_substr($t1,0,$length,'utf-8') . "$trim";
            return;
        }
        if($a[0][$i - 1][2] <= $length){
            echo "$t1";
        }else{
            echo $t1 . "$trim";
        }
        return;
    }
    if(mb_strlen($t1,'utf-8') <= $length){
        echo $t1;
    }else{
        echo mb_substr($t1,0,$length,'utf-8') . "$trim";
    }
}

修改CommentToMail插件 邮箱发件内容
修改插件目录下的Action.php文件,在240~250行左右
找到:

$mailer->SetFrom($this->_email->from, $this->_email->fromName);
$mailer->AddReplyTo($this->_email->to, $this->_email->toName);
$mailer->Subject = $this->_email->subject;
$mailer->AltBody = $this->_email->altBody;
$mailer->MsgHTML($this->_email->msgHtml);
$mailer->AddAddress($this->_email->to, $this->_email->toName);

改成:

$mailer->SetFrom($this->_email->from, $this->_email->fromName);
$mailer->AddReplyTo($this->_email->to, $this->_email->toName);
$mailer->Subject = preg_replace('#\@\((.*?)\)#','<img style="width:1.5rem;height:1.5rem;" src="http://file.littlehands.site/smilies/img/$1.png">',$this->_email->subject);
$mailer->AltBody = preg_replace('#\@\((.*?)\)#','<img style="width:1.5rem;height:1.5rem;" src="http://file.littlehands.site/smilies/img/$1.png">',$this->_email->altBody);
$mailer->MsgHTML(preg_replace('#\@\((.*?)\)#','<img style="width:1.5rem;height:1.5rem;" src="http://file.littlehands.site/smilies/img/$1.png">',$this->_email->msgHtml));
$mailer->AddAddress($this->_email->to, $this->_email->toName);

注意:

在修改时,要把http://file.littlehands.site/smilies/img/替换成你们表情包的链接

觉得上面的修改很麻烦话,可以在提交评论前,就把评论内容的符号替换掉

JS代码:
需要jquery

$('#comment-form').submit(function(){
    $('#textarea').val($('#textarea').val().replace(/\@\((.*?)\)/g,'<img style="width:1.5rem;height:1.5rem;" src="http://file.littlehands.site/smilies/img/$1.png">'));
});

作者:https://www.littlehands.site/archives/smilies.html