def main(): config = ConfigParser() config.read("config.ini") # Enable logging logging.basicConfig(filename='app.log', filemode='w', format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO) spotify_remote = SpotifyRemote( config.get("SPOTIFY", "CLIENT_ID"), config.get("SPOTIFY", "CLIENT_SECRET"), config.get("SPOTIFY", "USERNAME"), ) personal_message_handler = PersonalMessageHandler() locations_handler = LocationsHandler() bot = TelegramBot(config.get("TELEGRAM", "TOKEN"), spotify_remote, personal_message_handler, locations_handler) bot.start_bot() try: while not sleep(1): pass except KeyboardInterrupt: pass bot.stop_bot()
def main(): config = configparser.ConfigParser() config.read("config.ini") DIR = config.get("LOCAL_STORAGE", "dir") if not os.path.exists(DIR): os.makedirs(DIR) chatbot = TelegramBot() chatbot.start_bot() procs = [ Process(target=p, args=[chatbot]) for p in [weekly_results_process, live_updates_process] ] [p.start() for p in procs] try: while not sleep(1): pass except KeyboardInterrupt: [p.kill() for p in procs] chatbot.stop_bot() raise SystemExit
import logging import os import ccxt import yaml from tradeexecutor import CryptoExchange, TradeExecutor from telegram_bot import TelegramBot if __name__ == '__main__': logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s', level=logging.INFO) c_dir = os.path.dirname(__file__) with open(os.path.join(c_dir, "..", "secret_key.yml")) as f: file_data = yaml.safe_load(f) ccxt_ex = ccxt.bitfinex() ccxt_ex.apiKey = file_data['api_key'] ccxt_ex.secret = file_data['secret'] exchange = CryptoExchange(ccxt_ex) trade_executor = TradeExecutor(exchange) telegram_bot = TelegramBot(file_data['telegram_ktn'], file_data['user_id'], trade_executor) telegram_bot.start_bot()
def main(): bot = TelegramBot() bot.start_bot()