From 49ad8684366653eeb56e2db28bcce4e35e140c1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Pettersson?= Date: Tue, 2 Sep 2014 23:49:41 +0200 Subject: [PATCH] Added /bootstrap command. --- src/tox-weechat-commands.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/tox-weechat-commands.c b/src/tox-weechat-commands.c index 52e3147..34fd8ba 100644 --- a/src/tox-weechat-commands.c +++ b/src/tox-weechat-commands.c @@ -4,12 +4,34 @@ #include #include "tox-weechat.h" +#include "tox-weechat-tox.h" #include "tox-weechat-utils.h" #include "tox-weechat-chats.h" #include "tox-weechat-friend-requests.h" #include "tox-weechat-commands.h" +int +tox_weechat_cmd_bootstrap(void *data, struct t_gui_buffer *buffer, + int argc, char **argv, char **argv_eol) +{ + if (argc != 4) + return WEECHAT_RC_ERROR; + + char *address = argv[1]; + uint16_t port = atoi(argv[2]); + char *tox_address = argv[3]; + + if (!tox_weechat_bootstrap(address, port, tox_address)) + { + weechat_printf(tox_main_buffer, + "%sInvalid arguments for bootstrap.", + weechat_prefix("error")); + } + + return WEECHAT_RC_OK; +} + int tox_weechat_cmd_friend(void *data, struct t_gui_buffer *buffer, int argc, char **argv, char **argv_eol) @@ -326,6 +348,14 @@ tox_weechat_cmd_name(void *data, struct t_gui_buffer *buffer, void tox_weechat_commands_init() { + weechat_hook_command("bootstrap", + "bootstrap the Tox DHT", + "
", + " address: internet address of node to bootstrap with\n" + " port: port of the node\n" + "client id: Tox client of the node", + NULL, tox_weechat_cmd_bootstrap, NULL); + weechat_hook_command("friend", "manage friends", "list"