diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | TODO | 4 | ||||
-rwxr-xr-x | generate-emoji-sprite.py | 35 | ||||
-rw-r--r-- | images/sprites-small.png | bin | 1566335 -> 0 bytes | |||
-rw-r--r-- | plugins/Matrix.hpp | 5 | ||||
-rw-r--r-- | src/QuickMedia.cpp | 5 | ||||
-rw-r--r-- | src/plugins/Matrix.cpp | 19 |
7 files changed, 59 insertions, 11 deletions
@@ -84,8 +84,6 @@ See project.conf \[dependencies]. `waifu2x-ncnn-vulkan` needs to be installed when using the `--upscale-images` or `--upscale-images-always` option.\ `xdg-utils` which provides `xdg-open` needs to be installed when downloading torrents with `nyaa.si` plugin.\ `ffmpeg (and ffprobe which is included in ffmpeg)` needs to be installed to upload videos with thumbnails on matrix. -## License -QuickMedia is free software licensed under GPL 3.0. See the `LICENSE` file for more information. `images/sprites-small.png` is licensed under CC BY 4.0 and is available at https://github.com/EmojiTwo/emojitwo/ # Screenshots ## Youtube search ![](https://www.dec05eba.com/images/youtube.jpg) @@ -96,7 +96,6 @@ Maybe dont clear cache for body items when filtering. Change scroll in body when previous items change size (such as when thumbnail has finished loading). Load and show replied-to message in the pinned messages tab. Pressing enter on a pinned message should go to the message in the messages tab. -Cache pinned messages on disk (messages by event id), but take into consider edits? for example if one message is pinned in the room and then edited multiple times (such as room rules). In that case cache the pinned message to quickly display it and then fetch the latest version from the server and then replace the message with the latest version. Display file list for nyaa. Remove reply formatting for NOTICE in matrix as well. Scroll body when adding new items and the selected item fits after the scroll (needed for matrix where we want to see new messages when the last item is not selected). Or show the last item when its not visible in matrix (at the bottom, just like when replying/editing). @@ -136,4 +135,5 @@ then add a gap between old messages from before sync and after sync so we can fe Fetching of previous messages should also be saved in the /sync file and messages fetched with get_message_by_id, which would cache embedded items and pinned messages; also cache users. If manga page fails to download then show "failed to download image" as text and bind F5 to refresh (retry download). Use <img src to add custom emojis, and add setting for adding/removing custom emoji. -Use window title when room name changes in matrix.
\ No newline at end of file +Use window title when room name changes in matrix. +Prev token is incorrect if additional messages have been fetched and comparing to get_previous_messages set token, because prev token is not set when fetching additional messages.
\ No newline at end of file diff --git a/generate-emoji-sprite.py b/generate-emoji-sprite.py new file mode 100755 index 0000000..b0e9dc3 --- /dev/null +++ b/generate-emoji-sprite.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 + +import requests +from subprocess import Popen, PIPE + +def create_image_with_text(text, image_filepath): + process = Popen(["convert", "-size", "1024x", "-background", "#ff00ff", "-strip", "pango:" + text, image_filepath]) + _, _ = process.communicate() + +resp = requests.get("https://unicode.org/Public/emoji/13.1/emoji-test.txt") +resp.raise_for_status() +emoji_sequences = resp.text + +ss = [] +emoji_characters = [] +for line in emoji_sequences.splitlines(): + if len(line) == 0 or line[0] == '#': + continue + + columns = line.split(";") + sequences = columns[0].strip().split() + text = [chr(int(c, 16)) for c in sequences] + emoji_characters.extend(text) + ss.append(int(sequences[0], 16)) + #print(str(sequences)) + +#print(str(len(emoji_characters))) +create_image_with_text("".join(emoji_characters), "emoji.jpg") + +sow = list(set(ss)) +sow.sort() +for i in range(len(sow) - 1): + s1 = sow[i] + s2 = sow[i + 1] + print(str(s2-s1)) diff --git a/images/sprites-small.png b/images/sprites-small.png Binary files differdeleted file mode 100644 index 341a861..0000000 --- a/images/sprites-small.png +++ /dev/null diff --git a/plugins/Matrix.hpp b/plugins/Matrix.hpp index e6a35e2..71d9664 100644 --- a/plugins/Matrix.hpp +++ b/plugins/Matrix.hpp @@ -53,6 +53,11 @@ namespace QuickMedia { REDACTION }; + class MatrixEvent { + public: + virtual ~MatrixEvent() = default; + }; + struct Message { std::shared_ptr<UserInfo> user; std::string event_id; diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 20c2371..5c88322 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -3457,7 +3457,10 @@ namespace QuickMedia { auto message = std::make_shared<Message>(); message->user = matrix->get_me(current_room); - message->body = text; + if(msgtype == "m.emote") + message->body = "*" + current_room->get_user_display_name(me) + "* " + text; + else + message->body = text; message->type = MessageType::TEXT; message->timestamp = time(NULL) * 1000; diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index 1e35d9e..f6a91e7 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -1005,7 +1005,7 @@ namespace QuickMedia { { "-H", "Authorization: Bearer " + access_token }, { "-m", "35" } }; - +#if 0 sync_additional_messages_thread = std::thread([this]() { std::vector<CommandArg> additional_args = { { "-H", "Authorization: Bearer " + access_token }, @@ -1031,7 +1031,7 @@ namespace QuickMedia { additional_messages_queue.pop_wait(); parse_sync_response(json_root, true); }); - +#endif const rapidjson::Value *next_batch_json; PluginResult result; bool initial_sync = true; @@ -2743,13 +2743,20 @@ namespace QuickMedia { char url[512]; snprintf(url, sizeof(url), "%s/_matrix/client/r0/rooms/%s/event/%s", homeserver.c_str(), room->id.c_str(), event_id.c_str()); #endif - std::string err_msg; - rapidjson::Document json_root; - DownloadResult download_result = download_json(json_root, url, std::move(additional_args), true, &err_msg); + std::string response; + DownloadResult download_result = download_to_string_cache(url, response, std::move(additional_args), use_tor, true); if(download_result != DownloadResult::OK) return nullptr; + rapidjson::Document json_root; + rapidjson::ParseResult parse_result = json_root.Parse(response.c_str(), response.size()); + if(parse_result.IsError()) { + fprintf(stderr, "Failed to get message by id %s\n", event_id.c_str()); + room->fetched_messages_by_event_id.insert(std::make_pair(event_id, nullptr)); + return nullptr; + } + if(!json_root.IsObject()) { - fprintf(stderr, "Failed to get message by id %s, error: %s\n", event_id.c_str(), err_msg.c_str()); + fprintf(stderr, "Failed to get message by id %s\n", event_id.c_str()); room->fetched_messages_by_event_id.insert(std::make_pair(event_id, nullptr)); return nullptr; } |