Пример #1
0
    def send_Line(self, token):

        text = self.report()

        for k, tk in token.items():
            messenger = Sendline(tk)
            messenger.sendtext(text)
            print('Sent to :' + k)
Пример #2
0
# import package
from songline import Sendline

token = 'm7wHTQVaFdLju5MHW4rQgLpXSBaOMRcylCyRdwXzTvJ'
messenger = Sendline(token)

#messenger.sendtext('ไม่วู้')
#messenger.sticker(173,2)

img = 'https://static.posttoday.com/media/content/2017/11/23/35B73BCDE4784DB6836C26E43BF54395_1000.jpg'

messenger.sendimage(img)
Пример #3
0
    # print('server time: ',time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(1347517370))) # convert server time to local time
    
    checktext = checkCondition(ticker)
    if len(checktext)>0:
        textLine += checktext
        messenger.sendtext(textLine)

    time.sleep(0.5) # 0.5sec
    checkPrice()


### ========= main =========
API_HOST = 'https://api.bitkub.com' # base URL

token = tkn.TOKEN # line to me
messenger = Sendline(token) # send message

btc = 'THB_BTC'
eth = 'THB_ETH'

marketTicker = requests.get(API_HOST+'/api/market/ticker') # all coin in board
ticker = marketTicker.json() # change to dictionary(json)

btcValue = ticker[btc]['last']
ethValue = ticker[eth]['last']
usdtValue = ticker['THB_USDT']['last']
bnbValue = ticker['THB_BNB']['last']
bandValue = ticker['THB_BAND']['last']
dogeValue = ticker['THB_DOGE']['last']
# value_list = [btcValue,ethValue,usdtValue,bnbValue,bandValue,dogeValue]
value_list = [btcValue]
Пример #4
0
    #Path for MAC
    PATH_MAC = '/Users/TopBook/Google Drive/CODE/AUTORUN/'
    covid19_thai = Covid19_thai(url_2, PATH_MAC + 'covid19-thai-recorded.csv')
    # print( covid19_thai.report())

    token_all = {
        "user1 (ตังเอง)": '< user 1 - Token >',
        "ีuser2": '< please insert Token >',
        "user3": '< please insert Token >',
        "user4": '< please insert Token >',
        "user5": '< please insert Token >'
    }
    chk, dmm = covid19_thai.check_change()

    covid19_thai.get_patient_url_2()

    if (chk == False):

        token = {"user1 (ตังเอง)": '< please insert Token >'}
        covid19_thai.send_Line(token)
        messenger = Sendline(token["user1 (ตังเอง)"])
        messenger.sendtext("The program is running...")
        print("The program is running...")

    elif (chk):

        # covid19_thai.send_Line(  token_all )
        print("Send to ALL ")

    covid19_thai.update_to_csv(chk)
Пример #5
0
def write_data_point2():
    ''''
         10 นาที = 2 จุด
         15 นาที = 3 จุด
         20 นาที = 4 จุด
         25 นาที = 5 จุด
         30 นาที = 6 จุด
    '''
