-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sources.telegram_new: initial module via HPI
- Loading branch information
Showing
2 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from urllib.parse import unquote # TODO mm, make it easier to rememember to use... | ||
|
||
from promnesia.common import Results, logger, extract_urls, Visit, Loc | ||
|
||
|
||
def index() -> Results: | ||
from . import hpi | ||
from my.telegram.telegram_backup import messages | ||
|
||
# TODO port from old module | ||
# TODO - http_only | ||
# TODO - text_query and handling json column | ||
for i, m in enumerate(messages()): | ||
text = m.text | ||
|
||
urls = extract_urls(text) | ||
if len(urls) == 0: | ||
continue | ||
|
||
dt = m.time | ||
sender = m.sender.name | ||
chat = m.chat | ||
|
||
cname = chat.name if chat.name is not None else str(chat.id) | ||
|
||
locator = Loc.make( | ||
title=f"chat with {cname}", | ||
href=m.permalink, | ||
) | ||
context = f'{sender}: {text}' | ||
|
||
for u in urls: | ||
yield Visit( | ||
url=unquote(u), | ||
dt=dt, | ||
context=context, | ||
locator=locator, | ||
) |