玩客云 捡垃圾,40块钱还行,民间大佬弄出了刷Linux的方法,可惜是32位,不过也凑合用,比斐讯N1折腾了那么一点。
beancount beancount介绍可以看下面几个文章,整挺好。之前是用ios端的Moze3,感觉还是差了点意思。
Beancount复式记账(一):为什么 
复式记账指北(三):如何打造不半途而废的记账方案 
使用 Beancount 管理家庭财务 · 构建我的被动收入 
使用 Costflow 提高 Beancount 记账效率 
bot-docker 这里推荐使用kaaass/beancount_bot_costflow_docker,参考上面第二篇文章,里面有详细说明。不过上面的镜像只支持64位,只能自己弄32位的docker镜像。
Dockerfile 从beancount_bot_costflow_docker的Dockerfile修改而来
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 FROM alpine:3.6 WORKDIR /app ADD requirements.txt /app ENV PYTHONUNBUFFERED=1 RUN apk add --update --no-cache python3 python3-dev && ln -sf python3 /usr/bin/python RUN python3 -m ensurepip RUN pip3 install --no-cache --upgrade pip setuptools RUN apk add --update --no-cache --virtual .build-deps gcc libc-dev libxml2-dev libxml2 libxslt-dev py3-lxml && \     pip install --no-cache-dir -r requirements.txt && \         apk del .build-deps RUN apk add --no-cache libgcc libstdc++ curl RUN curl -fLO https://github.com/oznu/alpine-node/releases/download/14.18.1/node-v14.18.1-linux-arm-alpine.tar.gz RUN tar -xzf node-v14.18.1-linux-arm-alpine.tar.gz -C /usr --strip-components=1 --no-same-owner RUN rm -rf node-v14.18.1-linux-arm-alpine.tar.gz RUN node --version VOLUME ["/config", "/bean"] ENV BEANCOUNT_BOT_CONFIG /config/beancount_bot.yml ENV PYTHONPATH /config ADD docker-entrypoint.sh /app CMD ["/app/docker-entrypoint.sh"] 
这里用alpine:3.6的原因是3.6以上版本有联网问题,不知道是不是32位系统的问题。不过用了3.6版本需要自己安装Python3和nodejs,也算是小麻烦了点。
build 因为玩客云的CPU架构是armv7,所以docker build的时候需要指定一下
1 docker build --platform=linux/arm/v7 -t bctg . 
run 1 docker run -d --restart=always --network=host -v $PWD/bean:/bean -v $PWD/config:/config --name bctg -v /etc/localtime:/etc/localtime:ro bctg 
这里映射了localtime文件,主要是让docker的时间和host的时间一样,因为脚本记录的时候需要获取当前时间。
使用host network模式主要是为了设置proxy
配置 beancount_bot.yml 这里配置主要是删除掉了一些自己目前用不上的功能。因为主要用costflow语法,所以把template的功能也关闭了。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 log:      level:  'INFO'  bot:      proxy:  '127.0.0.1:8118'       token:  ''       auth_token:  ''       session_file:  '/config/bot.session'  transaction:      beancount_file:  '/bean/{year}/{month}.bean'       message_dispatcher:                               -  class:  'beancount_bot_costflow.CostflowDispatcher'        args:          costflow_config:  '/config/costflow.json'                                            
costflow.json 这个就相对简单一点,因为我觉得设置account的缩写比较难看,所以这里就没用到account的功能。
1 2 3 4 5 6 7 8 9 {     "mode": "beancount",     "currency": "CNY",     "tag": "#costflow",     "defaultAccount":  "Liabilities:CreditCard:招行信用卡",     "alphavantage": null,     "indent": 2,     "lineLength": 50 } 
效果 
1 2 3 4 5 2022-05-07 * "地铁" #costflow   tgbot_time: "2022-05-07 19:53:17.985351"   tgbot_uuid: "230a4246-b864-495d-8510-ed6f8da75cf1"   Liabilities:CreditCard:招行信用卡                       -0.02 CNY   Expenses:Transport:公交地铁 
这里的tgbot_time暂时没有除修改代码外的方法去除,不过也不碍事,留个记录怕到时候tg的消息找不到。