From d43375b1436b8d02266c0db893be9cdf2627380a Mon Sep 17 00:00:00 2001 From: Ari Archer Date: Thu, 17 Feb 2022 00:23:03 +0200 Subject: [PATCH] Added more config Signed-off-by: Ari Archer --- README.md | 11 +++++++++++ TODO | 4 ++++ arigram.desktop | 13 +++++++++++++ arigram/config.py | 2 ++ arigram/views.py | 10 +++++++++- do | 11 ++++++----- 6 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 TODO create mode 100644 arigram.desktop diff --git a/README.md b/README.md index a5bc670..addc7a3 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,12 @@ cd arigram ./do local ``` +#### Optionally install the desktop entry + +```sh +$ sudo ./do entry +``` + And add this to `~/.bashrc` or whatever POSIX complient shell you use: ```sh @@ -281,6 +287,11 @@ EXTRA_TDLIB_HEADERS = {"disable_web_page_preview": True} # Where to store your drafts DRAFTS_FILE = "/tmp/.drafts.json" + +# This defines if stuff like \n (Unicode escapes) +# get interpreted literally (False) or get decoded +# into an escape and you get a newline (True) +DECODE_INPUT_ESCAPES = False ``` ### Mailcap file diff --git a/TODO b/TODO new file mode 100644 index 0000000..15bcc71 --- /dev/null +++ b/TODO @@ -0,0 +1,4 @@ +- add a newline after every message except if it's from the same user +- implement [messageAnimatedEmoji] +- implement spoilers + diff --git a/arigram.desktop b/arigram.desktop new file mode 100644 index 0000000..58620b6 --- /dev/null +++ b/arigram.desktop @@ -0,0 +1,13 @@ +[Desktop Entry] +Version=1.1 +Name=Arigram +Comment=A fork of tg -- a hackable telegram TUI client +TryExec=arigram +Exec=arigram +Icon=arigram +Terminal=true +StartupWMClass=Arigram +Type=Application +Categories=Chat;Network;InstantMessaging; +MimeType=x-scheme-handler/tg; +Keywords=tg;chat;im;messaging;messenger;sms;arigram; diff --git a/arigram/config.py b/arigram/config.py index 0557d29..cec5a54 100644 --- a/arigram/config.py +++ b/arigram/config.py @@ -80,6 +80,8 @@ CUSTOM_KEYBINDS: Dict[str, Dict[str, Any]] = {} TRUNCATE_LIMIT: int = 15 +DECODE_INPUT_ESCAPES: bool = True + EXTRA_TDLIB_HEADEARS: Dict[Any, Any] = {} if os.path.isfile(CONFIG_FILE): diff --git a/arigram/views.py b/arigram/views.py index 244f53a..5fdad62 100644 --- a/arigram/views.py +++ b/arigram/views.py @@ -1,6 +1,7 @@ import curses import logging from datetime import datetime +from tempfile import TemporaryFile from typing import Any, Dict, List, Optional, Tuple, Union, cast from _curses import window # type: ignore @@ -20,8 +21,10 @@ from arigram.msg import MsgProxy from arigram.tdlib import ChatType, get_chat_type, is_group from arigram.utils import ( get_colour_by_str, + is_yes, num, string_len_dwc, + suspend, truncate_to_len, ) @@ -169,7 +172,12 @@ class StatusView: curses.cbreak() curses.noecho() - return buff.encode("raw_unicode_escape").decode("unicode_escape") + if config.DECODE_INPUT_ESCAPES: + buff = buff.encode("raw_unicode_escape", errors="ignore").decode( + "unicode_escape", errors="ignore" + ) + + return buff class ChatView: diff --git a/do b/do index 1e6c74e..a2e9519 100755 --- a/do +++ b/do @@ -30,10 +30,6 @@ main() { ;; local) - python3 -m poetry check - python3 -m poetry lock - python3 -m poetry install - python3 -m pip install --user --upgrade . ;; @@ -46,10 +42,15 @@ main() { check) black . isort arigram/*.py - chmod a+rx ./check.sh + chmod u+rx ./check.sh ./check.sh ;; + entry) + mkdir -p /usr/share/applications + cp arigram.desktop /usr/share/applications + ;; + *) python3 -m arigram ;;