tetsunosukeのnotebook

tetsunosukeのメモです

Ustreamのchatにtelnetでつなぐ

接続するとこんな感じになる

$ telnet chat1.ustream.tv 6667
Trying 216.52.240.155...
Connected to chat1.ustream.tv.
Escape character is '^]'.
:chat2.ustream.tv NOTICE AUTH :*** Looking up your hostname...
:chat2.ustream.tv NOTICE AUTH :*** Found your hostname (cached)

認証とかをする

NICK <ustream_id> <ustream_pw>
USER <> 0 * :<name>

でjoinする。

join #<channel>

発言するにはこんな感じ。

PRIVMSG #channel test

で、PHPのNet_SmartIRCで接続しようと思ってずっとうまくいっていなかった。

サンプルは: http://www.phppro.jp/phptips/archives/vol36/1 あたりのを使うと良いと思うのだけど、

loginの部分がちと違うんですね。

    function login($nick, $realname, $usermode = 0, $username = null, $password = null)
    {
        $this->log(SMARTIRC_DEBUG_CONNECTION, 'DEBUG_CONNECTION: logging in', __FILE__, __LINE__);

        $this->_nick = str_replace(' ', '', $nick);
        $this->_realname = $realname;

        if ($username !== null) {
            $this->_username = str_replace(' ', '', $username);
        } else {
            $this->_username = str_replace(' ', '', exec('whoami'));
        }

        if ($password !== null) {
            $this->_password = $password;
            $this->_send('PASS '.$this->_password, SMARTIRC_CRITICAL);
        }

        if (!is_numeric($usermode)) {
            $this->log(SMARTIRC_DEBUG_NOTICE, 'DEBUG_NOTICE: login() usermode ('.$usermode.') is not valid, will use 0 instead', __FILE__, __LINE__);
            $usermode = 0;
        }
        // ここのNICKコマンドにパスワードをつけて送信させなきゃだめ!
        $this->_send('NICK '.$this->_nick, SMARTIRC_CRITICAL);
        $this->_send('USER '.$this->_username.' '.$usermode.' '.SMARTIRC_UNUSED.' :'.$this->_realname, SMARTIRC_CRITICAL);
    }

つーわけでNICKコマンド送信の部分をカスタマイズしないといけないっぽい。他は大丈夫だと思うけど。