init Crystal
This commit is contained in:
parent
6950e5f050
commit
09ca61e016
9
.editorconfig
Normal file
9
.editorconfig
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*.cr]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
trim_trailing_whitespace = true
|
6
.gitignore
vendored
6
.gitignore
vendored
@ -1 +1,7 @@
|
|||||||
|
/docs/
|
||||||
|
/lib/
|
||||||
|
/bin/
|
||||||
|
/.shards/
|
||||||
|
*.dwarf
|
||||||
|
|
||||||
config.json
|
config.json
|
||||||
|
6
.travis.yml
Normal file
6
.travis.yml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
language: crystal
|
||||||
|
|
||||||
|
# Uncomment the following if you'd like Travis to run specs and check code formatting
|
||||||
|
# script:
|
||||||
|
# - crystal spec
|
||||||
|
# - crystal tool format --check
|
37
LICENSE
37
LICENSE
@ -1,24 +1,21 @@
|
|||||||
This is free and unencumbered software released into the public domain.
|
The MIT License (MIT)
|
||||||
|
|
||||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
Copyright (c) 2021 Alexander Popov <iiiypuk@iiiypuk.me>
|
||||||
distribute this software, either in source code form or as a compiled
|
|
||||||
binary, for any purpose, commercial or non-commercial, and by any
|
|
||||||
means.
|
|
||||||
|
|
||||||
In jurisdictions that recognize copyright laws, the author or authors
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software dedicate any and all copyright interest in the
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
software to the public domain. We make this dedication for the benefit
|
in the Software without restriction, including without limitation the rights
|
||||||
of the public at large and to the detriment of our heirs and
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
successors. We intend this dedication to be an overt act of
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
relinquishment in perpetuity of all present and future rights to this
|
furnished to do so, subject to the following conditions:
|
||||||
software under copyright law.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
The above copyright notice and this permission notice shall be included in
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
all copies or substantial portions of the Software.
|
||||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
||||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
||||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
||||||
OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
For more information, please refer to <http://unlicense.org>
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
39
README.md
39
README.md
@ -1,10 +1,12 @@
|
|||||||
# service for set status online on vk.com
|
# vk0nline
|
||||||
Скрипт для поддержания статуса __Онлайн__ в социальной сети Vk.com
|
Утилита для поддержания статуса __Онлайн__ в социальной сети Vk.com.
|
||||||
включает в себя `Python` скрипт `systemd` юнит.
|
|
||||||

|
|
||||||
|
|
||||||
## Установка:
|
Включает в себя `systemd` юнит.
|
||||||
+ Активировать автоматический запуск сессии пользователя
|
|
||||||
|

