Exemple #1
0
def linechat(text):

    ACCESS_TOKEN = "aTxnvziRz4xRKn3rMkWmlNSgnMVR7RRGOSloFIx0OQA"

    notify = LineNotify(ACCESS_TOKEN)

    notify.send(text)
Exemple #2
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)
Exemple #3
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)
Exemple #4
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
Exemple #5
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()
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.'
Exemple #7
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] \
Exemple #9
0
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)
Exemple #10
0
def linechat(text):
    ACCESS_TOKEN = "12CiN1mDzj3q93N5aTYvtWX63XlQOqDs6FWizTRUx1y"
    notify = LineNotify(ACCESS_TOKEN)
    notify.send(text)
Exemple #11
0
import datetime
from datetime import timedelta
from io import BytesIO

import numpy as np
from azure.storage.blob import BlobClient, BlobServiceClient, ContainerClient
from line_notify import LineNotify
from sklearn.mixture import GaussianMixture

from config_netatmo import *

ACCESS_TOKEN = "ruqitvgHdqSdlxregyLX6aT5956wrmexnyX5jv9PA0w"

notify = LineNotify(ACCESS_TOKEN)


class azure_manage():
    def __init__(self, connection_str, container_name):
        self.connection_str = connection_str
        self.container_name = container_name
        self.container_client = ContainerClient.from_connection_string(
            conn_str=self.connection_str, container_name=self.container_name)
        print("'azure_manage' object is creted")

    def get_all_blobs(self):
        """
        return list of blob names
        """
        blob_list = self.container_client.list_blobs()
        name_list = [blob['name'] for blob in blob_list]
        return name_list
Exemple #12
0
def sendMessage(message):
    token = '7w9sX5x78568L8lCGQ27hfvEyXPfzxZF2orUcCavcJ2'

    notify = LineNotify(token)
    notify.send(message, sticker_id=283, package_id=4)
Exemple #13
0
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()
Exemple #14
0
 def __init__(self, hass, access_token):
     """Initialize the service."""
     self._access_token = access_token
     self.hass = hass
     self._notify = LineNotify(access_token)
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)
Exemple #16
0
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
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,
Exemple #18
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)
Exemple #19
0
 def test___init__(self):
     # invalid token
     with self.assertRaises(RuntimeError):
         LineNotify(token='')
Exemple #20
0
 def setUpClass(cls):
     # from environment variable LINENOTIFY_TOKEN
     cls.client = LineNotify(token=None)
Exemple #21
0
def linechat(text):    
    ACCESS_TOKEN = "qh4YLKs18Z4RYKLvsFnLmgtVWmSpi7pY7KS112AFl7C"
    notify = LineNotify(ACCESS_TOKEN)
    notify.send(text)
Exemple #22
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()
Exemple #23
0
def linechat(text):

    ACCESS_TOKEN = "oK2sk4w1eidfRyOVfgIcln38TBS8JmL0PgfbbQ8t0Zv"
    notify = LineNotify(ACCESS_TOKEN)
    notify.send(text)
Exemple #24
0
def getDiffApiETC():
    key = 'etc'

    class AppURLopener(urllib.request.FancyURLopener):
        version = "Mozilla/5.0"

    opener = AppURLopener()
    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))
Exemple #25
0
def send_notification(message):
    notice = LineNotify(ACCESS_TOKEN)
    notice.send(message)
Exemple #26
0
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)