Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new commands, Support steemradar.js
- New command for account posts - New command for top trending posts - Scene wizard for trending - Action handler for account posts - Steemradar.js for notifications.
- Loading branch information
1 parent
87319d4
commit 525e91e
Showing
19 changed files
with
303 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
NODE_ENV=development | ||
BOT_TOKEN=your_api_token | ||
BOT_TOKEN_DEV=your_development_api_token | ||
MONGODB_URI=your_mongo_db_uri |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
myaccount - view your profile | ||
myaccount - view your account profile | ||
myposts - get your account posts | ||
setaccount - setup your account in Steem blockchain | ||
notifications - manage your account notifications | ||
trending - get top trending posts | ||
cryptoprices - get current crypto prices in USD | ||
help - get some help! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const myPosts = require('./../commands/myposts'); | ||
|
||
/** | ||
* Action handler for account posts next/previous | ||
*/ | ||
module.exports = ctx => { | ||
const query = ctx.match[0].split(':'); | ||
const type = query[2].match(/(previous|next)/)[0]; | ||
let currentPage = parseInt(query[1]); | ||
|
||
switch (type) { | ||
case 'next': | ||
currentPage++; | ||
myPosts(ctx, { edit: true, currentPage }); | ||
break; | ||
case 'previous': | ||
currentPage--; | ||
myPosts(ctx, { edit: true, currentPage }); | ||
break; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
const Extra = require('telegraf/extra'); | ||
const Markup = require('telegraf/markup'); | ||
const { paginate } = require('../../utils'); | ||
const steem = require('steem'); | ||
const controller = require('../../controllers/account'); | ||
|
||
/** | ||
* Replies with Steem account posts | ||
*/ | ||
module.exports = async (ctx, opts = {}) => { | ||
const chatId = ctx.from.id; | ||
const account = await controller.getAccount(chatId); | ||
if (account && account.steemAccount) { | ||
const accountName = account.steemAccount; | ||
const posts = await steem.api.getDiscussionsByAuthorBeforeDateAsync( | ||
accountName, | ||
null, | ||
null, | ||
10 // limit | ||
); | ||
if (posts.length) { | ||
const buttons = posts.map(post => { | ||
return Markup.urlButton(post.title, 'https://steemit.com' + post.url); | ||
}); | ||
|
||
const currentPage = opts.currentPage || 1; // default for front-end | ||
const pageSize = 6; // posts per page | ||
const totalPages = Math.ceil(buttons.length / pageSize); // rounds the page number up to the next largest whole number or integer | ||
let currentPagePosts = paginate(buttons, pageSize, currentPage); | ||
|
||
const paginating = () => { | ||
const next = Markup.callbackButton( | ||
ctx.i18n.t('next'), | ||
`posts:${currentPage}:next` | ||
); | ||
const previous = Markup.callbackButton( | ||
ctx.i18n.t('previous'), | ||
`posts:${currentPage}:previous` | ||
); | ||
if (currentPage === totalPages) { | ||
return [previous]; | ||
} else if (currentPage === 1) { | ||
return [next]; | ||
} else { | ||
return [previous, next]; | ||
} | ||
}; | ||
|
||
const keyboard = Markup.inlineKeyboard( | ||
currentPagePosts.concat(paginating()), | ||
{ | ||
columns: 1 | ||
} | ||
) | ||
.resize() | ||
.oneTime(); | ||
if (opts.edit) { | ||
ctx.editMessageText( | ||
ctx.i18n.t('my-posts', { | ||
accountName: accountName, | ||
totalPages: totalPages, | ||
currentPage: currentPage | ||
}), | ||
Extra.markup(keyboard) | ||
); | ||
} else { | ||
ctx.reply( | ||
ctx.i18n.t('my-posts', { | ||
accountName: accountName, | ||
totalPages: totalPages, | ||
currentPage: currentPage | ||
}), | ||
Extra.markup(keyboard) | ||
); | ||
} | ||
} else { | ||
ctx.reply( | ||
ctx.i18n.t('no-posts', { | ||
accountName: accountName | ||
}) | ||
); | ||
} | ||
ctx.scene.leave(); | ||
} else { | ||
ctx.reply(ctx.i18n.t('please-setup-account')); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const Stage = require('telegraf/stage'); | ||
|
||
module.exports = Stage.enter('trending-wizard'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.