|
||||||
|
|
||||||
|
## Установка
|
||||||
|
Активировать автоматический запуск сессии пользователя
|
||||||
```console
|
```console
|
||||||
# Изменить параметр ReadWritePaths=/etc /run /var/lib/systemd/linger
|
# Изменить параметр ReadWritePaths=/etc /run /var/lib/systemd/linger
|
||||||
nano /usr/lib/systemd/system/systemd-logind.service
|
nano /usr/lib/systemd/system/systemd-logind.service
|
||||||
@ -15,9 +17,30 @@ mkdir /var/lib/systemd/linger
|
|||||||
loginctl enable-linger $USER
|
loginctl enable-linger $USER
|
||||||
```
|
```
|
||||||
|
|
||||||
+ Скачать и запустить установщик
|
Скачать и запустить установщик:
|
||||||
```console
|
```console
|
||||||
curl -Lsk https://raw.githubusercontent.com/iiiypuk/vk0nline/master/install.sh | sh
|
curl -Lsk https://raw.githubusercontent.com/iiiypuk/vk0nline/master/install.sh | sh
|
||||||
```
|
```
|
||||||
|
|
||||||
+ Следовать инструкциям установщика
|
Следовать инструкциям установщика.
|
||||||
|
|
||||||
|
## Использование
|
||||||
|
* Скачать исполняемый файл программы
|
||||||
|
* Заполнить `appID` и `userIds` в `config.json`
|
||||||
|
* Запустить программу `vk0nline` и получить `accessToken`
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
TODO: Write development instructions here
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
1. Fork it (<https://github.com/your-github-user/src/fork>)
|
||||||
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
||||||
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
||||||
|
4. Push to the branch (`git push origin my-new-feature`)
|
||||||
|
5. Create a new Pull Request
|
||||||
|
|
||||||
|
## Contributors
|
||||||
|
|
||||||
|
- [Alexander Popov](https://github.com/iiiypuk) - creator and maintainer
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"clientId": 1,
|
"appID": 6954184,
|
||||||
"secureKey": "",
|
"userIds": 69040735,
|
||||||
"serviceKey": "",
|
"secureKey": null,
|
||||||
"accessToken": ""
|
"serviceKey": null,
|
||||||
|
"accessToken": null
|
||||||
}
|
}
|
||||||
|
14
shard.lock
Normal file
14
shard.lock
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
version: 2.0
|
||||||
|
shards:
|
||||||
|
crest:
|
||||||
|
git: https://github.com/mamantoha/crest.git
|
||||||
|
version: 0.27.0
|
||||||
|
|
||||||
|
http-client-digest_auth:
|
||||||
|
git: https://github.com/mamantoha/http-client-digest_auth.git
|
||||||
|
version: 0.6.0
|
||||||
|
|
||||||
|
http_proxy:
|
||||||
|
git: https://github.com/mamantoha/http_proxy.git
|
||||||
|
version: 0.8.0
|
||||||
|
|
17
shard.yml
Normal file
17
shard.yml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
name: vk0nline
|
||||||
|
version: 0.1.0
|
||||||
|
|
||||||
|
authors:
|
||||||
|
- Alexander Popov <iiiypuk@iiiypuk.me>
|
||||||
|
|
||||||
|
targets:
|
||||||
|
src:
|
||||||
|
main: src/src.cr
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
crest:
|
||||||
|
github: mamantoha/crest
|
||||||
|
|
||||||
|
crystal: 1.0.0
|
||||||
|
|
||||||
|
license: MIT
|
2
spec/spec_helper.cr
Normal file
2
spec/spec_helper.cr
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
require "spec"
|
||||||
|
require "../src/src"
|
9
spec/src_spec.cr
Normal file
9
spec/src_spec.cr
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
require "./spec_helper"
|
||||||
|
|
||||||
|
describe Src do
|
||||||
|
# TODO: Write tests
|
||||||
|
|
||||||
|
it "works" do
|
||||||
|
false.should eq(true)
|
||||||
|
end
|
||||||
|
end
|
36
src/vk0nline.cr
Normal file
36
src/vk0nline.cr
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
require "json"
|
||||||
|
require "crest"
|
||||||
|
|
||||||
|
# TODO: Write documentation for `Src`
|
||||||
|
module Src
|
||||||
|
VERSION = "0.1.0"
|
||||||
|
|
||||||
|
json = File.open("config.json") do |file|
|
||||||
|
JSON.parse(file)
|
||||||
|
end
|
||||||
|
|
||||||
|
# TODO: Get accessToken
|
||||||
|
if json["accessToken"] == nil
|
||||||
|
puts "Get accessToken"
|
||||||
|
|
||||||
|
token_url = "https://oauth.vk.com/authorize?client_id=#{json["appID"].as_i}&redirect_uri=vk.com&response_type=token&display=mobile&v=5.131&revoke=1&state=01010&scope=offline"
|
||||||
|
|
||||||
|
puts token_url
|
||||||
|
|
||||||
|
puts "Open this page, and save token to config.json"
|
||||||
|
else
|
||||||
|
# TODO: If return 1 == COMPLETE
|
||||||
|
response = Crest.get(
|
||||||
|
"https://api.vk.com/method/account.setOnline",
|
||||||
|
params: { :voip => "0", :v => "5.131",
|
||||||
|
:access_token => json["accessToken"].as_s,
|
||||||
|
:user_ids => json["userIds"].as_i }
|
||||||
|
)
|
||||||
|
|
||||||
|
status = JSON.parse(response.body)
|
||||||
|
|
||||||
|
if status["response"] == 1
|
||||||
|
puts "Complete!"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user