Dockerize
This commit is contained in:
parent
6f16104524
commit
a3ddc41118
7
Dockerfile
Normal file
7
Dockerfile
Normal file
@ -0,0 +1,7 @@
|
||||
FROM python:3.7
|
||||
WORKDIR /usr/src/app
|
||||
COPY requirements.txt ./
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
COPY src .
|
||||
COPY config.json ./
|
||||
CMD [ "python", "bot.py"]
|
11
README.md
11
README.md
@ -3,10 +3,6 @@ A bot to hold your todo.txt tasks
|
||||
|
||||
## setup and installation
|
||||
|
||||
### requirements
|
||||
- fuzzywuzzy
|
||||
- telepot
|
||||
|
||||
### install
|
||||
1. `git clone` the project or download it
|
||||
2. Create bot with [@botfather](https://t.me/botfather)
|
||||
@ -17,8 +13,11 @@ A bot to hold your todo.txt tasks
|
||||
, "tasks_file": "./tasks.json"
|
||||
}
|
||||
```
|
||||
4. `cd` to project directory
|
||||
5. run `bot.py`
|
||||
4. run `cp docker-compose.example docker-compose.yml`
|
||||
5. run `mkdir YOUR_TASKS_DIRECTORY`
|
||||
6. run `echo {} > YOUR_TASKS_DIRECTORY/tasks.json`
|
||||
7. edit `docker-compose.yml` bot.volumes to match your directory with your tasks
|
||||
8. run `docker-compose up`
|
||||
|
||||
## commands
|
||||
See [help.md](help.md)
|
||||
|
8
docker-compose.examle
Normal file
8
docker-compose.examle
Normal file
@ -0,0 +1,8 @@
|
||||
version: '3'
|
||||
services:
|
||||
bot:
|
||||
build: ./
|
||||
volumes:
|
||||
- ./tasks:/tasks
|
||||
volumes:
|
||||
tasks:
|
@ -22,6 +22,7 @@ PROPERTY_LAST_ARGUMENTS = "last_arguments"
|
||||
|
||||
CONFIG_FILE = 'config.json'
|
||||
ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
TASKS_FILE="/tasks/tasks.json"
|
||||
|
||||
|
||||
with open(CONFIG_FILE) as file:
|
||||
@ -136,7 +137,7 @@ def get_property(property_name, chat_id):
|
||||
:param chat_id:
|
||||
:return:
|
||||
"""
|
||||
with open(CONFIG['tasks_file']) as tasks_file:
|
||||
with open(TASKS_FILE) as tasks_file:
|
||||
info_dict = json.loads(tasks_file.read())
|
||||
|
||||
key = property_name + ":" + str(chat_id)
|
||||
@ -153,13 +154,13 @@ def set_property(property_name, value, chat_id):
|
||||
:param value:
|
||||
:param chat_id:
|
||||
"""
|
||||
with open(CONFIG['tasks_file']) as tasks_file:
|
||||
with open(TASKS_FILE) as tasks_file:
|
||||
info_dict = json.loads(tasks_file.read())
|
||||
|
||||
key = property_name + ":" + str(chat_id)
|
||||
info_dict[key] = value
|
||||
|
||||
with open(CONFIG['tasks_file'], 'w') as tasks_file:
|
||||
with open(TASKS_FILE, 'w') as tasks_file:
|
||||
info_dict = tasks_file.write(json.dumps(info_dict))
|
||||
|
||||
|
||||
@ -170,7 +171,7 @@ def get_tasks(chat_id, raw=False):
|
||||
:param raw: Defaults to False, raw returns the tasks as strings
|
||||
:return: Returns a python list of tasks, or a python dict if raw is True
|
||||
"""
|
||||
with open(CONFIG['tasks_file']) as tasks_file:
|
||||
with open(TASKS_FILE) as tasks_file:
|
||||
tasks_dict = json.loads(tasks_file.read())
|
||||
|
||||
if chat_id is None:
|
||||
@ -224,7 +225,7 @@ def set_tasks(tasks, chat_id):
|
||||
|
||||
task_dict[chat_id] = plaintext
|
||||
|
||||
with open(CONFIG['tasks_file'], 'w+') as tasks_file:
|
||||
with open(TASKS_FILE, 'w+') as tasks_file:
|
||||
tasks_file.write(json.dumps(task_dict))
|
||||
|
||||
|
30
src/help.md
Normal file
30
src/help.md
Normal file
@ -0,0 +1,30 @@
|
||||
# commands
|
||||
|
||||
Anything sent without a command is assumed to be a new task to be added
|
||||
|
||||
## actions on tasks
|
||||
- `/add <task-text>` - Add a new task
|
||||
- `/do <id> [id [id [id]...]]` - Do task(s)
|
||||
- `/priority <priority> <id> [id [id [id]...]]` - Set the priority of task(s)
|
||||
- `/rm <id> [id [id [id]...]]` - Remove task(s)
|
||||
- `/undo <id> [id [id [id]...]]` - undo task(s)
|
||||
|
||||
### fuzzy actions
|
||||
- `/fdo <text to match>`
|
||||
- `/fpriority <text to match>`
|
||||
- `/frm <text to match>`
|
||||
- `/fundo <text to match>`
|
||||
|
||||
## general
|
||||
- `/export` - Send all tasks as plaintext
|
||||
- `/help` - Show help information
|
||||
- `/ls [filters]` - List tasks
|
||||
- `/last` - Run the last command sent
|
||||
- `/marco` - Test if bot is up
|
||||
|
||||
|
||||
## /ls filters
|
||||
- `f[ilter]:<text>` - Tasks must have this text in it
|
||||
- `!f[ilter]:<text>` - Tasks must **not** have this text in it
|
||||
- `:show-done` - Show and include done tasks
|
||||
- `:only-done` - Show only done tasks
|
8
src/search.py
Normal file
8
src/search.py
Normal file
@ -0,0 +1,8 @@
|
||||
from fuzzywuzzy import process
|
||||
|
||||
choices = open('tmp').read().split('\n')
|
||||
|
||||
search_term = input('Search term: ')
|
||||
|
||||
for result, matchness in process.extract(search_term, choices):
|
||||
print(str(matchness), result)
|
Reference in New Issue
Block a user