diff options
-rw-r--r-- | ChangeLog.asciidoc | 2 | ||||
-rw-r--r-- | ReleaseNotes.asciidoc | 2 | ||||
-rw-r--r-- | doc/asciidoc.conf | 1 | ||||
-rw-r--r-- | doc/de/weechat_faq.de.txt | 4 | ||||
-rw-r--r-- | doc/de/weechat_user.de.txt | 4 | ||||
-rw-r--r-- | doc/en/weechat_faq.en.txt | 4 | ||||
-rw-r--r-- | doc/en/weechat_user.en.txt | 4 | ||||
-rw-r--r-- | doc/fr/weechat_faq.fr.txt | 4 | ||||
-rw-r--r-- | doc/fr/weechat_user.fr.txt | 4 | ||||
-rw-r--r-- | doc/it/weechat_faq.it.txt | 4 | ||||
-rw-r--r-- | doc/it/weechat_user.it.txt | 6 | ||||
-rw-r--r-- | doc/ja/weechat_faq.ja.txt | 4 | ||||
-rw-r--r-- | doc/ja/weechat_user.ja.txt | 4 | ||||
-rw-r--r-- | doc/pl/weechat_faq.pl.txt | 4 | ||||
-rw-r--r-- | doc/pl/weechat_user.pl.txt | 6 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-key.c | 2 | ||||
-rwxr-xr-x | test/weercd.py | 171 |
17 files changed, 119 insertions, 111 deletions
diff --git a/ChangeLog.asciidoc b/ChangeLog.asciidoc index 1db9db3a4..90e8bd1a1 100644 --- a/ChangeLog.asciidoc +++ b/ChangeLog.asciidoc @@ -69,7 +69,7 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] * core: add options "-beep" and "-current" in command /print * core: allow empty arguments for command /print * core: add bare display mode (for easy text selection and click on URLs), new - key: key[alt-!], new option "bare" in command /window, new options: + key: key[alt-l], new option "bare" in command /window, new options: weechat.look.bare_display_exit_on_input and weechat.look.bare_display_time_format * core: fix freeze/crash in gnutls (bug #41576) diff --git a/ReleaseNotes.asciidoc b/ReleaseNotes.asciidoc index 0d6a9b524..cee6c3be9 100644 --- a/ReleaseNotes.asciidoc +++ b/ReleaseNotes.asciidoc @@ -87,7 +87,7 @@ obsolete plugins). === Bare display A bare display mode has been added (for easy text selection and click on URLs), -the new default key is key[alt-!]. +the new default key is key[alt-l]. Use command `/key missing` to add the key or `/key listdiff` to see differences between your current keys and WeeChat default keys. diff --git a/doc/asciidoc.conf b/doc/asciidoc.conf index d250c2ca2..a30091bdf 100644 --- a/doc/asciidoc.conf +++ b/doc/asciidoc.conf @@ -6,7 +6,6 @@ key\[([^,\]]+),([^\]]+)\]=key[\1], key[\2] key\[(ctrl|alt|shift)\]=<span class="key \1">\1</span> key\[(ctrl|alt|shift)-\]=<span class="key \1">\1</span><span class="keyplus">+</span> key\[(ctrl|alt|shift)-([^\]]+)\]=<span class="key \1">\1</span><span class="keyplus">+</span>key[\2] -key\[l\]=<span class="key">l</span><span class="keyplus"> (L)</span> key\[([A-Za-z0-9/_&\=!-])\]=<span class="key">\1</span> key\[([a-z0-9/_&\=!-][^\]]*)\]=<span class="key">\1</span> key\[([^\]]+)\]=<span class="key other">\1</span> diff --git a/doc/de/weechat_faq.de.txt b/doc/de/weechat_faq.de.txt index 7ccd02402..4915e7332 100644 --- a/doc/de/weechat_faq.de.txt +++ b/doc/de/weechat_faq.de.txt @@ -227,7 +227,7 @@ werden sollte: [[terminal_copy_paste]] === Wie kann ich einen Text kopieren und einfügen ohne das die Nickliste mit kopiert wird? -Ab WeeChat ≥ 1.0 kann ein einfacher Anzeigemodus genutzt werden (Standardtastenbelegung: key[alt-!]). +Ab WeeChat ≥ 1.0 kann ein einfacher Anzeigemodus genutzt werden (Standardtastenbelegung: key[alt-l]). Hierzu kannst Du ein Terminal nutzen welches Block-Auswahl erlaubt (wie z.B. rxvt-unicode, konsole, gnome-terminal, ...). Im Normalfall erfolgt die Markierung mittels der Tasten @@ -243,7 +243,7 @@ Bildschirm zu positionieren: [[urls]] === Wie kann ich eine URL aufrufen die einen Zeilenumbruch besitzt? -Ab WeeChat ≥ 1.0 kann ein einfacher Anzeigemodus genutzt werden (Standardtastenbelegung: key[alt-!]). +Ab WeeChat ≥ 1.0 kann ein einfacher Anzeigemodus genutzt werden (Standardtastenbelegung: key[alt-l]). WeeChat stellt standardmäßig die Uhrzeit als auch einen Präfix in jeder Zeile dar. Optional können zusätzlich auch Bars im Chatfenster dargestellt diff --git a/doc/de/weechat_user.de.txt b/doc/de/weechat_user.de.txt index 28e4b83f2..de73254fe 100644 --- a/doc/de/weechat_user.de.txt +++ b/doc/de/weechat_user.de.txt @@ -889,7 +889,7 @@ Der vereinfachte Anzeigemodus hat folgende Funktionen: wie in einem Terminal genutzt werden um URLs anzuklicken oder Text zu markieren * ncurses wird nicht genutzt, deshalb werden URLs nicht am Ende der Zeile angeschnitten. -Der Standardtastenbefehl um den vereinfachten Textmodus zu aktivieren ist key[alt-!], +Der Standardtastenbefehl um den vereinfachten Textmodus zu aktivieren ist key[alt-l], mit dem selben Tastenbefehl wird dieser Modus wieder beendet (es kann auch mit jeder beliegen Tasteneingabe der Modus beendet werden, siehe Option <<option_weechat.look.bare_display_exit_on_input,weechat.look.bare_display_exit_on_input>>). @@ -1100,6 +1100,7 @@ Befehl festgelegt werden: | key[alt-j,alt-s] | wechselt zum IRC Server Buffer | `/server jump` | key[alt-0...9] | wechselt zum Buffer mit der Nummer (0 = 10) | `/buffer *N` | key[alt-j,01...99] | wechselt zum Buffer mit der angegeben Nummer | `/buffer NN` +| key[alt-l] | schaltet einfachen Anzeigemodus an/aus | `/window bare` | key[alt-m] | schaltet Mausfunktion ein/aus | `/mouse toggle` | key[alt-n] | springt zur nächsten Highlight Nachricht | `/window scroll_next_highlight` | key[alt-p] | springt zur vorherigen Highlight Nachricht | `/window scroll_previous_highlight` @@ -1116,7 +1117,6 @@ Befehl festgelegt werden: | key[alt-/] | wechselt zum jeweils zuletzt angezeigten Buffern | `/input jump_last_buffer_displayed` | key[alt-=] | schaltet Filterfunktion an/aus | `/filter toggle` | key[alt--] | schaltet, für den aktuellen Buffer, Filterfunktion an/aus | `/filter toggle @` -| key[alt-!] | schaltet einfachen Anzeigemodus an/aus | `/window bare` |=== [[key_bindings_search_context]] diff --git a/doc/en/weechat_faq.en.txt b/doc/en/weechat_faq.en.txt index 6dd0bc5fa..d12a7fc74 100644 --- a/doc/en/weechat_faq.en.txt +++ b/doc/en/weechat_faq.en.txt @@ -216,7 +216,7 @@ any bar: [[terminal_copy_paste]] === How can I copy/paste text without pasting nicklist? -With WeeChat ≥ 1.0, you can use the bare display (default key: key[alt-!]). +With WeeChat ≥ 1.0, you can use the bare display (default key: key[alt-l]). You can use a terminal with rectangular selection (like rxvt-unicode, konsole, gnome-terminal, ...). Key is usually key[ctrl-]key[alt-] mouse @@ -231,7 +231,7 @@ Another solution is to move nicklist to top or bottom, for example: [[urls]] === How can I click on long URLs (more than one line)? -With WeeChat ≥ 1.0, you can use the bare display (default key: key[alt-!]). +With WeeChat ≥ 1.0, you can use the bare display (default key: key[alt-l]). By default, WeeChat displays time and prefix for each line and optional bars around chat area. To make easier URL click, you can move nicklist to top and diff --git a/doc/en/weechat_user.en.txt b/doc/en/weechat_user.en.txt index 83694c36c..2631c7327 100644 --- a/doc/en/weechat_user.en.txt +++ b/doc/en/weechat_user.en.txt @@ -878,7 +878,7 @@ The bare display has following features: mouse like you do in the terminal to click on URLs and select text * ncurses is not used, therefore URLs are not cut at the end of lines. -The default key to enabled bare display is key[alt-!], and same key to exit (or +The default key to enabled bare display is key[alt-l], and same key to exit (or by default anything changing the input will exit the bare display, see option <<option_weechat.look.bare_display_exit_on_input,weechat.look.bare_display_exit_on_input>>). @@ -1084,6 +1084,7 @@ The notify level for a buffer can be set with command `/buffer`: | key[alt-j,alt-s] | Switch to IRC server buffer | `/server jump` | key[alt-0...9] | Switch to buffer by number (0 = 10) | `/buffer *N` | key[alt-j,01...99] | Switch to buffer by number | `/buffer NN` +| key[alt-l] | Toggle bare display on/off | `/window bare` | key[alt-m] | Toggle mouse | `/mouse toggle` | key[alt-n] | Scroll to next highlight | `/window scroll_next_highlight` | key[alt-p] | Scroll to previous highlight | `/window scroll_previous_highlight` @@ -1100,7 +1101,6 @@ The notify level for a buffer can be set with command `/buffer`: | key[alt-/] | Switch to last buffer displayed (before last jump to a buffer) | `/input jump_last_buffer_displayed` | key[alt-=] | Toggle filters on/off | `/filter toggle` | key[alt--] | Toggle filters on/off in current buffer | `/filter toggle @` -| key[alt-!] | Toggle bare display on/off | `/window bare` |=== [[key_bindings_search_context]] diff --git a/doc/fr/weechat_faq.fr.txt b/doc/fr/weechat_faq.fr.txt index cffc8beb8..7ec96c9be 100644 --- a/doc/fr/weechat_faq.fr.txt +++ b/doc/fr/weechat_faq.fr.txt @@ -223,7 +223,7 @@ barre, WeeChat recréera automatiquement la barre par défaut "input" si l'objet === Comment puis-je copier/coller du texte sans coller la liste des pseudos ? Avec WeeChat ≥ 1.0, vous pouvez utiliser l'affichage dépouillé (touche par -défaut : key[alt-!]). +défaut : key[alt-l]). Vous pouvez utiliser un terminal qui propose la sélection rectangulaire (comme rxvt-unicode, konsole, gnome-terminal, etc...). La touche est habituellement @@ -240,7 +240,7 @@ exemple : === Comment puis-je cliquer sur les longs URLs (plus d'une ligne) ? Avec WeeChat ≥ 1.0, vous pouvez utiliser l'affichage dépouillé (touche par -défaut : key[alt-!]). +défaut : key[alt-l]). Par défaut, WeeChat affiche l'heure et un préfixe pour chaque ligne avec des barres optionnelles autour de la zone de discussion. Pour rendre la le clic diff --git a/doc/fr/weechat_user.fr.txt b/doc/fr/weechat_user.fr.txt index acb08fe6f..2aa0d1d4c 100644 --- a/doc/fr/weechat_user.fr.txt +++ b/doc/fr/weechat_user.fr.txt @@ -904,7 +904,7 @@ L'affichage dépouillé a les caractéristiques suivantes : * ncurses n'est pas utilisé, par conséquent les URLs ne sont pas coupés en fin de ligne. -La touche par défaut pour activer l'affichage dépouillé est key[alt-!], et la +La touche par défaut pour activer l'affichage dépouillé est key[alt-l], et la même touche pour en sortir (ou par défaut tout changement dans la ligne de commande sortira de l'affichage dépouillé, voir l'option <<option_weechat.look.bare_display_exit_on_input,weechat.look.bare_display_exit_on_input>>). @@ -1113,6 +1113,7 @@ commande `/buffer` : | key[alt-j,alt-s] | Sauter au tampon IRC du serveur | `/server jump` | key[alt-0...9] | Sauter au tampon qui porte ce numéro (0 = 10) | `/buffer *N` | key[alt-j,01...99] | Sauter au tampon qui porte ce numéro | `/buffer NN` +| key[alt-l] | Activer/désactiver le mode d'affichage dépouillé | `/window bare` | key[alt-m] | Activer/désactiver la souris | `/mouse toggle` | key[alt-n] | Se positionner sur le highlight suivant | `/window scroll_next_highlight` | key[alt-p] | Se positionner sur le highlight précédent | `/window scroll_previous_highlight` @@ -1129,7 +1130,6 @@ commande `/buffer` : | key[alt-/] | Sauter au dernier tampon affiché (avant le dernier saut vers un tampon) | `/input jump_last_buffer_displayed` | key[alt-=] | Activer/désactiver les filtres | `/filter toggle` | key[alt--] | Activer/désactiver les filtres dans le tampon courant | `/filter toggle @` -| key[alt-!] | Activer/désactiver le mode d'affichage dépouillé | `/window bare` |=== [[key_bindings_search_context]] diff --git a/doc/it/weechat_faq.it.txt b/doc/it/weechat_faq.it.txt index 5e27ae77f..24ec5671e 100644 --- a/doc/it/weechat_faq.it.txt +++ b/doc/it/weechat_faq.it.txt @@ -226,7 +226,7 @@ non viene usato da un'altra barra: === Come posso copiare/incollare testo senza incollare la lista nick? // TRANSLATION MISSING -With WeeChat ≥ 1.0, you can use the bare display (default key: key[alt-!]). +With WeeChat ≥ 1.0, you can use the bare display (default key: key[alt-l]). È possibile usare un terminale con la selezione rettangolare (come rxvt-unicode, konsole, gnome-terminal, ...). La combinazione tasti in @@ -242,7 +242,7 @@ Un'altra soluzione è spostare la lista nick in alto o in basso, per esempio: === Come posso cliccare su URL lunghi (più di una riga)? // TRANSLATION MISSING -With WeeChat ≥ 1.0, you can use the bare display (default key: key[alt-!]). +With WeeChat ≥ 1.0, you can use the bare display (default key: key[alt-l]). Con le impostazioni predefinite, WeeChat mostra l'ora ed il prefisso per ogni riga e le barre opzionali intorno all'area di chat. Per facilitare il clic diff --git a/doc/it/weechat_user.it.txt b/doc/it/weechat_user.it.txt index 1f9e3f687..9023aa3ab 100644 --- a/doc/it/weechat_user.it.txt +++ b/doc/it/weechat_user.it.txt @@ -912,7 +912,7 @@ The bare display has following features: mouse like you do in the terminal to click on URLs and select text * ncurses is not used, therefore URLs are not cut at the end of lines. -The default key to enabled bare display is key[alt-!], and same key to exit (or +The default key to enabled bare display is key[alt-l], and same key to exit (or by default anything changing the input will exit the bare display, see option <<option_weechat.look.bare_display_exit_on_input,weechat.look.bare_display_exit_on_input>>). @@ -1122,6 +1122,8 @@ Il livello di notifica per un buffer può essere impostato con il comando `/buff | key[alt-j,alt-s] | Passa al buffer server IRC | `/server jump` | key[alt-0...9] | Passa al buffer numero (0 = 10) | `/buffer *N` | key[alt-j,01...99] | Passa al buffer numero | `/buffer NN` +// TRANSLATION MISSING +| key[alt-l] | Toggle bare display on/off | `/window bare` | key[alt-m] | Abilita/disabilita | `/mouse toggle` | key[alt-n] | Scorre fino alla notifica successiva | `/window scroll_next_highlight` | key[alt-p] | Scorre fino alla notifica precedente | `/window scroll_previous_highlight` @@ -1139,8 +1141,6 @@ Il livello di notifica per un buffer può essere impostato con il comando `/buff | key[alt-=] | Attiva/disattiva filtri | `/filter toggle` // TRANSLATION MISSING | key[alt--] | Toggle filters on/off in current buffer | `/filter toggle @` -// TRANSLATION MISSING -| key[alt-!] | Toggle bare display on/off | `/window bare` |=== [[key_bindings_search_context]] diff --git a/doc/ja/weechat_faq.ja.txt b/doc/ja/weechat_faq.ja.txt index 0a4575692..d355d487d 100644 --- a/doc/ja/weechat_faq.ja.txt +++ b/doc/ja/weechat_faq.ja.txt @@ -216,7 +216,7 @@ WeeChat は自動的にデフォルトバー "input" を作成します: [[terminal_copy_paste]] === どうすればニックネームリストを選択せずにテキストだけをコピー/ペーストできますか。 -WeeChat ≥ 1.0 では、最小限表示を使うことができます (デフォルトキー: key[alt-!])。 +WeeChat ≥ 1.0 では、最小限表示を使うことができます (デフォルトキー: key[alt-l])。 矩形選択のできるターミナルを使ってください (rxvt-unicode、 konsole、gnome-terminal、...)。通常、キーは key[ctrl-]key[alt-] マウス選択です。 @@ -230,7 +230,7 @@ konsole、gnome-terminal、...)。通常、キーは key[ctrl-]key[alt-] マウ [[urls]] === どうすれば長い (一行以上に渡る) URL をクリックできますか。 -WeeChat ≥ 1.0 では、最小限表示を使うことができます (デフォルトキー: key[alt-!])。 +WeeChat ≥ 1.0 では、最小限表示を使うことができます (デフォルトキー: key[alt-l])。 デフォルトでは、WeeChat はそれぞれの行の最初に時間とプレフィックス、 さらにチャットエリアを囲むようにオプションバーを表示します。url のクリックを簡単にするには、 diff --git a/doc/ja/weechat_user.ja.txt b/doc/ja/weechat_user.ja.txt index 0433eb8f7..bfcdbfb0e 100644 --- a/doc/ja/weechat_user.ja.txt +++ b/doc/ja/weechat_user.ja.txt @@ -877,7 +877,7 @@ URL を簡単にクリックしたり、テキストを簡単に選択できる ターミナルでやるのと同じように URL をクリックしたりテキストを選択できます * ncurses を使わない、このため URL を行の最後で分断されることがなくなります。 -最小限表示を有効化するデフォルトキーは key[alt-!] で、終了するには同じキーを押してください +最小限表示を有効化するデフォルトキーは key[alt-l] で、終了するには同じキーを押してください (また、デフォルトでは入力が変更された場合に最小限表示を終了します、<<option_weechat.look.bare_display_exit_on_input,weechat.look.bare_display_exit_on_input>> オプションを参照)。 @@ -1083,6 +1083,7 @@ irc サーバ "freenode" に含まれる全てのバッファに対して設定 | key[alt-j,alt-s] | IRC サーババッファに移動 | `/server jump` | key[alt-0...9] | 番号のバッファに移動 (0 = 10) | `/buffer *N` | key[alt-j,01...99] | 番号のバッファに移動 | `/buffer NN` +| key[alt-l] | 最小限表示の有効無効を切り替え | `/window bare` | key[alt-m] | マウスの有効無効を切り替え | `/mouse toggle` | key[alt-n] | 次のハイライトまでスクロール | `/window scroll_next_highlight` | key[alt-p] | 前のハイライトまでスクロール | `/window scroll_previous_highlight` @@ -1099,7 +1100,6 @@ irc サーバ "freenode" に含まれる全てのバッファに対して設定 | key[alt-/] | 最後に表示したバッファに移動 (バッファ移動前に表示していたウィンドウ) | `/input jump_last_buffer_displayed` | key[alt-=] | フィルタの有効無効を切り替え | `/filter toggle` | key[alt--] | 現在のバッファのフィルタの有効無効を切り替え | `/filter toggle @` -| key[alt-!] | 最小限表示の有効無効を切り替え | `/window bare` |=== [[key_bindings_search_context]] diff --git a/doc/pl/weechat_faq.pl.txt b/doc/pl/weechat_faq.pl.txt index 2c9314eae..9fd34696e 100644 --- a/doc/pl/weechat_faq.pl.txt +++ b/doc/pl/weechat_faq.pl.txt @@ -219,7 +219,7 @@ użyty w żadnym z pasków: === Jak mogę kopiować/wklejać tekst bez wklejania listy nicków? // TRANSLATION MISSING -With WeeChat ≥ 1.0, you can use the bare display (default key: key[alt-!]). +With WeeChat ≥ 1.0, you can use the bare display (default key: key[alt-l]). Możesz użyć terminala z prostokątnym zaznaczaniem (jak rxvt-unicode, konsole, gnome-terminal, ...). Klawisze to zazwyczaj key[ctrl-]key[alt-] zaznaczenie myszką. @@ -234,7 +234,7 @@ Innym rozwiązaniem jest przesunięcie listy nicków na górę lub dół, na prz === Jak mogę kliknąć na długi URL (dłuższy niż linia)? // TRANSLATION MISSING -With WeeChat ≥ 1.0, you can use the bare display (default key: key[alt-!]). +With WeeChat ≥ 1.0, you can use the bare display (default key: key[alt-l]). Domyślnie WeeChat wyświetla czas i przedrostki dla każdej linii i opcjonalne paski dookoła obszaru rozmowy. Aby usprawnić klikanie w urle można przesunąć listę nicków diff --git a/doc/pl/weechat_user.pl.txt b/doc/pl/weechat_user.pl.txt index d95e2f2ad..4ce1939e6 100644 --- a/doc/pl/weechat_user.pl.txt +++ b/doc/pl/weechat_user.pl.txt @@ -885,7 +885,7 @@ The bare display has following features: mouse like you do in the terminal to click on URLs and select text * ncurses is not used, therefore URLs are not cut at the end of lines. -The default key to enabled bare display is key[alt-!], and same key to exit (or +The default key to enabled bare display is key[alt-l], and same key to exit (or by default anything changing the input will exit the bare display, see option <<option_weechat.look.bare_display_exit_on_input,weechat.look.bare_display_exit_on_input>>). @@ -1093,6 +1093,8 @@ Poziom powiadomień dla bufora może zostać ustawiony za pomocą komendy `/buff | key[alt-j,alt-s] | Przełącz na bufor serwera IRC | `/server jump` | key[alt-0...9] | Przełącz na bufor za pomocą liczb (0 = 10) | `/buffer *N` | key[alt-j,01...99] | Przełącz na bufor za pomocą liczb | `/buffer NN` +// TRANSLATION MISSING +| key[alt-l] | Toggle bare display on/off | `/window bare` | key[alt-m] | Przełącz obsługę myszy | `/mouse toggle` | key[alt-n] | Przewiń do następnego powiadomienia | `/window scroll_next_highlight` | key[alt-p] | Przewiń do poprzedniego powiadomienia | `/window scroll_previous_highlight` @@ -1110,8 +1112,6 @@ Poziom powiadomień dla bufora może zostać ustawiony za pomocą komendy `/buff | key[alt-=] | Włącz/wyłącz filtry | `/filter toggle` // TRANSLATION MISSING | key[alt--] | Toggle filters on/off in current buffer | `/filter toggle @` -// TRANSLATION MISSING -| key[alt-!] | Toggle bare display on/off | `/window bare` |=== [[key_bindings_search_context]] diff --git a/src/gui/curses/gui-curses-key.c b/src/gui/curses/gui-curses-key.c index d05e8d37f..380a73b81 100644 --- a/src/gui/curses/gui-curses-key.c +++ b/src/gui/curses/gui-curses-key.c @@ -216,7 +216,7 @@ gui_key_default_bindings (int context) BIND(/* m-m */ "meta-m", "/mute mouse toggle"); BIND(/* start paste */ "meta2-200~", "/input paste_start"); BIND(/* end paste */ "meta2-201~", "/input paste_stop"); - BIND(/* bare display*/ "meta-!", "/window bare"); + BIND(/* bare display*/ "meta-l", "/window bare"); /* bind meta-j + {01..99} to switch to buffers # > 10 */ for (i = 1; i < 100; i++) diff --git a/test/weercd.py b/test/weercd.py index d829a5cd1..612075aca 100755 --- a/test/weercd.py +++ b/test/weercd.py @@ -19,38 +19,38 @@ # along with WeeChat. If not, see <http://www.gnu.org/licenses/>. # -# -# weercd - the WeeChat IRC testing server -# -# It can be used with any IRC client (not only WeeChat). -# -# In the "flood" mode, various IRC commands are sent in a short time (privmsg, -# notice, join/quit, ..) to test client resistance and memory usage (to quickly -# detect memory leaks, for example with client scripts). -# -# This script works with Python 2.x (>= 2.7) and 3.x. -# -# It is *STRONGLY RECOMMENDED* to connect this server with a client in a test -# environment: -# - for WeeChat, another home with: `weechat --dir /tmp/weechat` -# - on a test machine, because CPU will be used a lot by client to display -# messages from weercd -# - if possible locally (ie server and client on same machine), to speed up -# data exchange between server and client. -# -# Instructions to use this server with WeeChat: -# 1. open a terminal and run server: -# python weercd.py -# 2. open another terminal and run WeeChat with home in /tmp: -# weechat --dir /tmp/weechat -# 3. optional: install script(s) (/script install ...) -# 4. add server and connect to it: -# /server add weercd 127.0.0.1/7777 -# /connect weercd -# 5. wait some months..... -# WeeChat still not crashed and does not use 200 TB of RAM ? -# Yeah, it's stable \o/ -# +""" +weercd - the WeeChat IRC testing server + +It can be used with any IRC client (not only WeeChat). + +In the "flood" mode, various IRC commands are sent in a short time (privmsg, +notice, join/quit, ..) to test client resistance and memory usage (to quickly +detect memory leaks, for example with client scripts). + +This script works with Python 2.x (>= 2.7) and 3.x. + +It is *STRONGLY RECOMMENDED* to connect this server with a client in a test +environment: +- for WeeChat, another home with: `weechat --dir /tmp/weechat` +- on a test machine, because CPU will be used a lot by client to display + messages from weercd +- if possible locally (ie server and client on same machine), to speed up + data exchange between server and client. + +Instructions to use this server with WeeChat: + 1. open a terminal and run server: + python weercd.py + 2. open another terminal and run WeeChat with home in /tmp: + weechat --dir /tmp/weechat + 3. optional: install script(s) (/script install ...) + 4. add server and connect to it: + /server add weercd 127.0.0.1/7777 + /connect weercd + 5. wait some months..... + WeeChat still not crashed and does not use 200 TB of RAM ? + Yeah, it's stable! +""" from __future__ import division, print_function @@ -70,9 +70,32 @@ NAME = 'weercd' VERSION = '0.8' -class Client: +def fuzzy_string(minlength=1, maxlength=50, spaces=False): + """Return a fuzzy string (random length and content).""" + length = random.randint(minlength, maxlength) + strspace = '' + if spaces: + strspace = ' ' + return ''.join(random.choice(string.ascii_uppercase + + string.ascii_lowercase + + string.digits + strspace) + for x in range(length)) + + +def fuzzy_host(): + """Return a fuzzy host name.""" + return '{0}@{1}'.format(fuzzy_string(1, 10), fuzzy_string(1, 10)) + - def __init__(self, sock, addr, args, **kwargs): +def fuzzy_channel(): + """Return a fuzzy channel name.""" + return '#{0}'.format(fuzzy_string(1, 25)) + + +class Client(object): + """A client of weercd server.""" + + def __init__(self, sock, addr, args): self.sock, self.addr = sock, addr self.args = args self.name = NAME @@ -105,43 +128,24 @@ class Client: try: while not self.quit: self.flood() - except Exception as e: + except Exception as exc: if self.quit: self.endmsg = 'quit received' else: self.endmsg = 'connection lost' - self.endexcept = e + self.endexcept = exc except KeyboardInterrupt: self.endmsg = 'interrupted' else: self.endmsg = 'quit received' - def fuzzy_str(self, minlength=1, maxlength=50, spaces=False): - """Return a fuzzy string (random length and content).""" - length = random.randint(minlength, maxlength) - strspace = '' - if spaces: - strspace = ' ' - return ''.join(random.choice(string.ascii_uppercase + - string.ascii_lowercase + - string.digits + strspace) - for x in range(length)) - - def fuzzy_host(self): - """Return a fuzzy host name.""" - return '{0}@{1}'.format(self.fuzzy_str(1, 10), self.fuzzy_str(1, 10)) - def fuzzy_nick(self, with_number=False): """Return a fuzzy nick name.""" if with_number: self.nicknumber += 1 - return '{0}{1}'.format(self.fuzzy_str(1, 5), self.nicknumber) + return '{0}{1}'.format(fuzzy_string(1, 5), self.nicknumber) else: - return self.fuzzy_str(1, 10) - - def fuzzy_chan(self): - """Return a fuzzy channel name.""" - return '#{0}'.format(self.fuzzy_str(1, 25)) + return fuzzy_string(1, 10) def send(self, data): """Send one message to client.""" @@ -177,9 +181,9 @@ class Client: elif data.startswith('NICK '): self.nick = data[5:] elif data.startswith('PART '): - m = re.search('^PART :?(#[^ ]+)', data) - if m: - channel = m.group(1) + match = re.search('^PART :?(#[^ ]+)', data) + if match: + channel = match.group(1) if channel in self.channels: del self.channels[channel] elif data.startswith('QUIT '): @@ -188,7 +192,7 @@ class Client: def read(self, timeout): """Read raw data received from client.""" - inr, outr, exceptr = select.select([self.sock], [], [], timeout) + inr = select.select([self.sock], [], [], timeout)[0] if inr: data = self.sock.recv(4096) if data: @@ -236,7 +240,7 @@ class Client: def flood_self_join(self): """Self join on a new channel.""" - channel = self.fuzzy_chan() + channel = fuzzy_channel() if channel in self.channels: return self.send_cmd('JOIN', channel, @@ -249,8 +253,8 @@ class Client: def flood_user_notice(self): """Notice for the user.""" - self.send_cmd('NOTICE', self.fuzzy_str(1, 400, spaces=True), - nick=self.fuzzy_nick(), host=self.fuzzy_host()) + self.send_cmd('NOTICE', fuzzy_string(1, 400, spaces=True), + nick=self.fuzzy_nick(), host=fuzzy_host()) def flood_channel_join(self, channel): """Join of a user in a channel.""" @@ -258,7 +262,7 @@ class Client: return newnick = self.fuzzy_nick(with_number=True) self.send_cmd('JOIN', channel, - nick=newnick, host=self.fuzzy_host(), target='') + nick=newnick, host=fuzzy_host(), target='') self.channels[channel].append(newnick) def flood_channel_part(self, channel): @@ -270,10 +274,10 @@ class Client: return if random.randint(1, 2) == 1: self.send_cmd('PART', channel, - nick=rnick, host=self.fuzzy_host(), target='') + nick=rnick, host=fuzzy_host(), target='') else: - self.send_cmd('QUIT', self.fuzzy_str(1, 30), - nick=rnick, host=self.fuzzy_host(), target='') + self.send_cmd('QUIT', fuzzy_string(1, 30), + nick=rnick, host=fuzzy_host(), target='') self.channels[channel].remove(rnick) def flood_channel_kick(self, channel): @@ -283,8 +287,8 @@ class Client: rnick1 = self.channel_random_nick(channel) rnick2 = self.channel_random_nick(channel) if rnick1 and rnick2 and rnick1 != rnick2: - self.send_cmd('KICK', self.fuzzy_str(1, 50), - nick=rnick1, host=self.fuzzy_host(), + self.send_cmd('KICK', fuzzy_string(1, 50), + nick=rnick1, host=fuzzy_host(), target='{0} {1}'.format(channel, rnick2)) self.channels[channel].remove(rnick2) @@ -295,11 +299,11 @@ class Client: rnick = self.channel_random_nick(channel) if not rnick: return - msg = self.fuzzy_str(1, 400, spaces=True) + msg = fuzzy_string(1, 400, spaces=True) if 'channel' in self.args.notice and random.randint(1, 100) == 100: # notice for channel self.send_cmd('NOTICE', msg, - nick=rnick, host=self.fuzzy_host(), target=channel) + nick=rnick, host=fuzzy_host(), target=channel) else: # add random highlight if random.randint(1, 100) == 100: @@ -312,7 +316,7 @@ class Client: # CTCP version msg = '\x01VERSION\x01' self.send_cmd('PRIVMSG', msg, - nick=rnick, host=self.fuzzy_host(), target=channel) + nick=rnick, host=fuzzy_host(), target=channel) def flood(self): """Yay, funny stuff here! Flood the client!""" @@ -360,11 +364,11 @@ class Client: self.send(message.format(self=self)) count += 1 self.read(0.1 if stdin else self.args.sleep) - except IOError as e: + except IOError as exc: self.endmsg = 'unable to read file {0}'.format(self.args.file) - self.endexcept = e + self.endexcept = exc return - except Exception as e: + except Exception as exc: traceback.print_exc() self.endmsg = 'connection lost' return @@ -378,7 +382,7 @@ class Client: sys.stdout.flush() try: sys.stdin.readline() - except: + except Exception: pass def stats(self): @@ -400,14 +404,16 @@ class Client: countrate=countrate, bytesrate=bytesrate)) if self.endmsg == 'connection lost': - print('Uh-oh! No quit received, client has crashed? Ahah \o/') + print('Uh-oh! No quit received, client has crashed? Ahah \\o/') def __del__(self): self.stats() print('Closing connection with', self.addr) self.sock.close() -if __name__ == "__main__": + +def main(): + """Main function.""" # parse command line arguments parser = argparse.ArgumentParser( formatter_class=argparse.ArgumentDefaultsHelpFormatter, @@ -457,8 +463,8 @@ if __name__ == "__main__": servsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) servsock.bind((args.host or '', args.port)) servsock.listen(1) - except Exception as e: - print('Socket error: {0}'.format(e)) + except Exception as exc: + print('Socket error: {0}'.format(exc)) sys.exit(1) print('Listening on port', args.port, '(ctrl-C to exit)') clientsock = None @@ -475,3 +481,6 @@ if __name__ == "__main__": # no loop if message were sent from a file if args.file: break + +if __name__ == "__main__": + main() |