Skip to content

Instantly share code, notes, and snippets.

@2GMon
Created March 16, 2016 06:27
Show Gist options
  • Save 2GMon/58cfce0176da43fca69c to your computer and use it in GitHub Desktop.
Save 2GMon/58cfce0176da43fca69c to your computer and use it in GitHub Desktop.
twittperator work around
diff --git a/twittperator.js b/twittperator.js
index 62d5b55..b886a39 100644
--- a/twittperator.js
+++ b/twittperator.js
@@ -2081,6 +2081,30 @@ let INFO = xml`
});
}, // }}}
sourceScriptFile: function(file) { // {{{
+ const Script = Class("Script", {
+ init: function (file) {
+ let self = liberator.plugins.contexts[file.path];
+ if (self) {
+ if (self.onUnload)
+ self.onUnload();
+ return self;
+ }
+ liberator.plugins.contexts[file.path] = this;
+ this.NAME = file.leafName.replace(/\..*/, "").replace(/-([a-z])/g, function (m, n1) n1.toUpperCase());
+ this.PATH = file.path;
+ this.toString = this.toString;
+ this.__context__ = this;
+ this.__proto__ = liberator.plugins;
+
+ // This belongs elsewhere
+ for (let dir of io.getRuntimeDirectories("plugin")) {
+ if (dir.contains(file, false))
+ liberator.plugins[this.NAME] = this;
+ }
+ return this;
+ }
+ });
+
let self = this;
if (self._plugins.loaded[Utils.getPluginNameFromFile(file)])
@@ -2496,6 +2520,12 @@ let INFO = xml`
// アクセストークン取得後 {{{
function setup() {
function findSubCommand(s) { // {{{
+ SubCommands.iteritems = function iteritems() {
+ let length = SubCommands.length;
+ for (let i = 0; i < length; i++)
+ yield [i, SubCommands[i]];
+ };
+
for (let [, cmd] in util.Array(SubCommands)) {
let m = cmd.match(s);
if (m)
diff --git a/twittperator/echo-tweet.tw b/twittperator/echo-tweet.tw
index ff85e79..8d210f0 100644
--- a/twittperator/echo-tweet.tw
+++ b/twittperator/echo-tweet.tw
@@ -4,7 +4,7 @@
*/
(function () {
- plugins.twittperator.ChirpUserStream.addListener(
+ liberator.plugins.twittperator.ChirpUserStream.addListener(
function onMsg (msg, raw) {
if (msg.text)
liberator.echo(msg.user.screen_name + ": " + msg.text, commandline.FORCE_SINGLELINE);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment