Code Monkey home page Code Monkey logo

tg's Introduction

tg

Join telegram chat

Telegram terminal client.

tg screenshot

Features

  • view mediafiles: photo, video, voice/video notes, documents
  • ability to send pictures, documents, audio, video
  • reply, edit, forward, delete, send messages
  • stickers
  • notifications
  • record and send voice msgs
  • auto download files
  • toggle chats: pin/unpin, mark as read/unread, mute/unmute
  • message history
  • list contacts
  • show user status
  • secret chats
  • search
  • bots (bot keyboard)

Requirements

To use tg, you'll need to have the following installed:

Optional dependencies

  • terminal-notifier - for Mac (used by default). You can change it to dunst for Linux or any other notifications program (see NOTIFY_CMD in configuration)
  • ffmpeg - to record voice msgs and upload videos.
  • tdlib - in case of incompatibility with built in package. For example, macOS:
    brew install tdlib
    and then set in config TDLIB_PATH
  • urlview to choose urls when there is multiple in message, use URL_VIEW in config file to use another app (it should accept urls in stdin)
  • to open stickers and animated ones (thumbnail preview) you need to set in mailcap appropriate handler and have app which will open webp file:
    image/webp; mpv %s
  • ranger, nnn - can be used to choose file when sending, customizable with FILE_PICKER_CMD
  • fzf - to create groups and secret chats (used for single and multiple user selection)

Installation

From PyPI

This option is recommended for production:

pip3 install tg
tg

Homebrew

brew tap paul-nameless/homebrew-repo
brew install tg

From sources

This option is recommended for development:

git clone https://github.com/paul-nameless/tg.git
cd tg
pip install python-telegram
pip install .
tg

Using Docker

Note that voice recordings and notifications won't work when using Docker.

docker run -it --rm ghcr.io/paul-nameless/tg

From the AUR

If you're using Arch Linux, you can install tg through its AUR package:

If you're using the yay AUR helper, you can install the package with:

yay -S telegram-tg

If you want to use the latest developement version via the AUR you can find it here

Configuration

Config file should be stored at ~/.config/tg/conf.py. This is simple python file.

Simple config:

# should start with + (plus) and contain country code
PHONE = "[phone number in international format]"

Advanced configuration:

All configurable variables can be found here

import os

# You can write anything you want here, file will be executed at start time
# You can keep you sensitive information in password managers or gpg
# encrypted files for example
def get_pass(key):
    # retrieves key from password store
    return os.popen("pass show {} | head -n 1".format(key)).read().strip()


PHONE = get_pass("i/telegram-phone")
# encrypt you local tdlib database with the key
ENC_KEY = get_pass("i/telegram-enc-key")

# log level for debugging, info by default
LOG_LEVEL = "DEBUG"
# path where logs will be stored (all.log and error.log)
LOG_PATH = os.path.expanduser("~/.local/share/tg/")

# If you have problems with tdlib shipped with the client, you can install and
# use your own, for example:
TDLIB_PATH = "/usr/local/Cellar/tdlib/1.6.0/lib/libtdjson.dylib"

# you can use any other notification cmd, it is simple python string which
# can format title, msg, subtitle and icon_path paramters
# In these exapmle, kitty terminal is used and when notification is pressed
# it will focus on the tab of running tg
NOTIFY_CMD = "/usr/local/bin/terminal-notifier -title {title} -subtitle {subtitle} -message {msg} -appIcon {icon_path} -sound default -execute '/Applications/kitty.app/Contents/MacOS/kitty @ --to unix:/tmp/kitty focus-tab --no-response -m title:tg'"

# You can use your own voice recording cmd but it's better to use default one.
# The voice note must be encoded with the Opus codec, and stored inside an OGG
# container. Voice notes can have only a single audio channel.
VOICE_RECORD_CMD = "ffmpeg -f avfoundation -i ':0' -c:a libopus -b:a 32k {file_path}"

# You can customize chat and msg flags however you want.
# By default words will be used for readability, but you can make
# it as simple as one letter flags like in mutt or add emojies
CHAT_FLAGS = {
    "online": "●",
    "pinned": "P",
    "muted": "M",
    # chat is marked as unread
    "unread": "U",
    # last msg haven't been seen by recipient
    "unseen": "βœ“",
    "secret": "πŸ”’",
    "seen": "βœ“βœ“",  # leave empty if you don't want to see it
}
MSG_FLAGS = {
    "selected": "*",
    "forwarded": "F",
    "new": "N",
    "unseen": "U",
    "edited": "E",
    "pending": "...",
    "failed": "πŸ’©",
    "seen": "βœ“βœ“",  # leave empty if you don't want to see it
}

