Giter Club home page Giter Club logo

hexchat-javascript's Introduction

HexChat Javascript

Build Status Coverity Badge

Javascript interface using Spidermonkey.

This plugin is no longer actively developed though bugs may be fixed.
I suggest using the Lua plugin shipping with modern HexChat as an alternative.

For more information check out the wiki.

Features

  • Load/unload/reload/autoloading scripts
  • Interpreter via /js
  • Runtime per script
  • Full coverage of hexchat api
  • Windows and Unix support

Requirements

  • HexChat 2.9.6+
  • JS 1.8.5

Installation

Windows:

  1. Place the javascript.dll in the addons folder within your config dir.
  2. Install Javascript, instructions are on the wiki.

Fedora:

  1. Download a repo file from here into /etc/yum.repos.d/
  2. yum install hexchat-javascript

Arch:

  1. Download package from hexchat-javascript-git on the AUR.
  2. Follow the wiki to install.

Building

Linux:

  1. Install the hexchat and js dev package from your distro of choice. (e.g. js-devel, libmozjs185-dev, js185)
  2. make && sudo make install

Windows:

  1. Install my build of Javascript as mentioned on the wiki and update its path in hexchat-javascript.props.
  2. Open in Visual Studio and build.

hexchat-javascript's People

Contributors

hasufell avatar tingping avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

hexchat-javascript's Issues

Update to spidermonkey 24

Work is being done in mozjs-24 branch.

One major issue is that most major distros don't ship this version in their repos afaik.

  • Get it building
  • Fix crashes
  • Build mozjs-24 on Windows w/ VS2013

License Incompatibility

As a derivative (also affects plugins) of hexchat, this project has to be GPLv2-compatible. (the MPL isn't)
SpiderMonkey, as part of Firefox, is afaik under multiple licenses MPL/GPL/LGPL, therefore a license change shouldn't be problematic.
GPLv2+ would be nice
good project ;)

HexChat crashes when a long array is passed to a hook_server callback function

I have the following code to display incoming Twitch whispers:

function whisperIn_cb(words) {
    // words example: [':[email protected]', 'WHISPER', 'danpcg', ':test', 'message']
    // should print "pcgdan > danpcg: test message"
    var nick = words[0].replace(/^:(.+)!.+$/, '$1');
    var msg = words.slice(3);
    msg[0] = msg[0].slice(1); // remove leading ":" (':test')

    print(nick + ' > ' + words[2] + ': ' + msg.join(' '));

    return EAT_ALL;
}

hook_server('WHISPER', whisperIn_cb);

It works fine unless the whispered message has more than 27 words. If the message has 28 words or more, the length of the array words is over 30, which probably causes the crash. The code in whisperIn_cb() is not important, as HexChat still crashes if the function is empty.

I have noticed, that if you pass an array that has over 30 elements to a hook_command callback function (e.g. a long outgoing whisper message), the array gets truncated to the length of 30. Is it possible to have arrays that are longer than 30 words? If not, can they at least be truncated for hook_server callback functions, to prevent the crash?

P.S. I have written the same function using the Python interface and it works without any issues (tested with a 100-word whisper).

Is it possible to somehow access a different context?

I would like to execute a command in a certain context from another context. For example if I type !test in context A, I want something to happen in context B. From what I have read, this is possible in the Python Interface, but I can't get it to work with JavaScript. The context is always undefined. Am I doing something wrong or does the JavaScript Interface not support context objects (the feature list states "Full coverage of hexchat api", so I'm not sure if context is a part of the API)?

This is a snippet of the code I tried.

function twitchWhisper(nick, msg) {
  var channels = get_list('channels');
  var server, channel, cnc;
  for(var c in channels) {
    if(channels[c].network == 'Twitch group chat' && channels[c].type == 2) {
      cnc = channels[c].context; // is undefined
      server = channels[c].server;
      channel = channels[c].channel;
      break;
    }
  }
  cnc = find_context(server, channel); // returns undefined
  cnc.command('PRIVMSG #jtv :/w ' + nick + ' ' + msg); // results in an error
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.