Ejemplo n.º 1
0
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.'
Ejemplo n.º 2
0
def select_option():
    #SettingCam
    cur = conn.cursor()
    cur.execute("SELECT * FROM smart_setting")
    setting_value = cur.fetchall()
    #print(setting_value)
    cam_select = setting_value[0][1]
    cam_rtsp = setting_value[0][2]
    min_conf_threshold = setting_value[0][3] * 0.01
    #Line notify
    ACCESS_TOKEN = str(setting_value[0][5])
    notify = LineNotify(ACCESS_TOKEN)

    #Select List detect
    cur.execute("SELECT * FROM select_class")
    myresult = cur.fetchall()
    #print(myresult[0][2])
    detect_list = []
    for i in range(len(myresult)):
        if myresult[i][2] == 1:
            detect_list.append(myresult[i][1].lower())
    if setting_value[0][4] == '1080': resW, resH = 1920, 1080
    elif setting_value[0][4] == '720': resW, resH = 1280, 720
    elif setting_value[0][4] == '480': resW, resH = 640, 480
    elif setting_value[0][4] == '360': resW, resH = 480, 360

    return cam_select, cam_rtsp, min_conf_threshold, notify, detect_list, resW, resH
Ejemplo n.º 3
0
def linechat(text):

    ACCESS_TOKEN = "aTxnvziRz4xRKn3rMkWmlNSgnMVR7RRGOSloFIx0OQA"

    notify = LineNotify(ACCESS_TOKEN)

    notify.send(text)
Ejemplo n.º 4
0
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)
Ejemplo n.º 5
0
def post_line(api_url, access_token, image_file_path):
    bot = LineNotify(api_url, access_token)
    payload = {
        'message': '本日の回線速度',
        'stickerPackageId': None,
        'stickerId': None
    }
    image = image_file_path
    return bot.send_message(payload, image)
Ejemplo n.º 6
0
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()
Ejemplo n.º 7
0
def linechat(text):

    ACCESS_TOKEN = "oK2sk4w1eidfRyOVfgIcln38TBS8JmL0PgfbbQ8t0Zv"
    notify = LineNotify(ACCESS_TOKEN)
    notify.send(text)
Ejemplo n.º 8
0
 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
        "Close": close  # 終値
    })

    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] \
Ejemplo n.º 10
0
def linechat(text):
    ACCESS_TOKEN = "12CiN1mDzj3q93N5aTYvtWX63XlQOqDs6FWizTRUx1y"
    notify = LineNotify(ACCESS_TOKEN)
    notify.send(text)
Ejemplo n.º 11
0
 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()
Ejemplo n.º 12
0
def linechat(text):    
    ACCESS_TOKEN = "qh4YLKs18Z4RYKLvsFnLmgtVWmSpi7pY7KS112AFl7C"
    notify = LineNotify(ACCESS_TOKEN)
    notify.send(text)
import time
import requests

from line_notify import LineNotify

## สำหรับทำ Progress Bar
import time
import progressbar

tag_value = "สถานที่ท่องเที่ยวต่างประเทศ"
last_id = 0
n_page = 1

ACCESS_TOKEN = "xFxSCXHfq1LUBW6eYGUNzeX4KrCv1IAfNFFEuc4aLll"

notify = LineNotify(ACCESS_TOKEN)


def getTopicByTag(tag_value, last_id, n_page):

    with progressbar.ProgressBar(max_value=n_page) as bar:
        my_data = {}  # Topic and TID
        tag_list = {}  # Tag Topic ID

        for p in range(n_page):
            json_search = "https://pantip.com/forum/topic/ajax_json_all_topic_tag"

            post_data = {
                'last_id_current_page': last_id,
                'dataSend[tag]': urllib.parse.quote(tag_value),
                'dataSend[topic_type][type]': 0,
Ejemplo n.º 14
0
from line_notify import LineNotify

try:
    from config_dev import *

except:
    from config_prod import *

notify = LineNotify(LINE_NOTIFY_TOKEN)


def SendMsg(msg):
    notify.send(msg)
Ejemplo n.º 15
0
 def test___init__(self):
     # invalid token
     with self.assertRaises(RuntimeError):
         LineNotify(token='')
Ejemplo n.º 16
0
 def setUpClass(cls):
     # from environment variable LINENOTIFY_TOKEN
     cls.client = LineNotify(token=None)
Ejemplo n.º 17
0
def sendMessage(message):
    token = '7w9sX5x78568L8lCGQ27hfvEyXPfzxZF2orUcCavcJ2'

    notify = LineNotify(token)
    notify.send(message, sticker_id=283, package_id=4)
Ejemplo n.º 18
0
from flask import render_template
import time
from datetime import datetime as dt
import pytz
import smtplib
from email.mime.multipart import MIMEMultipart #email內容載體
from email.mime.text import MIMEText #用於製作文字內文
from email.mime.base import MIMEBase #用於承載附檔
from email import encoders #用於附檔編碼

from line_notify import LineNotify
import os


line_url_token = '3igcvnwqH2eV54CZN6N67CpYZDBgiUNW34qjCK07tPL'
notify = LineNotify(line_url_token)
tz = pytz.timezone('Asia/Taipei')

#取得通行憑證
cred = credentials.Certificate("serviceAccount.json")
firebase_admin.initialize_app(cred, {
    'databaseURL' : 'https://line-bot-test-77a80.firebaseio.com/'
})

access_token = '4vOSpHm6ybXdM4H8juFy82HfM2TSUVE3Ty2FLoT+5kjTzNhQdzz1dUfquvRaMCKuqbt/YYXbPj2Kv3W2MKDkxdtZWJZgcC+gKg2RyphLbPF0uaqybQurPvX9sT+eFFY1Qf8z4KuhvqT3tPdr/pX+/wdB04t89/1O/w1cDnyilFU='
channel_secret = '17af62e5969376a42034ad93f6bf9efe'
line_token = "3eTUCezVGnutNS538jzHElsVlWoHh9nTSpGVm2tbDfx"

app = Flask(__name__)

line_bot_api = LineBotApi(access_token)
Ejemplo n.º 19
0
def send_notification(message):
    notice = LineNotify(ACCESS_TOKEN)
    notice.send(message)
Ejemplo n.º 20
0
 def __init__(self, hass, access_token):
     """Initialize the service."""
     self._access_token = access_token
     self.hass = hass
     self._notify = LineNotify(access_token)