OSDN Git Service

s/suffix/comment/ to fit mu protocol draft
authorISHIKAWA Mutsumi <ishikawa@hanzubon.jp>
Sat, 20 Oct 2012 04:43:23 +0000 (13:43 +0900)
committerISHIKAWA Mutsumi <ishikawa@hanzubon.jp>
Sat, 20 Oct 2012 04:43:23 +0000 (13:43 +0900)
mubot.mysql
mubot4fb.pl

index f670c99..7fa574d 100644 (file)
@@ -3,11 +3,11 @@ CREATE TABLE posts (
        submitter VARCHAR(32) NOT NULL,
        submitter_type INTEGER NOT NULL default 1,
        fb_post_id BIGINT UNSIGNED UNIQUE NOT NULL,
-       uri VARCHAR(512) NOT NULL,
+       uri VARCHAR(1024) NOT NULL,
        prefix VARCHAR(512) NOT NULL,
-       suffix VARCHAR(512) NOT NULL,
-       scheme VARCHAR(512) NOT NULL,
-       path VARCHAR(512) NOT NULL,
+       comment VARCHAR(1024) NOT NULL,
+       scheme VARCHAR(1024) NOT NULL,
+       path VARCHAR(1024) NOT NULL,
        post_time BIGINT UNSIGNED NOT NULL
 ) ENGINE = innodb DEFAULT CHARSET utf8;
 
index 083ee7d..04b2a43 100755 (executable)
@@ -95,12 +95,12 @@ sub _db_insert {
        my ($me, $db_args) = @_;
 
        my ($scheme, $path) = split(/:\/\//, $db_args->{uri});
-       my $sth = $me->{dbh}->prepare("insert into posts (submitter, fb_post_id, uri, prefix, suffix, scheme, path, post_time) values (?, ?, ?, ?, ?, ?, ?, ?)");
+       my $sth = $me->{dbh}->prepare("insert into posts (submitter, fb_post_id, uri, prefix, comment, scheme, path, post_time) values (?, ?, ?, ?, ?, ?, ?, ?)");
        $sth->bind_param(1, $db_args->{submitter}, SQL_VARCHAR);
        $sth->bind_param(2, $db_args->{fb_post_id}, SQL_BIGINT);
        $sth->bind_param(3, $db_args->{uri}, SQL_VARCHAR);
        $sth->bind_param(4, $db_args->{prefix}, SQL_VARCHAR);
-       $sth->bind_param(5, $db_args->{suffix}, SQL_VARCHAR);
+       $sth->bind_param(5, $db_args->{comment}, SQL_VARCHAR);
        $sth->bind_param(6, $scheme, SQL_VARCHAR);
        $sth->bind_param(7, $path, SQL_VARCHAR);
        $sth->bind_param(8, time, SQL_BIGINT);
@@ -132,7 +132,7 @@ sub _db_search {
 
        my $column = $word =~ /:\/\// ? 'uri' : 'path';
        my $w = '%' . $word . '%';
-       my $sth = $me->{dbh}->prepare('select * from posts where prefix like ? or '.$column.' like ? or suffix like ? order by post_time desc limit 1000');
+       my $sth = $me->{dbh}->prepare('select * from posts where prefix like ? or '.$column.' like ? or comment like ? order by post_time desc limit 1000');
        $sth->bind_param(1, $w, SQL_VARCHAR);
        $sth->bind_param(2, $w, SQL_VARCHAR);
        $sth->bind_param(3, $w, SQL_VARCHAR);
@@ -176,7 +176,7 @@ sub _fb_delete {
 sub _format_submit {
        my ($me, $e) = @_;
 
-       return $e->{submitter}.'が『'.$e->{prefix}.' '.$e->{uri}.' '.$e->{suffix}.'』と'.strftime('%Y-%m-%d %H:%M:%S', localtime($e->{post_time}));
+       return $e->{submitter}.'が『'.$e->{prefix}.' '.$e->{uri}.' '.$e->{comment}.'』と'.strftime('%Y-%m-%d %H:%M:%S', localtime($e->{post_time}));
 }
 
 sub _response {
@@ -194,8 +194,8 @@ sub _add {
        if ($args->{body} =~ /$mu_re/) {
                my $prefix = $1;
                my $uri = $2;
-               my $suffix = $3;
-               my $text = $args->{who} . '曰く、'.$prefix.' '.$suffix;
+               my $comment = $3;
+               my $text = $args->{who} . '曰く、'.$prefix.' '.$comment;
 
                return 0 if ($me->_check_dup($args, $uri));
 
@@ -212,7 +212,7 @@ sub _add {
                                         fb_post_id => $post_id,
                                         uri => $uri,
                                         prefix => $prefix,
-                                        suffix => $suffix});
+                                        comment => $comment});
                        $resp_msg = $args->{who} . ': うい  '.$me->_fb_post_uri($post_id).' で登録';
                } else {
                        $resp_msg = 'can not post to facebook';