-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add !foto command to take screenshot
- Loading branch information
Showing
12 changed files
with
752 additions
and
10 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
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 |
---|---|---|
|
@@ -15,6 +15,10 @@ class Notifier { | |
|
||
return Promise.resolve() | ||
} | ||
|
||
getBot () { | ||
return this.bot | ||
} | ||
} | ||
|
||
module.exports = Notifier |
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
Loading
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const config = require('../config') | ||
const puppeteer = require("puppeteer"); | ||
require('mathjs') | ||
|
||
async function getScreenshot() { | ||
const browser = await puppeteer.launch({headless: true}) | ||
const page = await browser.newPage() | ||
const session = await page.target().createCDPSession() | ||
await session.send("Page.enable") | ||
|
||
await page.setViewport({ width: 1920, height: 1080 }) | ||
|
||
await page.goto("https://www.twitch.tv/" + config.twitch.channels, { waitUntil: 'networkidle0' }) | ||
await page.waitForSelector('div.persistent-player') | ||
await page.$eval('.video-player__default-player', el => el.remove()) | ||
const svgImage = await page.$('div.persistent-player') | ||
const name = Math.random().toString(36).substring(2,8) | ||
const bufferImage = await svgImage.screenshot({ | ||
path: `public/images/${name}.png`, | ||
omitBackground: true | ||
}) | ||
await browser.close() | ||
|
||
return {buffer: bufferImage, fileName: `${name}.png` } | ||
} | ||
|
||
|
||
|
||
module.exports = { | ||
getScreenshot | ||
} |
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.