# HG changeset patch # User David Demelier # Date 1465206597 -7200 # Node ID fea2e87c0fbe531e106e9126daed69e9fca6e663 # Parent 11bc287f7b5acb1a2bbc92eab89de6b47b99c87e Irccd: read info table diff -r 11bc287f7b5a -r fea2e87c0fbe lib/irccd/plugin-js.cpp --- a/lib/irccd/plugin-js.cpp Mon Jun 06 11:48:55 2016 +0200 +++ b/lib/irccd/plugin-js.cpp Mon Jun 06 11:49:57 2016 +0200 @@ -270,13 +270,25 @@ duk_get_global_string(m_context, "info"); if (duk_get_type(m_context, -1) == DUK_TYPE_OBJECT) { - // TODO: bring back -#if 0 - setAuthor(optionalProperty(m_context, -1, "author", author())); - setLicense(optionalProperty(m_context, -1, "license", license())); - setSummary(optionalProperty(m_context, -1, "summary", summary())); - setVersion(optionalProperty(m_context, -1, "version", version())); -#endif + // 'author' + duk_get_prop_string(m_context, -1, "author"); + setAuthor(duk_is_string(m_context, -1) ? duk_get_string(m_context, -1) : author()); + duk_pop(m_context); + + // 'license' + duk_get_prop_string(m_context, -1, "license"); + setLicense(duk_is_string(m_context, -1) ? duk_get_string(m_context, -1) : license()); + duk_pop(m_context); + + // 'summary' + duk_get_prop_string(m_context, -1, "summary"); + setSummary(duk_is_string(m_context, -1) ? duk_get_string(m_context, -1) : summary()); + duk_pop(m_context); + + // 'version' + duk_get_prop_string(m_context, -1, "version"); + setVersion(duk_is_string(m_context, -1) ? duk_get_string(m_context, -1) : version()); + duk_pop(m_context); } duk_pop(m_context); @@ -440,8 +452,8 @@ duk_put_prop_string(m_context, -2, "realname"); dukx_push_std_string(m_context, whois.host); duk_put_prop_string(m_context, -2, "host"); - // TODO - // duk_put_prop_string(m_context, -2, "channels", whois.channels); + dukx_push_array(m_context, whois.channels, dukx_push_std_string); + duk_put_prop_string(m_context, -2, "channels"); call("onWhois", 2); }