sm00th / bitlbee-discord

Bitlbee plugin for Discord (http://discordapp.com)
GNU General Public License v2.0
290 stars 27 forks source link

Add 'help discord' #99

Closed kensanata closed 6 years ago

kensanata commented 7 years ago

Add help discord such that people don't have to search "bitlbee discord how to" online whenever they want to join a new server or join new channels.

kensanata commented 7 years ago

Whoops, fixed pull request description.

kensanata commented 7 years ago

Standard options are documented as follows:

11:50 <kensanata> help set private
11:50 <root> Type: boolean
11:50 <root> Scope: global
11:50 <root> Default: true
11:50 <root>  
11:50 <root> If value is true, messages from users will appear in separate
    query windows. If false, messages from users will appear in a control
    channel.

Discord options are documented as follows:

11:50 <kensanata> help discord host
11:50 <root> host (type: string; default: "discordapp.com")
11:50 <root> Discord server hostname. Just in case discord changes the
    hostname or there are some alternatives with compatible API.

I'll go through the file and change the formatting and to use bold keywords for Type, Scope, and Default, but only if you want me to. As mentioned in a previous comment, using an external file might be easier to maintain. We don't have to use XML, we can simply use the txt format with embedded control characters for bold and all that.

sm00th commented 7 years ago

Tried this out and it doesn't seem to work if there are no discord accounts added. I guess that discord_init() is not the right place to register help.

The other thing is this blob of text in source code looks horrendous and I don't think merging it is a good idea. I'll see how we can move this into a separate file.

dequis commented 7 years ago

Tried this out and it doesn't seem to work if there are no discord accounts added. I guess that discord_init() is not the right place to register help.

Might be a limitation you'll have to deal with if you use help_add_mem, purple has a similar problem:

    g_string_append(help, "\n\nFor used protocols, more information about available "
                    "settings can be found using \x02help purple <protocol name>\x02 "
                    "(create an account using that protocol first!)");
kensanata commented 7 years ago

Maybe move it to init_plugin?

sm00th commented 7 years ago

Might be a limitation you'll have to deal with if you use help_add_mem, purple has a similar problem

Looking at the code it feels like purple has dynamic help and that the message about needing to create an account is available through help purple.

Maybe move it to init_plugin?

That is probably the right place for help even if it doesn't help solve the problem, just not in this state.

help_add_mem seems to be the only way to add entries to an existing help struct, so we'll need to parse the file on our own.

kensanata commented 7 years ago

I'm going to try and use help_init.

sm00th commented 7 years ago

I'm going to try and use help_init. help_init allocates new help_t, so if you are planning to give it global.help it'll just replace normal help with yours

kensanata commented 7 years ago

Sure. Take a look at d0bcf0d. I call help_init and append the new help entries to global.help. There are two issues I need help with, however:

  1. How to fix the Makefile such that it copies src/discord_help.txt to VARDIR as defined in Bitlbee's config.h, assuming that is where we would expect the file? Alternatively, PLUGINDIR but then I need a way to get the filename in discord_help_init.
  2. Stress test the fix: at one point I had the impression that making changes to /usr/local/share/bitlbee/discord-help.txt triggered a reload of the original help file and subsequently a loss of all Discord help items.

The second point might not be all that important, I guess? But who knows.

kensanata commented 7 years ago

Should I squash these commits? I don't think the intermediate revisions add anything.

sm00th commented 7 years ago

Gosh github is confusing. You can find my comments at https://github.com/sm00th/bitlbee-discord/commit/ba0fe9c559369fac27fd4c4e75f2ca5fd6c748f3 (for some reason)

kensanata commented 7 years ago

Yeah, that happened because I rebased all my changes since you merged the two other branches, which resulted in all the commits getting new hashes, so now the comments are attached to hashes that aren't part of the actual branch anymore. I hadn't considered that, when I forced pushed the rebased branch.

kensanata commented 7 years ago

To summarize the open issues from ba0fe9c:

sm00th commented 7 years ago
  • when to call discord_help_init – global.helpfile is not set in init_plugin but init_plugin_info is too late: help is unavailable when no discord account has been created

At this point we don't have a choice but to move discord_help_init() call into discord_init(). It is a good idea to see if help global.helpfile/help initialization can be moved before plugin load in bitlbee, but this will take some time and we'll still want to maintain compatibility with older versions of bitlbee anyway.

  • the help file has to get installed by make install

I'll do that when I merge this branch.

sm00th commented 6 years ago

Merged manually in https://github.com/sm00th/bitlbee-discord/commit/1d67b20daa3b877c85be6f2fd3a79009f853ac33