Update log storage plugin example for beta.3

cshd
Dragory 2020-10-03 16:15:02 +03:00
parent b80cb0ed15
commit bf4920f4b0
No known key found for this signature in database
GPG Key ID: 5F387BA66DF8AAC1
1 changed files with 5 additions and 5 deletions

View File

@ -36,18 +36,18 @@ To use this custom attachment storage type, you would set the `attachmentStorage
### Example of a custom log storage type ### Example of a custom log storage type
This example adds a custom type for the `logStorage` option called `"pastebin"` that uploads logs to Pastebin. This example adds a custom type for the `logStorage` option called `"pastebin"` that uploads logs to Pastebin.
The code that handles API calls to Pastebin is left out, as it's not relevant to the example.
```js ```js
module.exports = function({ logs, formatters }) { module.exports = function({ logs, formatters }) {
logs.addStorageType('pastebin', { logs.addStorageType('pastebin', {
async save(thread, threadMessages) { async save(thread, threadMessages) {
const formatLogResult = await formatters.formatLog(thread, threadMessages); const formatLogResult = await formatters.formatLog(thread, threadMessages);
// formatLogResult.content contains the log text const pastebinUrl = await saveToPastebin(formatLogResult); // saveToPastebin is an example function that returns the pastebin URL for the saved log
// Some code here that uploads the full text to Pastebin, and stores the Pastebin link in the database return { url: pastebinUrl };
}, },
getUrl(threadId) { getUrl(thread) {
// Find the previously-saved Pastebin link from the database based on the thread id, and return it return thread.log_storage_data.url;
} }
}); });
}; };