コード例 #1
0
 def __init__(self):
     while True:
         for folder in os.listdir("./users"):
             for file in os.listdir("./users/" + folder):
                 pid = open("./users/" + folder + "/" + file,
                            'r').readline().replace('\n', '')
                 path = '/proc/' + pid
                 if os.path.exists(path):
                     print("Pid ", file, ' is OK')
                 else:
                     buddy = knocker.Knocker(token=open(
                         './token.token', 'r').readline().replace('n', ''))
                     buddy.SendMsg("PID: " + (file + ' - ' + pid) +
                                   " is not OK",
                                   peerId=int(folder))
         time.sleep(120)
コード例 #2
0
ファイル: main.py プロジェクト: HoolyPanda/p1566058768
def main():
    credentials = json.load(open("credentials.json", 'r',
                                 encoding='utf-8-sig'))
    a = knocker.Knocker(login=credentials['login'],
                        password=credentials['password'],
                        token=credentials['token'],
                        groupId=int(credentials['groupid']))
    targetFolder = credentials['targetfolder']
    uploadFlag = False
    while True:
        for osFile in os.listdir(targetFolder):
            # m = open('message', 'r', encoding='ansi').read()
            print('Found new file')
            a.PostFile(dicId=a.UploadFile(file=targetFolder + "\\" + osFile),
                       message=open('message.txt', 'r',
                                    encoding='utf-8-sig').read())
            os.remove(targetFolder + '\\' + osFile)
            time.sleep(int(credentials['timeout']))
            uploadFlag = True
        pass
        if not uploadFlag:
            # print('Folder is empty')
            time.sleep(int(credentials['timeout']))
コード例 #3
0
ファイル: SheduleBot.py プロジェクト: HoolyPanda/SheduleBot
                            a += f'{str(d.year)}'
                            url += f'#{a}'
                            self.date = a
                except Exception as e:
                    print(str(e))
                    pass
                pass
            else:
                break
        pass


print(os.getpid())
token = open("./token.token", 'r').readline()
bot = knocker.Knocker(token=token)
Farseer.SpawnConfig(name="SheduleBot", peerId=160500068)
sheduleBot = SheduleBot()

while True:
    m = datetime.datetime.now().minute
    if m >= 10:
        currentTime = str(datetime.datetime.now().hour) + ":" + str(
            datetime.datetime.now().minute)
    else:
        currentTime = str(datetime.datetime.now().hour) + ":0" + str(
            datetime.datetime.now().minute)
    config = json.load(open('./config.json', 'r'))
    for group in config["Groups"]:
        sheduleBot.group = group
        if currentTime == "6:00" and group["finalClassEnds"] == '':
コード例 #4
0
ファイル: main.py プロジェクト: HoolyPanda/SiteChecker
import vk_api
import os
import random
import time
import Farseer
import requests
import knocker

Knocker = knocker.Knocker(token=open('./token.cred', 'r').readline())


def ping(target: str):
    req = requests.get('https://' + target.replace('\n', '') + '/',
                       verify=False)
    if req.status_code == 200:
        print("======================================  " +
              target.replace('\n', "") + " is Up")
    else:
        msg = target.replace('\n',
                             '') + f' is down, code: {str(req.status_code)}'
        print(msg)
        bot = vk_api.VkApi(token=open("./token.cred", "r").readline())
        bot._auth_token()
        for line in open('./peers.cred', 'r').readlines():
            try:
                Knocker.SendMsg(messageText=msg, peerId=int(line))
            except Exception as e:
                print(str(e))
                pass
        # bot.method("messages.send",{"peer_id": 160500068, "random_id" : random.randint(1, 1000),"message": msg})