import datetime
from time import sleep
import vk
def get_status(current_status, vk_api, id):
profiles = vk_api.users.get(user_id=id, fields='online, last_seen', v=5.93)
if (not current_status) and (profiles[0]['online']):
now = datetime.datetime.now()
print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
print('Was online: ', now.strftime("%d-%m-%Y %H:%M"))
return True
if (current_status) and (not profiles[0]['online']):
print('leaved : ', datetime.datetime.fromtimestamp(profiles[0]['last_seen']['time']).strftime('%d-%m-%Y %H:%M'))
print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
return False
return current_status
if __name__ == '__main__':
id = input("User id: ")
session = vk.Session(access_token='1234567890')
vk_api = vk.API(session)
current_status = False
while(True):
current_status = get_status(current_status, vk_api, id)
print("status: " + str(current_status))
sleep(10)
@Component({
selector: 'app-operations-jobs',
templateUrl: './operations-jobs.component.html',
styleUrls: ['./operations-jobs.component.scss']
})
export class OperationsJobsComponent implements OnInit {
addJobForm: FormGroup;
@Input()
currentIdForDelete: number[];
//инизиц. событие
@Output()
addJob: EventEmitter<any> = new EventEmitter()
@Output()
deleteJob: EventEmitter<any> = new EventEmitter()
currentRole: string;
cveArr: Array<number> = [3,4,5,6,7,8,9,10];
constructor(
private fb:FormBuilder,
private dataService: DataService,
private authService: AuthService
) { }
ngOnInit() {
this.buildForm();
this.authService.role
.subscribe((role)=>{
this.currentRole = role;
})
}
buildForm(){
this.addJobForm = this.fb.group(
{ ip:["67.59.156.250/24", Validators.required],
port:["21 22 80 445", Validators.required],
rate:["200", Validators.required],
parsetype:["2", Validators.required],
jobname:["I like this", Validators.required],
jobdescribe:["Additional Info", Validators.required],
apipython:["127.0.0.1", Validators.required],
"cve-score": [this.cveArr[1], Validators.required],
}
);
}
sendData(form){
this.dataService.addJob(form.value)
.subscribe(
(data)=>{
console.log(data);
if(data){
//вызов у родителя
this.addJob.emit(data)
}
},
(error)=>{
console.log(error);
}
)
}
deletUsers(){
console.log(this.currentIdForDelete)
if(this.currentIdForDelete){
this.currentIdForDelete.forEach((elemId)=>{
this.dataService.deleteJobs(elemId)
.subscribe(
(res:any)=>{
if(res.status == 200){
this.deleteJob.emit(res.id)
}},
(err)=>{console.log(err)}
)
})
}
}
}