def handle_request(): """Responds to any HTTP request. Args: request (flask.Request): HTTP request object. Returns: The response text or any set of values that can be turned into a Response object using `make_response <http://flask.pocoo.org/docs/1.0/api/#flask.Flask.make_response>`. """ #region configuration with open("private/config.json") as json_data_file: config = json.load(json_data_file) ACCESS_TOKEN = config['notify_token'] REPORT_URL = "https://datastudio.google.com/embed/reporting/{report_id}/page/{page_id}".format( report_id=config['report']['id'], page_id=config['report']['page'] ) COOKIES_JSON_PATH = config['cookies_json_path'] #endregion driver = SeleniumUtils.get_webdriver() notify = LineNotify(ACCESS_TOKEN) driver = SeleniumUtils.add_cookies(driver, COOKIES_JSON_PATH) driver.get(REPORT_URL) captured_image_path, captured_status = SeleniumUtils.capture_report_screeen(driver) if captured_status is not None: data_date = time.strftime("%m/%d/%Y, %H:%M:%S", time.localtime(time.time())) notify.send(f"Dashboard as of {data_date}", image_path=captured_image_path) SeleniumUtils.teardown_webdriver(driver) else: notify.send("Unable to capture report screen\n\n Please contact admin to refresh cookies or validate issue.", image_path=captured_image_path) SeleniumUtils.teardown_webdriver(driver) return 'Successfully send line notify dashboard.'
def linechat(text): ACCESS_TOKEN = "aTxnvziRz4xRKn3rMkWmlNSgnMVR7RRGOSloFIx0OQA" notify = LineNotify(ACCESS_TOKEN) notify.send(text)
def send_notification(message): """ Send LINE notification :param message: The message to be sent via LINE :type str: """ notice = LineNotify(ACCESS_TOKEN) notice.send(message)
def main(): payload = { "form_username": KU_id, "form_password": KU_pass, } session_requests = requests.session() login_url = "https://stdregis.ku.ac.th/_Login.php" result = session_requests.get(login_url) result = session_requests.post(login_url, data=payload, headers=dict(referer=login_url)) url = 'https://stdregis.ku.ac.th/_Student_RptKu.php?mode=KU20' result = session_requests.get(url, headers=dict(referer=url)) soup = BeautifulSoup(result.text, 'html.parser') soup_table = BeautifulSoup(str(soup.find_all("table", class_="table")), 'lxml') tag = soup_table.table notify = LineNotify(Line_token) tag = tag.text tag = tag.split("Second Semester 2017")[1] tag = tag.replace("CodeCourse", "") tag = tag.replace("Course", "") tag = tag.replace("TitleGradeCredit", "") tag = tag.replace("01", "\n01") tag = tag.replace("sem. G.P.A.", "\nsem. G.P.A.") tag = tag.replace("cum. G.P.A.", "\ncum. G.P.A.") check = False for t in tag.split("\n"): check = False revt = ''.join(reversed(t)) o = 0 for i in revt: if o == 1: if i == 'N': check = True break o += 1 if check: continue if str(t)[0] == '0': print(t) notify.send(t) print()
class Controller: def __init__(self, token_line, token_todoist, vacation_mode_pj=None): self._holidays = requests.get( "https://holidays-jp.github.io/api/v1/date.json").json() self._line_notify = LineNotify(token_line, name="todoist") self._todoist_api = TodoistAPI(token_todoist, cache="/tmp/") self._todoist_vacation_mode_pj = vacation_mode_pj def _is_vacation_mode_on(self): return self._todoist_api.completed.get_stats( )['goals']['vacation_mode'] == 1 def _is_today_holiday(self): today = datetime.date.today().strftime("%Y-%m-%d") return today in self._holidays.keys() def _get_custom_date_tasks(self): today = datetime.date.today().strftime("%Y-%m-%d") tasks = [] if self._todoist_vacation_mode_pj is None: return tasks for item in self._todoist_api.projects.get_data( self._todoist_vacation_mode_pj)['items']: due = item['due']['date'] if due and due == today: tasks.append(item) return tasks def _has_any_custom_date_tasks(self): return len(self._get_custom_date_tasks()) > 0 def _should_change_vacation_mode_on(self): return not self._is_vacation_mode_on() and ( self._is_today_holiday() or self._has_any_custom_date_tasks()) def _should_change_vacation_mode_off(self): return self._is_vacation_mode_on() and not self._is_today_holiday( ) and not self._has_any_custom_date_tasks() def _complete_custom_date_tasks(self): if not self._has_any_custom_date_tasks(): return for item in self._get_custom_date_tasks(): self._todoist_api.items.get_by_id(item['id']).complete() self._todoist_api.commit() def execute(self): if self._should_change_vacation_mode_on(): vacation = 1 notify_message = "バケーションモードをONにしました。" elif self._should_change_vacation_mode_off(): vacation = 0 notify_message = "バケーションモードをOFFにしました。" else: return before_vacation_mode = self._is_vacation_mode_on() self._todoist_api.user.update_goals(vacation_mode=vacation) self._todoist_api.commit() if self._is_vacation_mode_on() == before_vacation_mode: notify_message = "バケーションモードの変更に失敗しました。" self._line_notify.send(notify_message)
}) return candles # 単純移動平均線を算出 def make_sma(candles, span): return pd.Series(candles["Close"]).rolling(window=span).mean() bb_api = BbApi() symbol = "BTC/USD" # 通貨ペア amount = 1 # 注文量(USD) line_notify = LineNotify() line_notify.send("Start trading") print("Start trading") # Botを起動 while True: try: candles = get_candles("minute", 1000).set_index("Time") sma_5 = make_sma(candles, 5) # 短期移動平均線を作成 sma_13 = make_sma(candles, 13) # 長期移動平均線を作成 # 短期移動平均線 > 長期移動平均線 の状態が3本続いたらゴールデンクロス(騙し防止のために判断まで少し待つ) golden_cross = sma_5.iloc[-1] > sma_13.iloc[-1] \ and sma_5.iloc[-2] > sma_13.iloc[-2] \ and sma_5.iloc[-3] > sma_13.iloc[-3] \ and sma_5.iloc[-4] < sma_13.iloc[-4]
weights_ = np.load(load_bytes, allow_pickle=True) gmm = GaussianMixture(n_components=len(means), covariance_type='full') gmm.precisions_cholesky_ = np.linalg.cholesky(np.linalg.inv(covar)) gmm.weights_ = weights_ gmm.means_ = means gmm.covariances_ = covar ws.get_data() data = ws.devices[0]['dashboard_data'] timestamp = datetime.datetime.fromtimestamp( data['time_utc']) + timedelta(hours=7) msg = f"\nDatetime : {timestamp.strftime('%Y-%m-%d %H:%M:%S')} \ \nTemperature : {data['Temperature']} \ \nCO2 : {data['CO2']} \ \nHumidity : {data['Humidity']} \ \nNoise : {data['Noise']} \ " x = np.array( [data['Temperature'], data['Humidity'], data['CO2'], data['Noise']]).reshape(1, -1) if gmm.predict(x)[0] == 0: msg += '\nNo people in the room' else: msg += '\nPeople in the room' notify.send(msg)
def linechat(text): ACCESS_TOKEN = "12CiN1mDzj3q93N5aTYvtWX63XlQOqDs6FWizTRUx1y" notify = LineNotify(ACCESS_TOKEN) notify.send(text)
def actions_update(self): token = '7w9sX5x78568L8lCGQ27hfvEyXPfzxZF2orUcCavcJ2' notify = LineNotify(token) notify.send('Upadate Data already') self.state_view.setText("Update data base complete.") Face_functions.trainModel()
def linechat(text): ACCESS_TOKEN = "qh4YLKs18Z4RYKLvsFnLmgtVWmSpi7pY7KS112AFl7C" notify = LineNotify(ACCESS_TOKEN) notify.send(text)
def sendMessage(message): token = '7w9sX5x78568L8lCGQ27hfvEyXPfzxZF2orUcCavcJ2' notify = LineNotify(token) notify.send(message, sticker_id=283, package_id=4)
response = opener.open('https://api-etc.ethermine.org/networkStats') apiDiff = json.load(response) rawdiff = apiDiff['data'] diffETC = rawdiff['difficulty'] coins[key].difficulty = diffETC #print(diffETC) notify = LineNotify(ACCESS_TOKEN) while True: getDiffApiRVN() #getDiffApiETH() #getDiffApiETC() for key in coins: if coins[key].willingtomonitor == True: print("Coin notify : " + coins[key].name) print("Time scan :" + timescan + " sec") print("date : " + datetime.datetime.now().strftime("%Y-%m-%d %H:%M")) if float(coins[key].difficulty) <= float(coins[key].targetDiff): print(coins[key].difficulty) print(coins[key].targetDiff) notify.send(key + " Diff: " + str(coins[key].difficulty)) #tmin = int(timescan) / 60 #notify.send("time scan : " + str(timescan) + " sec = " + str(tmin) + " min ") #notify.send("date: "+datetime.datetime.now().strftime("%Y-%m-%d %H:%M")) #delay (sec) time.sleep(int(timescan))
from line_notify import LineNotify #ACCESS_TOKEN = 'TOKEN' ACCESS_TOKEN = '2bXUH7qIDsnWKOkACnWDTD5OlvYEBJ0umNfjL5jEZh3' #1 to 1 notify = LineNotify(ACCESS_TOKEN) notify.send('附張照片') notify.send("合掌村", image_path='./image.jpg') #ACCESS_TOKEN = 'A29E1yosXT9rKIqMHadrhESoRJK8WT6TE2qqtttd6O4' #1234
from ftplib import FTP from time import sleep from line_notify import LineNotify ACCESS_TOKEN = "your token" notify = LineNotify(ACCESS_TOKEN) ftp = FTP('localhost') ftp.login('root', '1234') def changemon(dir='./'): ls_prev = set() while True: ls = set(ftp.nlst(dir)) add, rem = ls - ls_prev, ls_prev - ls if add or rem: yield add, rem ls_prev = ls sleep(5) for add, rem in changemon(): print('\n'.join('+ %s' % i for i in add)) notify.send('+ %s' % i for i in add) ftp.quit()
def linechat(text): ACCESS_TOKEN = "oK2sk4w1eidfRyOVfgIcln38TBS8JmL0PgfbbQ8t0Zv" notify = LineNotify(ACCESS_TOKEN) notify.send(text)
def send_notification(message): notice = LineNotify(ACCESS_TOKEN) notice.send(message)
class LineNotificationService(BaseNotificationService): """Implement the notification service for LINE""" def __init__(self, hass, access_token): """Initialize the service.""" self._access_token = access_token self.hass = hass self._notify = LineNotify(access_token) def send_message(self, message="", **kwargs): """Send a message to a user.""" service_data = { ATTR_TARGET: kwargs.get(ATTR_TARGET, self._access_token) } if ATTR_TITLE in kwargs: service_data.update({ATTR_TITLE: kwargs.get(ATTR_TITLE)}) if message: service_data.update({ATTR_MESSAGE: message}) data = kwargs.get(ATTR_DATA) # Get keyboard info if data is not None and ATTR_KEYBOARD in data: keys = data.get(ATTR_KEYBOARD) keys = keys if isinstance(keys, list) else [keys] service_data.update(keyboard=keys) elif data is not None and ATTR_INLINE_KEYBOARD in data: keys = data.get(ATTR_INLINE_KEYBOARD) keys = keys if isinstance(keys, list) else [keys] service_data.update(inline_keyboard=keys) # Send a photo, video, document, or location if data is not None and ATTR_PHOTO in data: photos = data.get(ATTR_PHOTO, None) photos = photos if isinstance(photos, list) else [photos] for photo_data in photos: service_data.update(photo_data) self.hass.services.call(DOMAIN, "send_photo", service_data=service_data) return if data is not None and ATTR_VIDEO in data: videos = data.get(ATTR_VIDEO, None) videos = videos if isinstance(videos, list) else [videos] for video_data in videos: service_data.update(video_data) self.hass.services.call(DOMAIN, "send_video", service_data=service_data) return if data is not None and ATTR_LOCATION in data: service_data.update(data.get(ATTR_LOCATION)) return self.hass.services.call(DOMAIN, "send_location", service_data=service_data) if data is not None and ATTR_DOCUMENT in data: service_data.update(data.get(ATTR_DOCUMENT)) return self.hass.services.call(DOMAIN, "send_document", service_data=service_data) # Send message _LOGGER.debug("LINE NOTIFIER calling %s.send_message with %s", DOMAIN, service_data) self._notify.send(message)