Skip to content

Commit

Permalink
Added nowplaying alias, update lava-xm-plugin, only require natives w…
Browse files Browse the repository at this point in the history
…hen processing images locally, reimplement cache limit
  • Loading branch information
TheEssem committed Aug 22, 2022
1 parent 3d97811 commit 1cafef7
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ lavalink:
twitch: true
vimeo: true
mixer: true
http: false
http: true
local: true
bufferDurationMs: 400
youtubePlaylistLoadLimit: 6 # Number of pages at 100 each
Expand All @@ -26,7 +26,7 @@ lavalink:
#searchTriggersFail: true # Whether a search 429 should trigger marking the ip as failing
#retryLimit: -1 # -1 = use default lavaplayer value | 0 = infinity | >0 = retry will happen this numbers times
plugins:
- dependency: "com.github.esmBot:lava-xm-plugin:v0.1.0"
- dependency: "com.github.esmBot:lava-xm-plugin:v0.2.0"
repository: "https://jitpack.io"
- dependency: "com.github.Topis-Lavalink-Plugins:Topis-Source-Managers-Plugin:v2.0.7"
repository: "https://jitpack.io"
Expand Down
2 changes: 1 addition & 1 deletion commands/music/nowplaying.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class NowPlayingCommand extends MusicCommand {
}

static description = "Shows the currently playing song";
static aliases = ["playing", "np"];
static aliases = ["playing", "np", "current"];
}

export default NowPlayingCommand;
2 changes: 1 addition & 1 deletion docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Choose the distro you're using below for insallation instructions.
[libvips](https://github.com/libvips/libvips) is the core of esmBot's image processing commands. The latest version (8.13.0) is recommended because it contains fixes to GIF handling and support for the freeze command; however, this version isn't packaged for most distros yet. To fix this, you'll need to build libvips from source.

!!! note
Alpine and Arch users can skip this step, since both distros now have 8.13.0 packaged.
Alpine, Arch, and RHEL **(not Fedora!)** users can skip this step, since these distros now have 8.13.0 packaged.

First, download the source and move into it:
```sh
Expand Down
10 changes: 5 additions & 5 deletions utils/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class TimedMap extends Map {

export const runningCommands = new TimedMap();

/*class Cache extends Map {
class Cache extends Map {
constructor(values) {
super(values);
this.maxValues = 2048;
Expand All @@ -26,8 +26,8 @@ export const runningCommands = new TimedMap();
super.set(key, value);
if (this.size > this.maxValues) this.delete(this.keys().next().value);
}
}*/
}

export const prefixCache = new Map();
export const disabledCache = new Map();
export const disabledCmdCache = new Map();
export const prefixCache = new Cache();
export const disabledCache = new Cache();
export const disabledCmdCache = new Cache();
6 changes: 3 additions & 3 deletions utils/image-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { fileURLToPath } from "url";
const nodeRequire = createRequire(import.meta.url);

const relPath = `../build/${process.env.DEBUG && process.env.DEBUG === "true" ? "Debug" : "Release"}/image.node`;
const magick = nodeRequire(relPath);
const img = nodeRequire(relPath);

const enumMap = {
"forget": 0,
Expand All @@ -33,7 +33,7 @@ export default function run(object) {
});
promise = request(object.path).then(res => res.body.arrayBuffer()).then(buf => Buffer.from(buf));
}
// Convert from a MIME type (e.g. "image/png") to something ImageMagick understands (e.g. "png").
// Convert from a MIME type (e.g. "image/png") to something the image processor understands (e.g. "png").
// Don't set `type` directly on the object we are passed as it will be read afterwards.
// If no image type is given (say, the command generates its own image), make it a PNG.
const fileExtension = object.params.type ? object.params.type.split("/")[1] : "png";
Expand All @@ -47,7 +47,7 @@ export default function run(object) {
}
objectWithFixedType.basePath = path.join(path.dirname(fileURLToPath(import.meta.url)), "../");
try {
const result = magick[object.cmd](objectWithFixedType);
const result = img[object.cmd](objectWithFixedType);
const returnObject = {
buffer: result.data,
fileExtension: result.type
Expand Down
4 changes: 3 additions & 1 deletion utils/services/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import EventEmitter from "events";

// only requiring this to work around an issue regarding worker threads
const nodeRequire = createRequire(import.meta.url);
nodeRequire(`../../build/${process.env.DEBUG && process.env.DEBUG === "true" ? "Debug" : "Release"}/image.node`);
if (process.env.API_TYPE === "none") {
nodeRequire(`../../build/${process.env.DEBUG && process.env.DEBUG === "true" ? "Debug" : "Release"}/image.node`);
}

import ImageConnection from "../imageConnection.js";

Expand Down

0 comments on commit 1cafef7

Please sign in to comment.