# กำหนดตัวแปรจำนวนจุด conti = Continuously
    content = request.get_json()
    
    temperature       = content['temperature']
    humidity          = content['humidity']
    node_name1 = content['node']
    dateTime          = content['dateTime']
    print(f'temp={temperature}')
    print(f'hu={humidity}')
    print(f'node={node_name1}')
    print(f'dateTime ={dateTime}')
    nodes = Node_SetUp.query.filter_by(node=node_name1)
    
    
    len_ab_temp=[]
    no_de=node_name1
    for n in nodes:
        time_alert = int(n.time_alert) #เวลาเป็นาทีที่เลือกให้เตือน
        print(f'time_alert ={time_alert}, type = {type(time_alert)}')
        count = time_alert / 5
        int_count=int(count)
        print(f'int_count ={int_count}, type = {type(int_count)}')
        t_h_alert = n.temp_hight_alert
        t_l_alert = n.temp_low_alert
        # temp = Temp_data.query.filter_by(node_name1=n.node).order_by(Temp_data.id.desc())
        e = n.staff.email.split(",")   #แบ่งอีเมลของแต่ละคนออกมาเป็น list
        
        now = datetime.datetime.now()
        min_time_alert = datetime.timedelta(minutes=time_alert)
        print(f'now = {now}')
        print(f'min_time_alert = {min_time_alert}')
        diff_time = (now - min_time_alert)
        print(f'diff_time = {diff_time}')
        email = e
        user  =n.staff.username  
        try:     
            temp = Temp_data.query.filter(Temp_data.dateTime >= diff_time).filter(Temp_data.dateTime <= now)
            for t in temp:
                last_ab_temp=t.ab_temp[-1]
                messenger = Sendline(token)
                print(f'n.node={node_name1}')
                messenger.sendtext(f'อุณหภูมิของ {node_name1} ขณะนี้เท่ากับ {t.ab_temp} องศาเซลเซียส กรุณาตรวจสอบ')
            # for t in temp:
            #     print(f't.ab_temp = {t.ab_temp}:{len(t.ab_temp)}')
            #     print(len(t.ab_temp))
                # if len(t.ab_temp) >= count:
                #     print(f't.ab_temp = {t.ab_temp}')
                #     send_email_alert(email,user,no_de,t.ab_temp)
                # else:
                #     print('No No No')
                
        except:
            pass
        
            



        
        # send_email_alert(email,user,no_de,tempss)  
            
        
    return addData(dateTime,humidity,node_name1,temperature)
Пример #6
0
time_today = str(currentDT.strftime("%Y-%m-%d  %H:%M:%S"))

text_ = 'ขณะนี้มียอดผู้ป่วย Covid19 ในประเทศไทยที่ยืนยันแล้ว \nจำนวน ' + covid_num + ' คน \nข้อมูลวันที่ ' + time_today

print(text_)

last_covid19 = int(last_covid19)
covid_num = int(covid_num)

if (covid_num > last_covid19):

    text_ = text_ + '\nมียอดผู้ป่วยเพิ่มขึ้น : ' + str(covid_num -
                                                       last_covid19) + ' คน'

    messenger = Sendline(token_me)
    messenger.sendtext(text_)

    messenger = Sendline(token_line_group)
    messenger.sendtext(text_)

elif (covid_num < last_covid19):

    text_ = text_ + '\nมียอดผู้ป่วยลดลง: ' + str(last_covid19 -
                                                 covid_num) + ' คน'

    messenger = Sendline(token_me)
    messenger.sendtext(text_)

    messenger = Sendline(token_line_group)
    messenger.sendtext(text_)
Пример #7
0
from flask import Flask
from binance.client import Client
from songline import Sendline
from apscheduler.schedulers.background import BackgroundScheduler
try:
    from config_dev import API_BINANCE_KEY, API_BINANCE_SECRET, API_LINE_TOKEN
except Exception:
    from config_prod import API_BINANCE_KEY, API_BINANCE_SECRET, API_LINE_TOKEN

#+++ Start Connection +++
app = Flask(__name__)
api_key = API_BINANCE_KEY
api_secret = API_BINANCE_SECRET
client = Client(api_key, api_secret)
token = API_LINE_TOKEN
lineNoti = Sendline(token)
sched = BackgroundScheduler(daemon=True)
#+++ End Connection +++


def signal_by_ema(symbols):
    try:
        #print("In Coin : " + symbols)
        #klines = client.get_historical_klines(symbols, Client.KLINE_INTERVAL_30MINUTE , "120 minutes ago UTC")
        #klines = client.get_historical_klines(symbols, Client.KLINE_INTERVAL_30MINUTE, "860 minutes ago UTC")
        klines = client.get_historical_klines(symbols,
                                              Client.KLINE_INTERVAL_1HOUR,
                                              "250 hours ago UTC")
        closes = [float(i[4]) for i in klines]
        closes = np.array(closes)
        if len(closes) > 0:
Пример #8
0
from songline import Sendline

token = 'YnC15ij9ilV76PuK8A8W2GEUbUFlAaTP3DU6eazEVBA'

messager = Sendline(token)

# messager.sendtext('Hello World')
messager.sticker(300, 4)