-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
280 additions
and
159 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
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,10 @@ | ||
const { Composer } = require('telegraf').default | ||
const composer = new Composer() | ||
|
||
// composer.on('chosen_inline_result', async ctx => { | ||
// console.log(ctx.update.chosen_inline_result) | ||
// }) | ||
|
||
module.exports = app => { | ||
app.use(composer.middleware()) | ||
} |
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,3 @@ | ||
const Composer = require('telegraf/composer') | ||
const composer = new Composer() | ||
const getFiles = require('../lib/get-files') |
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,76 @@ | ||
const Composer = require('telegraf/composer') | ||
const composer = new Composer() | ||
const getFiles = require('../lib/get-files') | ||
|
||
composer.command('pool', async ctx => { | ||
if (ctx.from.id === Number.parseInt(process.env.ADMIN_ID)) { | ||
ctx.reply(`Here's ${Object.keys(getFiles.cachePool()).length} chapters waiting to be cached.`, { | ||
reply_markup: { | ||
inline_keyboard: cacheKeyboard( | ||
getFiles.getCacheBlockingValue(), | ||
getFiles.getUpdateCachingBlockingValue() | ||
) | ||
} | ||
}) | ||
} | ||
}) | ||
composer.action(/^cachepool=(\S+)$/i, async ctx => { | ||
if (ctx.from.id === Number.parseInt(process.env.ADMIN_ID)) { | ||
switch (ctx.match[1]) { | ||
case 'on': | ||
getFiles.setCachingBlocking(true) | ||
break | ||
case 'off': | ||
getFiles.setCachingBlocking(false) | ||
break | ||
} | ||
ctx.editMessageReplyMarkup({ | ||
inline_keyboard: cacheKeyboard( | ||
getFiles.getCacheBlockingValue(), | ||
getFiles.getUpdateCachingBlockingValue() | ||
) | ||
}) | ||
} else { | ||
return ctx.editMessageReplyMarkup({ inline_keyboard: [] }) | ||
} | ||
}) | ||
|
||
composer.action(/^updatecache=(\S+)$/i, async ctx => { | ||
if (ctx.from.id === Number.parseInt(process.env.ADMIN_ID)) { | ||
switch (ctx.match[1]) { | ||
case 'on': | ||
getFiles.setUpdateCachingBlocking(true) | ||
break | ||
case 'off': | ||
getFiles.setUpdateCachingBlocking(false) | ||
break | ||
} | ||
ctx.editMessageReplyMarkup({ | ||
inline_keyboard: cacheKeyboard( | ||
getFiles.getCacheBlockingValue(), | ||
getFiles.getUpdateCachingBlockingValue() | ||
) | ||
}) | ||
} else { | ||
return ctx.editMessageReplyMarkup({ inline_keyboard: [] }) | ||
} | ||
}) | ||
|
||
module.exports = app => { | ||
app.use(composer.middleware()) | ||
} | ||
|
||
function cacheKeyboard (cacheBlock, updateBlock) { | ||
return [ | ||
[ | ||
{ | ||
text: `${cacheBlock ? 'Enable' : 'Disable'} caching`, | ||
callback_data: `cachepool=${cacheBlock ? 'off' : 'on'}` | ||
}, | ||
{ | ||
text: `${updateBlock ? 'Enable' : 'Disable'} updating`, | ||
callback_data: `updatecache=${updateBlock ? 'off' : 'on'}` | ||
} | ||
] | ||
] | ||
} |
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,5 @@ | ||
module.exports = app => { | ||
require('./start')(app) | ||
require('./search')(app) | ||
require('./get-cache-pool')(app) | ||
} |
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 |
---|---|---|
|
@@ -131,4 +131,4 @@ module.exports = collectionName => { | |
} else { | ||
throw new Error('Collection not found') | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.