Implement do push
, fixed some API issues and completed more TODOs
- Added drafts - Fixed some API issues - Add `do push` - Added codeQL workflow
This commit is contained in:
parent
c46f7233b5
commit
94ce9fe73c
71
.github/workflows/codeql-analysis.yml
vendored
Normal file
71
.github/workflows/codeql-analysis.yml
vendored
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
# For most projects, this workflow file will not need changing; you simply need
|
||||||
|
# to commit it to your repository.
|
||||||
|
#
|
||||||
|
# You may wish to alter this file to override the set of languages analyzed,
|
||||||
|
# or to provide custom queries or build logic.
|
||||||
|
#
|
||||||
|
# ******** NOTE ********
|
||||||
|
# We have attempted to detect the languages in your repository. Please check
|
||||||
|
# the `language` matrix defined below to confirm you have the correct set of
|
||||||
|
# supported CodeQL languages.
|
||||||
|
#
|
||||||
|
name: "CodeQL"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main ]
|
||||||
|
pull_request:
|
||||||
|
# The branches below must be a subset of the branches above
|
||||||
|
branches: [ main ]
|
||||||
|
schedule:
|
||||||
|
- cron: '16 2 * * 4'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
analyze:
|
||||||
|
name: Analyze
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
actions: read
|
||||||
|
contents: read
|
||||||
|
security-events: write
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
language: [ 'python' ]
|
||||||
|
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
|
||||||
|
# Learn more:
|
||||||
|
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
# Initializes the CodeQL tools for scanning.
|
||||||
|
- name: Initialize CodeQL
|
||||||
|
uses: github/codeql-action/init@v1
|
||||||
|
with:
|
||||||
|
languages: ${{ matrix.language }}
|
||||||
|
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||||
|
# By default, queries listed here will override any specified in a config file.
|
||||||
|
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||||
|
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||||
|
|
||||||
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||||
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
|
- name: Autobuild
|
||||||
|
uses: github/codeql-action/autobuild@v1
|
||||||
|
|
||||||
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
|
# 📚 https://git.io/JvXDl
|
||||||
|
|
||||||
|
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||||
|
# and modify them (or add more) to build your code if your project
|
||||||
|
# uses a compiled language
|
||||||
|
|
||||||
|
#- run: |
|
||||||
|
# make bootstrap
|
||||||
|
# make release
|
||||||
|
|
||||||
|
- name: Perform CodeQL Analysis
|
||||||
|
uses: github/codeql-action/analyze@v1
|
8
BUGS.md
8
BUGS.md
|
@ -9,7 +9,9 @@ A place of important bugs to fix outside of issues
|
||||||
- 4 -- intended
|
- 4 -- intended
|
||||||
- 5 -- critical
|
- 5 -- critical
|
||||||
|
|
||||||
| `state` | `issue` | `extra_info` | `id` |
|
| `state` | `issue` | `extra_info` | `id` |
|
||||||
| :---------: | :---------------------------------------------------------------------: | :-----------------------------------------------: | :----------: |
|
| :---------: | :-----------------------------------------------------------------------------: | :-----------------------------------------------: | :----------: |
|
||||||
| 0 | When pinning chats the UI does not update until arigram is quit | | 0x0000000000 |
|
| 0 | When pinning chats the UI does not update until arigram is quit | | 0x0000000000 |
|
||||||
|
| 1 | API changed, needs refactoring | | 0x0000000001 |
|
||||||
|
| 0 | Due to API changes and telegram needing more money -- needs sponsor support | | 0x0000000002 |
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ A fork of [tg](https://github.com/paul-nameless/tg) -- a hackable telegram TUI c
|
||||||
- [x] better default file picker
|
- [x] better default file picker
|
||||||
- [x] custom keybindings
|
- [x] custom keybindings
|
||||||
- [x] consistent styling
|
- [x] consistent styling
|
||||||
- [ ] drafts
|
- [x] drafts
|
||||||
- [ ] scheduled messages
|
- [ ] scheduled messages
|
||||||
- [ ] local passwords
|
- [ ] local passwords
|
||||||
- [ ] debug mode
|
- [ ] debug mode
|
||||||
|
@ -32,6 +32,7 @@ A fork of [tg](https://github.com/paul-nameless/tg) -- a hackable telegram TUI c
|
||||||
- [ ] less crowded UI
|
- [ ] less crowded UI
|
||||||
- [ ] search (for users)
|
- [ ] search (for users)
|
||||||
- [ ] bots (bot keyboard)
|
- [ ] bots (bot keyboard)
|
||||||
|
- [ ] profile pictures
|
||||||
|
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
|
@ -16,6 +16,7 @@ _global_mailcap = mailcap.getcaps()
|
||||||
CONFIG_DIR = os.path.expanduser("~/.config/arigram/")
|
CONFIG_DIR = os.path.expanduser("~/.config/arigram/")
|
||||||
CONFIG_FILE = os.path.join(CONFIG_DIR, "config.py")
|
CONFIG_FILE = os.path.join(CONFIG_DIR, "config.py")
|
||||||
FILES_DIR = os.path.expanduser("~/.cache/arigram/")
|
FILES_DIR = os.path.expanduser("~/.cache/arigram/")
|
||||||
|
DRAFTS_FILE = os.path.join(FILES_DIR, "drafts.json")
|
||||||
MAILCAP_FILE: Optional[str] = None
|
MAILCAP_FILE: Optional[str] = None
|
||||||
|
|
||||||
LOG_LEVEL = "INFO"
|
LOG_LEVEL = "INFO"
|
||||||
|
|
|
@ -2,6 +2,8 @@ import logging
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
import shlex
|
import shlex
|
||||||
|
import json
|
||||||
|
import pyperclip
|
||||||
import webbrowser
|
import webbrowser
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from functools import partial, wraps
|
from functools import partial, wraps
|
||||||
|
@ -333,6 +335,44 @@ class Controller:
|
||||||
else:
|
else:
|
||||||
self.present_info("Message wasn't sent")
|
self.present_info("Message wasn't sent")
|
||||||
|
|
||||||
|
@bind(msg_handler, ["g"])
|
||||||
|
def load_draft_message(self) -> None:
|
||||||
|
chat_id = self.model.chats.id_by_index(self.model.current_chat)
|
||||||
|
schat_id = str(chat_id)
|
||||||
|
if not self.can_send_msg() or chat_id is None:
|
||||||
|
self.present_info("Can't send msg in this chat")
|
||||||
|
return
|
||||||
|
elif not os.path.exists(config.DRAFTS_FILE):
|
||||||
|
self.present_info("You have no drafts")
|
||||||
|
return
|
||||||
|
|
||||||
|
with open(config.DRAFTS_FILE, "r") as f:
|
||||||
|
try:
|
||||||
|
drafts_json = json.load(f)
|
||||||
|
except json.decoder.JSONDecodeError:
|
||||||
|
self.present_error("Drafts file corrupted: restoring")
|
||||||
|
|
||||||
|
with open(config.DRAFTS_FILE, "w") as f:
|
||||||
|
f.write("{}")
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
if not drafts_json.get(schat_id):
|
||||||
|
self.present_info("No drafts found")
|
||||||
|
return
|
||||||
|
|
||||||
|
draft = pyfzf.FzfPrompt().prompt(drafts_json[schat_id])[0]
|
||||||
|
drafts_json[schat_id].remove(draft)
|
||||||
|
|
||||||
|
log.exception(str(drafts_json))
|
||||||
|
|
||||||
|
pyperclip.copy(draft)
|
||||||
|
# TODO: auto-insert draft
|
||||||
|
self.present_info("Draft copies to clipboard")
|
||||||
|
|
||||||
|
with open(config.DRAFTS_FILE, "w") as f:
|
||||||
|
json.dump(drafts_json, f)
|
||||||
|
|
||||||
@bind(msg_handler, ["a", "i"])
|
@bind(msg_handler, ["a", "i"])
|
||||||
def write_short_msg(self) -> None:
|
def write_short_msg(self) -> None:
|
||||||
chat_id = self.model.chats.id_by_index(self.model.current_chat)
|
chat_id = self.model.chats.id_by_index(self.model.current_chat)
|
||||||
|
@ -949,7 +989,7 @@ class Controller:
|
||||||
return
|
return
|
||||||
|
|
||||||
user = self.model.users.get_user(msg.sender_id)
|
user = self.model.users.get_user(msg.sender_id)
|
||||||
name = f"{user['first_name']} {user['last_name']}"
|
name = f"{user.get('first_name')} {user.get('last_name')}"
|
||||||
|
|
||||||
if text := msg.text_content if msg.is_text else msg.content_type:
|
if text := msg.text_content if msg.is_text else msg.content_type:
|
||||||
notify(text, title=name)
|
notify(text, title=name)
|
||||||
|
|
|
@ -282,7 +282,7 @@ class Model:
|
||||||
return {
|
return {
|
||||||
chat["title"]: f"{basic_info['member_count']} members",
|
chat["title"]: f"{basic_info['member_count']} members",
|
||||||
"Info": chat_info["description"],
|
"Info": chat_info["description"],
|
||||||
"Share link": chat_info["invite_link"],
|
#"Share link": chat_info["invite_link"],
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_supergroup_info(self, chat: Dict[str, Any]) -> Dict[str, Any]:
|
def get_supergroup_info(self, chat: Dict[str, Any]) -> Dict[str, Any]:
|
||||||
|
@ -291,10 +291,11 @@ class Model:
|
||||||
)
|
)
|
||||||
result.wait()
|
result.wait()
|
||||||
chat_info = result.update
|
chat_info = result.update
|
||||||
|
log.exception(str(chat_info))
|
||||||
return {
|
return {
|
||||||
chat["title"]: f"{chat_info['member_count']} members",
|
chat["title"]: f"{chat_info['member_count']} members",
|
||||||
"Info": chat_info["description"],
|
"Info": chat_info["description"],
|
||||||
"Share link": chat_info["invite_link"],
|
#"Share link": chat_info["invite_link"],
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_channel_info(self, chat: Dict[str, Any]) -> Dict[str, Any]:
|
def get_channel_info(self, chat: Dict[str, Any]) -> Dict[str, Any]:
|
||||||
|
@ -306,7 +307,7 @@ class Model:
|
||||||
return {
|
return {
|
||||||
chat["title"]: "subscribers",
|
chat["title"]: "subscribers",
|
||||||
"Info": chat_info["description"],
|
"Info": chat_info["description"],
|
||||||
"Share link": chat_info["invite_link"],
|
#"Share link": chat_info["invite_link"],
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_secret_chat_info(self, chat: Dict[str, Any]) -> Dict[str, Any]:
|
def get_secret_chat_info(self, chat: Dict[str, Any]) -> Dict[str, Any]:
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
import json
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from typing import Any, Callable, Dict
|
from typing import Any, Callable, Dict
|
||||||
|
|
||||||
from arigram import config, utils
|
from arigram import config, utils
|
||||||
from arigram.controllers import Controller
|
from arigram.controllers import Controller
|
||||||
from arigram.msg import MsgProxy
|
from arigram.msg import MsgProxy
|
||||||
|
from arigram.config import DRAFTS_FILE
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -191,8 +194,24 @@ def update_chat_draft_message(
|
||||||
) -> None:
|
) -> None:
|
||||||
chat_id = update["chat_id"]
|
chat_id = update["chat_id"]
|
||||||
# FIXME: ignoring draft message itself for now because UI can't show it
|
# FIXME: ignoring draft message itself for now because UI can't show it
|
||||||
# draft_message = update["draft_message"]
|
draft_message = update["draft_message"]["input_message_text"]["text"]["text"]
|
||||||
order = update["position"]["order"]
|
order = update["positions"][0]["order"]
|
||||||
|
|
||||||
|
|
||||||
|
if not os.path.exists(DRAFTS_FILE):
|
||||||
|
with open(DRAFTS_FILE, "w") as nf:
|
||||||
|
nf.write("{}")
|
||||||
|
|
||||||
|
with open(DRAFTS_FILE, "r") as df:
|
||||||
|
dj = json.load(df)
|
||||||
|
|
||||||
|
if not dj.get(chat_id):
|
||||||
|
dj[chat_id] = []
|
||||||
|
dj[chat_id].append(draft_message)
|
||||||
|
|
||||||
|
with open(DRAFTS_FILE, "w") as wdf:
|
||||||
|
json.dump(dj, wdf)
|
||||||
|
|
||||||
|
|
||||||
current_chat_id = controller.model.current_chat_id
|
current_chat_id = controller.model.current_chat_id
|
||||||
if controller.model.chats.update_chat(chat_id, order=order):
|
if controller.model.chats.update_chat(chat_id, order=order):
|
||||||
|
|
7
do
7
do
|
@ -21,6 +21,13 @@ case $ARG in
|
||||||
gh pr create -f
|
gh pr create -f
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
push)
|
||||||
|
git diff > /tmp/arigram.diff
|
||||||
|
git add -A
|
||||||
|
git commit -S
|
||||||
|
git push -u origin main
|
||||||
|
;;
|
||||||
|
|
||||||
release)
|
release)
|
||||||
CURRENT_VERSION=$(cat arigram/__init__.py | grep version | cut -d '"' -f 2)
|
CURRENT_VERSION=$(cat arigram/__init__.py | grep version | cut -d '"' -f 2)
|
||||||
echo Current version $CURRENT_VERSION
|
echo Current version $CURRENT_VERSION
|
||||||
|
|
|
@ -13,6 +13,7 @@ repository = "https://github.com/TruncatedDinosour/arigram"
|
||||||
python = "^3.8"
|
python = "^3.8"
|
||||||
python-telegram = "^0.15.0^"
|
python-telegram = "^0.15.0^"
|
||||||
pyfzf = "^0.2.2"
|
pyfzf = "^0.2.2"
|
||||||
|
pyperclip = "^1.8.2"
|
||||||
|
|
||||||
[tool.poetry.dev-dependencies]
|
[tool.poetry.dev-dependencies]
|
||||||
black = "20.8b1"
|
black = "20.8b1"
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
python-telegram>=0.15.0
|
python-telegram>=0.15.0
|
||||||
pyfzf>=0.2.2
|
pyfzf>=0.2.2
|
||||||
|
pyperclip>=1.8.2
|
||||||
|
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -23,5 +23,5 @@ setup(
|
||||||
packages=["arigram"],
|
packages=["arigram"],
|
||||||
entry_points={"console_scripts": ["arigram = arigram.__main__:main"]},
|
entry_points={"console_scripts": ["arigram = arigram.__main__:main"]},
|
||||||
python_requires=">=3.8",
|
python_requires=">=3.8",
|
||||||
install_requires=["python-telegram>=0.15.0", "pyfzf>=0.2.2"],
|
install_requires=["python-telegram>=0.15.0", "pyfzf>=0.2.2", "pyperclip>=1.8.2"],
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue