Si la musique est vide, on affiche autre-chose

master
Philippe Pittoli 2011-10-28 14:41:55 +02:00
parent 8ddc1b4e87
commit 6a84c1c8cf
1 changed files with 11 additions and 8 deletions

View File

@ -80,15 +80,18 @@ int cb_currentsong_plugin(void *data, struct t_gui_buffer *buffer, int argc, cha
{ {
for(i = 0 ; i < TAILLE_BUFFER_CURRENT_SONG ; i++) for(i = 0 ; i < TAILLE_BUFFER_CURRENT_SONG ; i++)
song[i] = '\0'; song[i] = '\0';
sprintf(song,"/currentsong didn't work !!! You should probably use the 'host <ip|url>' or 'port num' option"); snprintf(song, TAILLE_BUFFER_CURRENT_SONG, "%s didn't work !!! Look at the options !",argv[0]);
sprintf(affichage,"pluginerr\t%s",song); snprintf(affichage, TAILLE_BUFFER_CURRENT_SONG, "%s%s",weechat_prefix("error"),song);
weechat_printf(buffer,affichage); weechat_printf(buffer,affichage);
return WEECHAT_RC_ERROR; return WEECHAT_RC_ERROR;
} }
sprintf(affichage,"/me ♪ %s", song); if(strcmp("",song) == 0)
snprintf(affichage,TAILLE_BUFFER_CURRENT_SONG, "/me ! ♪");
else
snprintf(affichage,TAILLE_BUFFER_CURRENT_SONG, "/me ♪ %s", song);
//sprintf(affichage,"/me ♪ %s%s", weechat_color ("_red"), song); // Ne s'affiche pas correctement chez les autres //snprintf(affichage, TAILLE_BUFFER_CURRENT_SONG, "/me ♪ %s%s", weechat_color ("_red"), song);
//weechat_utf8_normalize(affichage, '?'); // Pour ne pas avoir de caractères non-lisibles //weechat_utf8_normalize(affichage, '?');
weechat_command(buffer,affichage); weechat_command(buffer,affichage);
@ -107,9 +110,9 @@ int weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]
weechat_hook_command ("currentsong", weechat_hook_command ("currentsong",
"Affiche le morceau que vous écoutez", "Affiche le morceau que vous écoutez",
"[host ip]", "[host <ip|url> [port]]",
"si mpd n'est pas en local : host <ip|url>", "si mpd n'est pas en local : host <ip|url> [port]",
"host ", "host %(the_host) %(the_port)",
&cb_currentsong_plugin, NULL); &cb_currentsong_plugin, NULL);
return WEECHAT_RC_OK; return WEECHAT_RC_OK;