Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

various changes to support arm64 Apple Silicon based devices #9

Merged
merged 16 commits into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]
python-version: [3.9]

steps:

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,5 @@ dmypy.json
# Cython debug symbols
cython_debug/

# macOS
/.DS_Store
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ To use tg, you'll need to have the following installed:
```sh
brew install tdlib
```
and then set in config `TDLIB_PATH`
and then set in config `TDLIB_PATH`.
- macOS arm64: you can also manually put the tdlib prebuilt (tdlib-arm64-prebuilts/libtdjson.dylib) in `/usr/local/lib`.
- `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:
```ini
Expand Down Expand Up @@ -200,7 +201,7 @@ 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"
TDLIB_PATH = "/usr/local/Cellar/tdlib/1.8.0/lib/libtdjson.dylib"

# A callback to notify a user,
# Arguments get passed in kwargs
Expand Down
2 changes: 1 addition & 1 deletion arigram/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ def notify_for_message(self, chat_id: int, msg: MsgProxy) -> None:

# TODO: handle cases when all chats muted on global level
if chat["notification_settings"]["mute_for"] or self.model.is_me(
msg["sender"].get("user_id")
(msg.get("sender_id") or msg.get("sender")).get("user_id")
):
return

Expand Down
5 changes: 2 additions & 3 deletions arigram/msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,8 @@ def chat_id(self) -> int:

@property
def sender_id(self) -> int:
return self.msg["sender"].get("user_id") or self.msg["sender"].get(
"chat_id"
)
msg = (self.msg.get("sender_id") or self.msg.get("sender"))
return msg.get("user_id") or msg.get("chat_id")

@property
def forward(self) -> Optional[Dict[str, Any]]:
Expand Down
6 changes: 3 additions & 3 deletions arigram/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,15 +280,15 @@ def _get_flags(self, chat: Dict[str, Any]) -> str:
msg = chat.get("last_message")
if (
msg
and self.model.is_me(msg["sender"].get("user_id"))
and self.model.is_me((msg.get("sender_id") or msg.get("sender")).get("user_id"))
and msg["id"] > chat["last_read_outbox_message_id"]
and not self.model.is_me(chat["id"])
):
# last msg haven't been seen by recipient
flags.append("unseen")
elif (
msg
and self.model.is_me(msg["sender"].get("user_id"))
and self.model.is_me((msg.get("sender_id") or msg.get("sender")).get("user_id"))
and msg["id"] <= chat["last_read_outbox_message_id"]
):
flags.append("seen")
Expand Down Expand Up @@ -628,7 +628,7 @@ def get_last_msg(
if not last_msg:
return None, "<No messages yet>"
return (
last_msg["sender"].get("user_id"),
(last_msg.get("sender_id") or last_msg.get("sender")).get("user_id"),
parse_content(MsgProxy(last_msg), users),
)

Expand Down
2 changes: 0 additions & 2 deletions do
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ main() {
;;

local)
python3 -m poetry check
python3 -m poetry lock
python3 -m poetry install

python3 -m pip install --user --upgrade .
Expand Down
162 changes: 81 additions & 81 deletions poetry.lock

Large diffs are not rendered by default.

Binary file added tdlib-arm64-prebuilts/libtdjson.dylib
Binary file not shown.