summaryrefslogtreecommitdiff
path: root/src/server/api/bot
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-04-08 02:30:37 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-04-08 02:30:37 +0900
commita1b490afa756a71b9cef4afa424575bc223bc612 (patch)
tree06de4d839e17b1e08e0891542af7360c701a154a /src/server/api/bot
parentMerge pull request #1392 from syuilo/greenkeeper/element-ui-2.3.3 (diff)
downloadsharkey-a1b490afa756a71b9cef4afa424575bc223bc612.tar.gz
sharkey-a1b490afa756a71b9cef4afa424575bc223bc612.tar.bz2
sharkey-a1b490afa756a71b9cef4afa424575bc223bc612.zip
Post --> Note
Closes #1411
Diffstat (limited to 'src/server/api/bot')
-rw-r--r--src/server/api/bot/core.ts22
-rw-r--r--src/server/api/bot/interfaces/line.ts18
2 files changed, 20 insertions, 20 deletions
diff --git a/src/server/api/bot/core.ts b/src/server/api/bot/core.ts
index a44aa9d7bc..1cf0522349 100644
--- a/src/server/api/bot/core.ts
+++ b/src/server/api/bot/core.ts
@@ -3,7 +3,7 @@ import * as bcrypt from 'bcryptjs';
import User, { IUser, init as initUser, ILocalUser } from '../../../models/user';
-import getPostSummary from '../../../renderers/get-post-summary';
+import getNoteSummary from '../../../renderers/get-note-summary';
import getUserName from '../../../renderers/get-user-name';
import getUserSummary from '../../../renderers/get-user-summary';
import parseAcct from '../../../acct/parse';
@@ -83,7 +83,7 @@ export default class BotCore extends EventEmitter {
'me: アカウント情報を見ます\n' +
'login, signin: サインインします\n' +
'logout, signout: サインアウトします\n' +
- 'post: 投稿します\n' +
+ 'note: 投稿します\n' +
'tl: タイムラインを見ます\n' +
'no: 通知を見ます\n' +
'@<ユーザー名>: ユーザーを表示します\n' +
@@ -109,10 +109,10 @@ export default class BotCore extends EventEmitter {
this.signout();
return 'ご利用ありがとうございました <3';
- case 'post':
+ case 'note':
case '投稿':
if (this.user == null) return 'まずサインインしてください。';
- this.setContext(new PostContext(this));
+ this.setContext(new NoteContext(this));
return await this.context.greet();
case 'tl':
@@ -190,7 +190,7 @@ abstract class Context extends EventEmitter {
public static import(bot: BotCore, data: any) {
if (data.type == 'guessing-game') return GuessingGameContext.import(bot, data.content);
- if (data.type == 'post') return PostContext.import(bot, data.content);
+ if (data.type == 'note') return NoteContext.import(bot, data.content);
if (data.type == 'tl') return TlContext.import(bot, data.content);
if (data.type == 'notifications') return NotificationsContext.import(bot, data.content);
if (data.type == 'signin') return SigninContext.import(bot, data.content);
@@ -254,13 +254,13 @@ class SigninContext extends Context {
}
}
-class PostContext extends Context {
+class NoteContext extends Context {
public async greet(): Promise<string> {
return '内容:';
}
public async q(query: string): Promise<string> {
- await require('../endpoints/posts/create')({
+ await require('../endpoints/notes/create')({
text: query
}, this.bot.user);
this.bot.clearContext();
@@ -269,12 +269,12 @@ class PostContext extends Context {
public export() {
return {
- type: 'post'
+ type: 'note'
};
}
public static import(bot: BotCore, data: any) {
- const context = new PostContext(bot);
+ const context = new NoteContext(bot);
return context;
}
}
@@ -296,7 +296,7 @@ class TlContext extends Context {
}
private async getTl() {
- const tl = await require('../endpoints/posts/timeline')({
+ const tl = await require('../endpoints/notes/timeline')({
limit: 5,
untilId: this.next ? this.next : undefined
}, this.bot.user);
@@ -306,7 +306,7 @@ class TlContext extends Context {
this.emit('updated');
const text = tl
- .map(post => `${getUserName(post.user)}\n「${getPostSummary(post)}」`)
+ .map(note => `${getUserName(note.user)}\n「${getNoteSummary(note)}」`)
.join('\n-----\n');
return text;
diff --git a/src/server/api/bot/interfaces/line.ts b/src/server/api/bot/interfaces/line.ts
index 1191aaf391..b6b0c257e9 100644
--- a/src/server/api/bot/interfaces/line.ts
+++ b/src/server/api/bot/interfaces/line.ts
@@ -9,7 +9,7 @@ import _redis from '../../../../db/redis';
import prominence = require('prominence');
import getAcct from '../../../../acct/render';
import parseAcct from '../../../../acct/parse';
-import getPostSummary from '../../../../renderers/get-post-summary';
+import getNoteSummary from '../../../../renderers/get-note-summary';
import getUserName from '../../../../renderers/get-user-name';
const redis = prominence(_redis);
@@ -80,14 +80,14 @@ class LineBot extends BotCore {
}
break;
- // postback
- case 'postback':
- const data = ev.postback.data;
+ // noteback
+ case 'noteback':
+ const data = ev.noteback.data;
const cmd = data.split('|')[0];
const arg = data.split('|')[1];
switch (cmd) {
case 'showtl':
- this.showUserTimelinePostback(arg);
+ this.showUserTimelineNoteback(arg);
break;
}
break;
@@ -107,7 +107,7 @@ class LineBot extends BotCore {
const actions = [];
actions.push({
- type: 'postback',
+ type: 'noteback',
label: 'タイムラインを見る',
data: `showtl|${user.id}`
});
@@ -141,14 +141,14 @@ class LineBot extends BotCore {
return null;
}
- public async showUserTimelinePostback(userId: string) {
- const tl = await require('../../endpoints/users/posts')({
+ public async showUserTimelineNoteback(userId: string) {
+ const tl = await require('../../endpoints/users/notes')({
userId: userId,
limit: 5
}, this.user);
const text = `${getUserName(tl[0].user)}さんのタイムラインはこちらです:\n\n` + tl
- .map(post => getPostSummary(post))
+ .map(note => getNoteSummary(note))
.join('\n-----\n');
this.reply([{