# use this app to open url when there are multiple
URL_VIEW = 'urlview'

# Specifies range of colors to use for drawing users with
# different colors
# this one uses base 16 colors which should look good by default
USERS_COLORS = tuple(range(2, 16))

# to use 256 colors, set range appropriately
# though 233 looks better, because last colors are black and gray
# USERS_COLORS = tuple(range(233))

# to make one color for all users
# USERS_COLORS = (4,)

# cleanup cache
# Values: N days, None (never)
KEEP_MEDIA = 7

FILE_PICKER_CMD = "ranger --choosefile={file_path}"
# FILE_PICKER_CMD = "nnn -p {file_path}"

MAILCAP_FILE = os.path.expanduser("~/.config/mailcap")

DOWNLOAD_DIR = os.path.expanduser("~/Downloads/")  # copy file to this dir

Mailcap file

Mailcap file is used for deciding how to open telegram files (docs, pics, voice notes, etc.). Path to the file can be overriden with MAILCAP_FILE in config file.

Example: ~/.mailcap

# media
video/*; mpv "%s"
audio/ogg; mpv --speed=1.33 "%s"
audio/mpeg; mpv --no-video "%s"
image/*; qview "%s"

# text
text/html; w3m "%s"
text/html; open -a Firefox "%s"
text/plain; less "%s"

# fallback to vim
text/*; vim "%s"

Keybindings

vi like keybindings are used in the project. Can be used commands like 4j - 4 lines down.

For navigation arrow keys also can be used.

Chats:

  • j,k: move up/down
  • J,K: move 10 chats up/down
  • g: go to top chat
  • l: open msgs of the chat
  • m: mute/unmute current chat
  • p: pin/unpin current chat
  • u: mark read/unread
  • r: read current chat
  • c: show list of contacts
  • dd: delete chat or remove history
  • ng: create new group chat
  • ns: create new secret chat
  • /: search in chats
  • ?: show help

Msgs:

  • j,k: move up/down
  • J,K: move 10 msgs up/down
  • G: move to the last msg (at the bottom)
  • D: download file
  • l: if video, pics or audio then open app specified in mailcap file, for example:
    # Images
    image/png; qView "%s"
    audio/*; mpv "%s"
    if text, open in less (to view multiline msgs)
  • e: edit current msg
  • <space>: select msg and jump one msg down (use for deletion or forwarding)
  • <ctrl+space>: same as space but jumps one msg up
  • y: yank (copy) selected msgs with to internal buffer (for forwarding) and copy current msg text or path to file to clipboard
  • p: forward (paste) yanked (copied) msgs to current chat
  • dd: delete msg for everybody (multiple messages will be deleted if selected)
  • i or a: insert mode, type new message
  • I or A: open vim to write long msg and send
  • v: record and send voice message
  • r,R: reply to a current msg
  • S: calls a file picker
  • sv: send video
  • sa: send audio
  • sp: send picture
  • sd: send document
  • o: open url present in message (if multiple urls, urlview will be opened)
  • ]: next chat
  • [: prev chat
  • u: show user info (username, bio, phone, etc.)
  • c: show chat info (e.g. secret chat encryption key, chat id, state, etc.)
  • ?: show help
  • !: open msg with custom cmd

Publish

Run task to automatically increase version and release (https://taskfile.dev):

task release

tg's People

Contributors

banderlog avatar bn-rv avatar crax97 avatar galicarnax avatar gardenappl avatar ijustdev avatar irondrondron avatar jingmatrix avatar jugendhacker avatar kalashnlkov avatar klemensn avatar leisefuxx avatar lightme16 avatar nivit avatar paul-nameless avatar steffo99 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tg's Issues

Marking messages as read

Thanks for the implementation of secret chats, it works well. The only issue is that messages received from the other party in the secret chat dont get marked as read. This means for instance with disappearing messages, the messages dont disappear. Note that there exists focus events for terminals that you can use to mark messages read when the window is focused. Or for a simpler implementation simply mark messages as read when the user starts typing/sends a message.

In a terminal you turn on focus reporting by sending <ESC>[1004h and turn it off with <ESC>[1004l. The terminal then sends <ESC>[I for focus gained and <ESC>[O for focus lost.
https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-FocusIn_FocusOut

Segmentation Fault after viewing media

Hi, I get a segmentation fault after viewing videos with mpv or images with imv, sometimes this happens after viewing multiple media files, other times it happens after viewing only one media file.

Custom mailcap path

I like to keep my home directory clean and for example in neomutt I've set to fetch mailcap from ~/.config/mailcap. I hope I could do the same with tg.

Some names are missing

Not sure how to reproduce this, it seems like some usernames are not shown in group chat messages.

image

❯ pip show tg
Name: tg
Version: 0.6.0
Summary: Terminal client for telegram
Home-page: https://github.com/paul-nameless/tg
Author: Paul Nameless
Author-email: [email protected]
License: UNKNOWN
Location: /home/hexyoungs/miniconda3/lib/python3.8/site-packages
Requires: python-telegram
Required-by:

Auto download files when openend

I guess somewhat contrary to #163 I actually want to be able to just hit l or enter on a message with an image and if it isn't downloaded yet it should just autodownload it instead of requiring me to press D manually every time beforehand.

black formatting

Setup github actions to check black formatting and reformat project

Blank screen at startup / KeyError: 'order'

I just installed and run tg.
Then I entered my phone number and the security code.
On my phone I got notified that my computer logged in to my telegram account.

But tg only ends in a blank screen, no cursor, nothing.
Is this somewhere a known issue or is there a way to debug tg?

I am running Manjaro ARM64, Sway Desktop, Termite.

Support for proxy env vars????

I couldn't find any settings supporting proxy (http,https ...) environment variables. Am behind a corporate ntlm authentication proxy. If this possible????

input indicator for Chinese character

When I compose a short message:

  1. If I type English words, there would be a cursor that indicates my input location; it works well and this indicator places at the end of buffer.
  2. However, this is not the case when I input Chinese character, if I type 5 Chinese character, the indicator will show at the third position, where I use bold style to indicate the position of cursor:

δΈ­ζ–‡ηš„ιΌ ζ ‡

  1. I believe this is related to curses python module, and related code is at https://github.com/paul-nameless/tg/blob/master/tg/views.py#L109

Voice recording buggy

First of all thanks a lot for this awesome application!

Unfortunately I have some troubles with the voice recording.
Not sure if I ever will use it :D but thought you might be interested.

This was my first bug:
ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card
[alsa @ 0x5626bffac2c0] cannot open audio device default (No such device)
default: Input/output error

Fixed with adding that line to my conf.py
VOICE_RECORD_CMD = "ffmpeg -f alsa -i hw:0 -c:a libopus -b:a 32k {file_path}"

But there is still another one:

Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, alsa, from 'hw:0':
Duration: N/A, start: 1592929738.453123, bitrate: 1536 kb/s
Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
[NULL @ 0x558585020e00] Unable to find a suitable output format for '/tmp/voice-2020-06-23'
/tmp/voice-2020-06-23: Invalid argument

'Seen' message flag

I'd like to have a 'seen' tag as opposed to 'unseen' so I could mimic Telegram Desktop with check and double-check icons. Also to avoid annoying moving of the message text when a message gets seen.

RTL text sometimes overflows beyond the white line onto the chat window

I don't know how to reproduce this reliably, but RTL text (Arabic, Persian, etc) sometimes overflows beyond the white barrier and starts spilling text on the chat window, which is very annoying and makes reading old messages a challenge.

Note that the white barrier doesn't disappear, it gets pushed slightly to the left of the text.

libtdjson.so: No such file or directory

I installed telegram-tg 0.6.0-1 from AUR on Manjaro.
I did not create the config.py file manually.
I ran tg in terminal, I entered my phone number.
Then it couldn't find the ~/.cache/tg/files folder, so I created it manually and re-run tg.

Next this error appears:

File "/usr/lib/python3.8/ctypes/__init__.py", line 373, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /usr/lib/python3.8/site-packages/telegram/lib/linux/libtdjson.so: cannot open shared object file: No such file or directory

What do you recommend?

Something wrong: Tried to invoke without .connect()

When I enter my phone number for the first time I keep getting:
Something wrong: Tried to invoke without .connect()

I live in Australia so I tried the country code + my mobile number eg +614******* also tried without country code 04******** same error.

KeyError: 'positions' on updateChatLastMessage

I'm reporting this for a user, who does not have a github account.

The log of this user fills up with the following traces quite fast. Looks like it might be related to libtd version differences but I'm not totally sure.

ERROR [2021-04-21 17:23:18,769] update_handlers.py:32 - wrapper | Error happened in handler: updateChatLastMessage
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/tg/update_handlers.py", line 30, in wrapper
    fun(controller, update)
  File "/usr/lib/python3.9/site-packages/tg/update_handlers.py", line 210, in update_chat_last_message
    if len(update["positions"]) > 0:
KeyError: 'positions'
ERROR [2021-04-21 17:23:18,770] update_handlers.py:32 - wrapper | Error happened in handler: updateChatLastMessage
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/tg/update_handlers.py", line 30, in wrapper
    fun(controller, update)
  File "/usr/lib/python3.9/site-packages/tg/update_handlers.py", line 210, in update_chat_last_message
    if len(update["positions"]) > 0:
KeyError: 'positions'
ERROR [2021-04-21 17:23:18,772] controllers.py:803 - draw | Error happened in draw loop
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/tg/controllers.py", line 801, in draw
    fun()
  File "/usr/lib/python3.9/site-packages/tg/controllers.py", line 832, in _render_chats
    chats = self.model.get_chats(
  File "/usr/lib/python3.9/site-packages/tg/models.py", line 160, in get_chats
    return self.chats.fetch_chats(offset=offset, limit=limit)
  File "/usr/lib/python3.9/site-packages/tg/models.py", line 393, in fetch_chats
    self._load_next_chats()
  File "/usr/lib/python3.9/site-packages/tg/models.py", line 425, in _load_next_chats
    self.add_chat(chat)
  File "/usr/lib/python3.9/site-packages/tg/models.py", line 441, in add_chat
    if len(chat["positions"]) > 0:
KeyError: 'positions'

tg only worked once after installation [SOLVED]

[SOLVED]

Hi

Installed tg on Ubuntu WSL (windows 10) and worked ok. Sending and reading messages like a charm.
After a while I rebooted the machine and then tg suddlenly is not working.

Message is: "Command tg not found"

Tried to install it again:

"Requirements already satisfied"

but same message: "Command tg not found"

any hint?

[SOLUTION]

added '/home/user/.local/bin' to PATH.

Feature request: Toggle sidebar (chatlist) visibility

Sidebar takes up potentially useful space (it's especially noticeable when tg is resized to <70 columns) and exposes the list of my chats. It would be cool to have an option to toggle the sidebar either using a hotkey or automatically when the available width is too tight.

Make support for windows 10

Please make support for windows10 at least 64bits
I try many things to run this great app, but none of them work. Maybe someone could guide me to the right direction.

I use mintty (git bash) from a portable instalation of git for windows
I create a venv py -3.9 -m venv /path/to/venv/directory
Then I installed your app with pip install tg, which install python-telegram lib too.

I realized that python-telegram doesn't come with tdjson.dll for win10 64bits so I downloaded a precompiled version from this site.
I just give the path on conf.py file like TDLIB_PATH = "/path/to/your/library/tdjson.dll"

It seems to work when a run tg, ask for my login code, but as soon as I put it and press enter the program stops. If I try tu re run it the error redirection is not supported.
I search that on duckduckgo and it seems that is a problem of mintty console

I try cmd.exe program and the error now is FIND: parameter format not correct, search again and seems it is a problem of the two find programs, one from windows and one from git bash.
I just try to run on the folder where find from git bash is, but the program just do not output anything, just return to console prompt.

Maybe I am making some mistakes, if someone could lead me to the right direction, i really want to use this telegram client

[Feature Request] Per user colors

In group chats, it's making it quite hard to distinguish who's who.

Even in 1on1 chats, it can get confusing.

Any way we can have random colors (or even predefined) colors on a user basis?

Support for secret chats

I realize its on your TODO list, however, I'd like to now if it is likely to be implemented anytime soon. Thanks.

Some messages get skipped

I'm not sure if it's just after the first time message fetch that causes this but when browsing message history in my chats some messages are skipped and the selection goes to the one after the skipped line. In the logs the current-msg shows that the selection only moved a single message like the skipped one doesn't exist at all from the program's perspective.

quote filename path for mailcap

Please quote filename path when passing it to mailcap command, otherwise I will get error like this:

display-im6.q16: unable to open image `/home/jing/Images/Capture': Aucun fichier ou dossier de ce type @ error/blob.c/OpenBlob/2874.
display-im6.q16: no decode delegate for this image format `' @ error/constitute.c/ReadImage/560.
display-im6.q16: unable to open image `d’écran': Aucun fichier ou dossier de ce type @ error/blob.c/OpenBlob/2874.
display-im6.q16: no decode delegate for this image format `' @ error/constitute.c/ReadImage/560.
display-im6.q16: unable to open image `de': Aucun fichier ou dossier de ce type @ error/blob.c/OpenBlob/2874.
display-im6.q16: no decode delegate for this image format `' @ error/constitute.c/ReadImage/560.
display-im6.q16: unable to open image `2021-01-06': Aucun fichier ou dossier de ce type @ error/blob.c/OpenBlob/2874.
display-im6.q16: no decode delegate for this image format `' @ error/constitute.c/ReadImage/560.
display-im6.q16: unable to open image `15-48-59.png': Aucun fichier ou dossier de ce type @ error/blob.c/OpenBlob/2874.

I suggest change code instead of changing my mailcap file because mutt does this, and my mailcap file comes from there

Certain colors use the background color only in tmux

Running outside of tmux everything looks fine.
From within tmux some words seem missing on the left column (list of chats)
after trying to figure out what the pattern was I saw that darkmagenta and skyblue text was background colored (close to black)

libtd build failed while installing from aur package

i tried installing tg with yay -S telegram-tg

It lead to compilation of libtd, think. It was taking 100% cpu usage and near 75% completion took all of my ram (8 gb). and then failed.

later i tried pip3 which was quick and successfull.

I just wanted to know what happened with aur package method. and do i need to be worried about changes it might have caused to my system.

took this screenshot of what was going in between
screenshot

View glitch

If I open message view and then press a to write a message this glitch appears:
image

Is it known?

AUR package

For those who are to lazy to build this themselves and want to manage it via a package manager on Arch Linux I created a AUR package for it: telegram-tg-git

Maybe you could mention it somewhere as an alternative install method?

No text shown in quick msg bottom line

When I type start with i, my cursor moves, but no text is shown there.

It is due to following error, I was typing the word yes:

Traceback (most recent call last):
  File "/home/jing/.local/lib/python3.9/site-packages/tg/views.py", line 39, in addstr
    return self.win.addstr(y, x, _str, attr)
TypeError: an integer is required (got type NoneType)
ERROR [2021-04-22 18:28:10,333] views.py:41 - addstr | Error drawing: y=0, x=0, _str='y', attr=None
Traceback (most recent call last):
  File "/home/jing/.local/lib/python3.9/site-packages/tg/views.py", line 39, in addstr
    return self.win.addstr(y, x, _str, attr)
TypeError: an integer is required (got type NoneType)
ERROR [2021-04-22 18:28:10,479] views.py:41 - addstr | Error drawing: y=0, x=0, _str='ye', attr=None
Traceback (most recent call last):
  File "/home/jing/.local/lib/python3.9/site-packages/tg/views.py", line 39, in addstr
    return self.win.addstr(y, x, _str, attr)
TypeError: an integer is required (got type NoneType)
ERROR [2021-04-22 18:28:10,758] views.py:41 - addstr | Error drawing: y=0, x=0, _str='yes', attr=None
Traceback (most recent call last):
  File "/home/jing/.local/lib/python3.9/site-packages/tg/views.py", line 39, in addstr
    return self.win.addstr(y, x, _str, attr)
TypeError: an integer is required (got type NoneType)

how to not auto download files.

the download thing is confusing for me. i know the 10MB limit,but sometimes less than 1MB picture is not downloaded but 5MB pdf file got downloaded.sometimes sticker is downloaded , sometimes not. i usually dont auto download anything. can you made on demand file download?

Add config file

We should store config at ~/.config/tg/tg.conf
If path does not exists, it should be created

api_key, api_hash and login should be prompted if their values are empty and saved to config

Add a keybinding to download files

Something like 'd' which will download the files in the selected messages to a pre specified folder, settable in config.py, defaulting to /tmp

Does not work in Termux on Android

For fun I tested it on Android and it couldn't load a DLL due to packaging errors (possibly my own local problems):

$ tg
Enter your phone number in international format (including country code)
phone> +375298625706
Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/bin/tg", line 8, in <module>
    sys.exit(main())
  File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/tg/main.py", line 47, in main
    tg = Tdlib(
  File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/telegram/client.py", line 113, in __init__
    self._tdjson = TDJson(library_path=library_path, verbosity=tdlib_verbosity)
  File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/telegram/tdjson.py", line 27, in __init__
    self._build_client(library_path, verbosity)
  File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/telegram/tdjson.py", line 36, in _build_client
    self._tdjson = CDLL(library_path)
  File "/data/data/com.termux/files/usr/lib/python3.8/ctypes/__init__.py", line 373, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen failed: "/data/data/com.termux/files/usr/lib/python3.8/site-packages/telegram/lib/linux/libtdjson.so" is for EM_X86_64 (62) instead of EM_AARCH64 (183)
$

This is probably outside of your scope, this is mostly an FYI for folks who are crazy enough to try it. :p

String length computation is broken

Currently tg uses string_len_dwc() which computes string length based on east asian widths. That is incorrect. The absolutely correct way to do it is to use a standard compliant implementation of wcswidth. However there are no easily re-useable implementations of that available (someday, I should split out the one I have in kitty into a re-useable package). So in lieu of that use the libc version of wcswidth instead via ctypes.

from ctypes import CDLL, c_wchar_p
libc = CDLL(None)
wcswidth = libc.wcswidth
wcswidth.argtypes = [c_wchar_p]

tg doesn't work on python 3.9

ERROR [2021-02-21 14:57:25,811] update_handlers.py:32 - wrapper | Error happened in handler: updateNewChat Traceback (most recent call last): File "/home/michael/.local/lib/python3.9/site-packages/tg/update_handlers.py", line 30, in wrapper fun(controller, update) File "/home/michael/.local/lib/python3.9/site-packages/tg/update_handlers.py", line 119, in update_new_chat controller.model.chats.add_chat(chat) File "/home/michael/.local/lib/python3.9/site-packages/tg/models.py", line 439, in add_chat if int(chat["order"]) == 0: KeyError: 'order' ERROR [2021-02-21 14:57:25,811] update_handlers.py:32 - wrapper | Error happened in handler: updateChatLastMessage Traceback (most recent call last): File "/home/michael/.local/lib/python3.9/site-packages/tg/update_handlers.py", line 30, in wrapper fun(controller, update) File "/home/michael/.local/lib/python3.9/site-packages/tg/update_handlers.py", line 192, in update_chat_last_message order = update["order"] KeyError: 'order' ERROR [2021-02-21 14:57:26,614] controllers.py:807 - draw | Error happened in draw loop Traceback (most recent call last): File "/home/michael/.local/lib/python3.9/site-packages/tg/controllers.py", line 805, in draw fun() File "/home/michael/.local/lib/python3.9/site-packages/tg/controllers.py", line 798, in _resize self._render() File "/home/michael/.local/lib/python3.9/site-packages/tg/controllers.py", line 825, in _render self._render_chats() File "/home/michael/.local/lib/python3.9/site-packages/tg/controllers.py", line 836, in _render_chats chats = self.model.get_chats( File "/home/michael/.local/lib/python3.9/site-packages/tg/models.py", line 160, in get_chats return self.chats.fetch_chats(offset=offset, limit=limit) File "/home/michael/.local/lib/python3.9/site-packages/tg/models.py", line 392, in fetch_chats self._load_next_chats() File "/home/michael/.local/lib/python3.9/site-packages/tg/models.py", line 424, in _load_next_chats self.add_chat(chat) File "/home/michael/.local/lib/python3.9/site-packages/tg/models.py", line 439, in add_chat if int(chat["order"]) == 0: KeyError: 'order'

Getting this error when using Python 3.9, terminal showing only black screen.

copy msg text instead of path to file

This is an awesome project, thanks for creating it!

I have the following situation: I get a QR code as an image and the content as text from a bot. Now I would like to get the text into my clipboard and not the path. This is the code (you probably know):

tg/tg/models.py

Lines 221 to 238 in 06f7c5b

def copy_msgs_text(self) -> bool:
"""Copies current msg text or path to file if it's file"""
buffer = []
from_chat_id, msg_ids = self.copied_msgs
if not msg_ids:
return False
for msg_id in msg_ids:
_msg = self.msgs.get_message(from_chat_id, msg_id)
if not _msg:
return False
msg = MsgProxy(_msg)
if msg.file_id and msg.local_path:
buffer.append(msg.local_path)
elif msg.is_text:
buffer.append(msg.text_content)
copy_to_clipboard("\n".join(buffer))
return True

Any ideas how to solve this? Or maybe you won't change that behaviour at all.

Provide some way to set the disappearing message timer

The current value of the timer should be displayed at the top of the chat window, where the user name is displayed. And there should be some way to change the time, perhaps a shortcut that asks the user for the new time and sets it in the chat. Or alternately a config file setting to set a default value of the timer for newly created secret chats.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.