def __init__(self, username: str, telegram_chat_ids: str): self.sleeper = Sleeper(30) self.username = username self.existing_like_id_set = get_like_id_set(self.get_likes()) logging.info('Init monitor succeed.\nUsername: {}\nLike ids: {}'.format( self.username, self.existing_like_id_set)) self.telegram_notifier = TelegramNotifier(chat_ids=telegram_chat_ids, username=username, module='Like') self.last_log_time = datetime.now()
def __init__(self, username: str, telegram_chat_ids: str): self.sleeper = Sleeper(120) self.username = username self.user_id = get_user_id(username) self.following_users = self.get_all_following_users(self.user_id) logging.info( 'Init monitor succeed.\nUsername: {}\nUser id: {}\nFollowing users: {}' .format(username, self.user_id, self.following_users)) self.telegram_notifier = TelegramNotifier(chat_ids=telegram_chat_ids, username=username, module='Following') self.last_log_time = datetime.now()
def __init__(self, username: str, telegram_chat_ids: str): self.sleeper = Sleeper(10) self.user_id = get_user_id(username) tweets = self.get_tweets() self.last_tweet_id = tweets[0]['id'] logging.info( 'Init monitor succeed.\nUsername: {}\nUser id: {}\nLast tweet: {}'. format(username, self.user_id, tweets[0])) self.telegram_notifier = TelegramNotifier(chat_ids=telegram_chat_ids, username=username, module='Tweet') self.last_log_time = datetime.now()
def __init__(self, chat_ids: str, username: str, module: str): if not chat_ids: logging.warning('Telegram id not set, skip initialization of telegram notifier.') self.bot = None return token = get_token('TELEGRAM_TOKEN') if not token: raise ValueError('TELEGRAM_TOKEN is null, please fill in it.') self.bot = telegram.Bot(token=token) self.chat_ids = chat_ids.split(',') self.username = username self.module = module self.sleeper = Sleeper(1) self.send_message('Init telegram bot succeed.')
# Imports import torch import math import copy from sleeper import Sleeper sleeper = Sleeper() class Academy: def __init__(self, net, data, gpu = False, autoencoder_trainer = False): """ Trains and test models on datasets Args: net (Pytorch model class): Network to train and test data (Tensor Object): Data to train and test with gpu (bool, optional): If True then GPU's will be used. Defaults to False. autoencoder_trainer (bool, optional): If True labels will equal inputs. Defaults to False. """ super(Academy,self).__init__() # Declare GPU usage self.gpu = gpu # Push net to CPU or GPU self.net = net if self.gpu == False else net.cuda()