Portage NixOS

This commit is contained in:
nyanloutre 2018-06-27 20:00:36 +02:00
parent 61e491699f
commit ebf12e00a4
7 changed files with 75 additions and 24 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
__pycache__
*.egg-info
result
api_keys.env

View File

@ -1,8 +0,0 @@
FROM python:alpine
RUN apk add --no-cache gcc g++ make libffi-dev openssl-dev && \
pip install python-telegram-bot requests block-io
COPY run.py /
CMD ["python", "run.py"]

View File

@ -1,7 +0,0 @@
.PHONY: build
build:
docker build -t dogetipbot .
.PHONY: run
run: build
docker run --rm --name dogetipbot --env-file api_keys.env dogetipbot

View File

@ -1,3 +0,0 @@
BLOCK_IO_API_KEY=123455678
BLOCK_IO_PIN=12345678
TELEGRAM_API_KEY=12345678

26
default.nix Normal file
View File

@ -0,0 +1,26 @@
{ pkgs ? import <nixpkgs> {}
}:
let
inherit (pkgs) fetchgit;
inherit (blockioPkgs) python3;
blockioPkgs = import (fetchgit {
url = "https://github.com/nyanloutre/nixpkgs.git";
rev = "b2e5d6520e16e6188b13ee79712078b072e253f5";
sha256 = "0gjy61vpm434fvfwb6kbgsmd9d8k7w4kk68vxikivys805h4sxd0";
}){};
in
python3.pkgs.buildPythonApplication rec {
name = "dogetipbot-telegram-${version}";
version = "1.0";
src = ./.;
propagatedBuildInputs = with python3.pkgs; [
python-telegram-bot
requests
block-io
];
}

29
run.py → dogetipbot_telegram.py Normal file → Executable file
View File

@ -5,11 +5,27 @@ import logging
import os import os
import urllib.request import urllib.request
import json import json
import argparse
BLOCK_IO_API_KEY = os.environ['BLOCK_IO_API_KEY'] # BLOCK_IO_API_KEY = os.environ['BLOCK_IO_API_KEY']
BLOCK_IO_PIN = os.environ['BLOCK_IO_PIN'] # BLOCK_IO_PIN = os.environ['BLOCK_IO_PIN']
TELEGRAM_API_KEY = os.environ['TELEGRAM_API_KEY'] # TELEGRAM_API_KEY = os.environ['TELEGRAM_API_KEY']
NETWORK = os.environ['NETWORK'] # NETWORK = os.environ['NETWORK']
# Parsing arguments
parser = argparse.ArgumentParser(description='Dogetipbot telegram')
parser.add_argument('--block-io-api-key')
parser.add_argument('--block-io-pin')
parser.add_argument('--telegram-api-key')
parser.add_argument('--network')
args = parser.parse_args()
BLOCK_IO_API_KEY = args.block_io_api_key
BLOCK_IO_PIN = args.block_io_pin
TELEGRAM_API_KEY = args.telegram_api_key
NETWORK = args.network
# Logging # Logging
@ -216,5 +232,6 @@ dispatcher.add_handler(infos_handler)
withdraw_handler = CommandHandler('withdraw', withdraw, pass_args=True) withdraw_handler = CommandHandler('withdraw', withdraw, pass_args=True)
dispatcher.add_handler(withdraw_handler) dispatcher.add_handler(withdraw_handler)
updater.start_polling() def main():
updater.idle() updater.start_polling()
updater.idle()

22
setup.py Normal file
View File

@ -0,0 +1,22 @@
from setuptools import setup
setup(
name='dogetipbot-telegram',
py_modules=['dogetipbot_telegram'],
version='1.0',
description='Telegram bot for tipping Dogecoins',
author='Paul TREHIOU',
author_email='paul@nyanlout.re',
url='https://gitea.nyanlout.re/nyanloutre/dogetipbot-telegram',
license='MIT',
entry_points={
'console_scripts': [
'dogetipbot-telegram=dogetipbot_telegram:main'
]
},
install_requires=[
'python-telegram-bot',
'requests',
'block-io'
]
)