Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
d31f591f52 | |||
5511a355d4 | |||
99331d966b | |||
2f9c1ad76c | |||
d2517bb3f2 | |||
31aeff8191 | |||
011f888601 | |||
dddaf080a7 | |||
34a3395853 |
BIN
.preview.png
BIN
.preview.png
Binary file not shown.
Before Width: | Height: | Size: 8.4 KiB |
|
@ -1,44 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# Prepating installation
|
|
||||||
mkdir -p /home/$USER/.local/share/emilecok/vk0nline
|
|
||||||
mkdir -p /home/$USER/.config/emilecok/vk0nline
|
|
||||||
|
|
||||||
if [ -x "$(command -v git)" ]; then
|
|
||||||
echo Installing distribution via Git...
|
|
||||||
|
|
||||||
git clone https://github.com/iiiypuk/vk0nline.git --depth 1 /home/$USER/.local/share/emilecok/vk0nline &> /dev/null
|
|
||||||
elif [ -x "$(command -v unzip)" ]; then
|
|
||||||
echo Installing distribution via zip file...
|
|
||||||
|
|
||||||
cd /home/$USER/.local/share/emilecok/vk0nline
|
|
||||||
curl -LsOk https://github.com/iiiypuk/vk0nline/archive/master.zip
|
|
||||||
unzip master.zip
|
|
||||||
mv vk0nline-master vk0nline
|
|
||||||
else
|
|
||||||
echo Git
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd /home/$USER/.local/share/emilecok/vk0nline
|
|
||||||
sed -i "s/USERNAME/$USER/" ./systemd/user/vk0nline.service &> /dev/null
|
|
||||||
chmod 755 ./vk0nline.py
|
|
||||||
cp -p ./config.json.example /home/$USER/.config/emilecok/vk0nline/config.json &> /dev/null
|
|
||||||
|
|
||||||
echo Installing systemd services...
|
|
||||||
mkdir -p /home/$USER/.config/systemd/user
|
|
||||||
|
|
||||||
cd /home/$USER/.config/systemd/user
|
|
||||||
ln -s /home/$USER/.local/share/emilecok/vk0nline/systemd/user/vk0nline.service . &> /dev/null
|
|
||||||
ln -s /home/$USER/.local/share/emilecok/vk0nline/systemd/user/vk0nline.timer . &> /dev/null
|
|
||||||
|
|
||||||
echo Installation complete.
|
|
||||||
echo
|
|
||||||
echo Start script, authorize and save access token
|
|
||||||
echo :: python /home/$USER/.local/share/emilecok/vk0nline/vk0nline.py
|
|
||||||
echo
|
|
||||||
echo Edit configuration file
|
|
||||||
echo :: by /home/$USER/.config/emilecok/vk0nline/config.json
|
|
||||||
echo
|
|
||||||
echo And start \& activate systemd services
|
|
||||||
echo :: systemctl start vk0nline.\{service,timer\} --user
|
|
||||||
echo :: systemctl enable vk0nline.\{service,timer\} --user
|
|
|
@ -1,6 +0,0 @@
|
||||||
language: crystal
|
|
||||||
|
|
||||||
# Uncomment the following if you'd like Travis to run specs and check code formatting
|
|
||||||
# script:
|
|
||||||
# - crystal spec
|
|
||||||
# - crystal tool format --check
|
|
12
HISTORY.md
Normal file
12
HISTORY.md
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
## Legend
|
||||||
|
- 🐛 - Bug
|
||||||
|
- ✔️ - Fixed
|
||||||
|
- ❌ - Removed
|
||||||
|
- ➕ - Added
|
||||||
|
- ℹ️ - Information
|
||||||
|
- ♻️ - Edited
|
||||||
|
|
||||||
|
## 2.0.1 - [16/05/2022]
|
||||||
|
- ➕ - Added colors to output
|
||||||
|
- ➕ - Added help
|
||||||
|
- ➕ - Added `--mkconfig` param to make new config file
|
58
README.md
58
README.md
|
@ -1,35 +1,47 @@
|
||||||
# vk0nline
|
# Будь **ОНЛАЙН** ВКонтакте
|
||||||
Утилита для поддержания статуса __Онлайн__ в социальной сети Vk.com.
|
|
||||||
|
|
||||||
Включает в себя `systemd` юнит.
|
|
||||||
|
|
||||||
![preview](https://raw.githubusercontent.com/iiiypuk/vk0nline/master/.preview.png)
|
|
||||||
|
|
||||||
## Установка
|
## Установка
|
||||||
Активировать автоматический запуск сессии пользователя
|
|
||||||
```bash
|
|
||||||
# Изменить параметр ReadWritePaths=/etc /run /var/lib/systemd/linger
|
|
||||||
nano /usr/lib/systemd/system/systemd-logind.service
|
|
||||||
# Перезапустить сервисы
|
|
||||||
systemctl daemon-reload
|
|
||||||
# Активировать пользователя
|
|
||||||
mkdir /var/lib/systemd/linger
|
|
||||||
loginctl enable-linger $USER
|
|
||||||
|
|
||||||
Подготавливаем рабочую директорию
|
Подготовка рабочей директории:
|
||||||
mkdir -p /home/$USER/.local/share/emilecok/vk0nline/
|
```bash
|
||||||
wget https://github.com/iiiypuk/vk0nline/blob/master/config.json.example -O /home/$USER/.local/share/emilecok/vk0nline/config.json
|
mkdir -p /home/$USER/.local/share/emilecok/vk0nline
|
||||||
wget $BINARY -O /home/$USER/.local/share/emilecok/vk0nline/vk0nline.x86_64-lnx
|
cd /home/$USER/.local/share/emilecok/vk0nline
|
||||||
chmod +x /home/$USER/.local/share/emilecok/vk0nline/vk0nline.x86_64-lnx
|
wget https://github.com/iiiypuk/vk0nline/releases/download/2.0.0/vk0nline-2.0.0.linux-x86_64
|
||||||
|
|
||||||
# Заполняем конфигурационный файл, поля appID и userIds
|
# Заполняем конфигурационный файл, поля appID и userIds
|
||||||
vi /home/$USER/.local/share/emilecok/vk0nline/config.json
|
cp config.json.example config.json
|
||||||
|
vi config.json
|
||||||
|
|
||||||
# Запускаем, получаем accessToken и запускаем ещё раз
|
# Запускаем, получаем accessToken и запускаем ещё раз
|
||||||
/home/$USER/.local/share/emilecok/vk0nline/vk0nline.x86_64-lnx
|
./vk0nline*
|
||||||
```
|
```
|
||||||
|
|
||||||
## Systemd
|
## Systemd
|
||||||
|
Активируем автоматический запуск сессии пользователя:
|
||||||
```bash
|
```bash
|
||||||
...
|
# Изменить параметр ReadWritePaths=/etc /run /var/lib/systemd/linger
|
||||||
|
nano /usr/lib/systemd/system/systemd-logind.service
|
||||||
|
|
||||||
|
# Перезапустить сервисы
|
||||||
|
systemctl daemon-reload
|
||||||
|
|
||||||
|
# Активировать пользователя
|
||||||
|
mkdir /var/lib/systemd/linger
|
||||||
|
loginctl enable-linger $USER
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Правим имя пользователя в сервисе
|
||||||
|
sed -i "s/USERNAME/$USER/" ./systemd/user/vk0nline.service &> /dev/null
|
||||||
|
|
||||||
|
mkdir -p /home/$USER/.config/systemd/user &> /dev/null
|
||||||
|
cd /home/$USER/.config/systemd/user
|
||||||
|
|
||||||
|
ln -s /home/$USER/.local/share/emilecok/vk0nline/systemd/user/vk0nline.service . &> /dev/null
|
||||||
|
ln -s /home/$USER/.local/share/emilecok/vk0nline/systemd/user/vk0nline.timer . &> /dev/null
|
||||||
|
|
||||||
|
# Запуск и активация сервисов
|
||||||
|
systemctl start vk0nline.\{service,timer\} --user
|
||||||
|
systemctl enable vk0nline.\{service,timer\} --user
|
||||||
|
```
|
||||||
|
|
||||||
|
|
12
build.sh
12
build.sh
|
@ -5,4 +5,14 @@ then
|
||||||
mkdir bin
|
mkdir bin
|
||||||
fi
|
fi
|
||||||
|
|
||||||
crystal build --progress --no-debug --release src/vk0nline.cr -o bin/vk0nline.x86_64-lnx
|
ARCH=`uname -m`
|
||||||
|
OS=`uname | tr '[:upper:]' '[:lower:]'`
|
||||||
|
VERSION=`cat shard.yml | grep -m 1 'version: ' | sed -e 's/version: //g'`
|
||||||
|
|
||||||
|
if [ "$1" = "all" ]
|
||||||
|
then
|
||||||
|
echo "..in progress.."
|
||||||
|
else
|
||||||
|
echo "Build $VERSION for `uname` `uname -m`"
|
||||||
|
crystal build --progress --no-debug --release src/vk0nline.cr -o bin/vk0nline-$VERSION.$OS-$ARCH
|
||||||
|
fi
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
version: 2.0
|
version: 2.0
|
||||||
shards:
|
shards:
|
||||||
|
ameba:
|
||||||
|
git: https://github.com/crystal-ameba/ameba.git
|
||||||
|
version: 1.0.0
|
||||||
|
|
||||||
crest:
|
crest:
|
||||||
git: https://github.com/mamantoha/crest.git
|
git: https://github.com/mamantoha/crest.git
|
||||||
version: 0.27.0
|
version: 1.2.1
|
||||||
|
|
||||||
http-client-digest_auth:
|
http-client-digest_auth:
|
||||||
git: https://github.com/mamantoha/http-client-digest_auth.git
|
git: https://github.com/mamantoha/http-client-digest_auth.git
|
||||||
|
@ -10,5 +14,5 @@ shards:
|
||||||
|
|
||||||
http_proxy:
|
http_proxy:
|
||||||
git: https://github.com/mamantoha/http_proxy.git
|
git: https://github.com/mamantoha/http_proxy.git
|
||||||
version: 0.8.0
|
version: 0.9.0
|
||||||
|
|
||||||
|
|
14
shard.yml
14
shard.yml
|
@ -1,17 +1,21 @@
|
||||||
name: vk0nline
|
name: vk0nline
|
||||||
version: 2.0.0
|
version: 2.0.1
|
||||||
|
|
||||||
authors:
|
authors:
|
||||||
- Alexander Popov <iiiypuk@iiiypuk.me>
|
- Alexander Popov <iiiypuk@fastmail.fm>
|
||||||
|
|
||||||
targets:
|
targets:
|
||||||
src:
|
vk0nline:
|
||||||
main: src/src.cr
|
main: src/vk0nline.cr
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
crest:
|
crest:
|
||||||
github: mamantoha/crest
|
github: mamantoha/crest
|
||||||
|
|
||||||
crystal: 1.0.0
|
development_dependencies:
|
||||||
|
ameba:
|
||||||
|
github: crystal-ameba/ameba
|
||||||
|
|
||||||
|
crystal: 1.4.1
|
||||||
|
|
||||||
license: MIT
|
license: MIT
|
||||||
|
|
|
@ -1,24 +1,60 @@
|
||||||
|
require "option_parser"
|
||||||
require "json"
|
require "json"
|
||||||
|
require "colorize"
|
||||||
require "crest"
|
require "crest"
|
||||||
|
|
||||||
|
# program options
|
||||||
|
begin
|
||||||
|
OptionParser.parse do |parser|
|
||||||
|
parser.banner = "Make ONLINE on vk.com\n"
|
||||||
|
|
||||||
|
parser.on "--version", "Show version" do
|
||||||
|
print "vk0nline ".colorize(:green).mode(:bold)
|
||||||
|
puts "2.0.1".colorize(:yellow)
|
||||||
|
|
||||||
|
exit(0)
|
||||||
|
end
|
||||||
|
parser.on "--mkconfig", "Make new empty config" do
|
||||||
|
new_config = {appID: nil, userIds: nil, accessToken: nil}
|
||||||
|
|
||||||
|
File.open("config.json.new", "w") do |f|
|
||||||
|
f.puts new_config.to_json.to_s
|
||||||
|
end
|
||||||
|
|
||||||
|
print "Config saved to "
|
||||||
|
print "config.json.new".colorize(:yellow).mode(:bold)
|
||||||
|
puts " file."
|
||||||
|
|
||||||
|
exit(0)
|
||||||
|
end
|
||||||
|
parser.on "-h", "--help", "Show help" do
|
||||||
|
puts parser
|
||||||
|
|
||||||
|
exit(0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
rescue ex
|
||||||
|
puts ex.message, ""
|
||||||
|
end
|
||||||
|
|
||||||
begin # JSON::ParseException
|
begin # JSON::ParseException
|
||||||
json = File.open("config.json") do |file|
|
json = File.open("config.json") do |file|
|
||||||
JSON.parse(file)
|
JSON.parse(file)
|
||||||
end
|
end
|
||||||
rescue
|
rescue
|
||||||
puts "Parse config.json error"
|
puts "Parse config.json error".colorize(:red)
|
||||||
|
|
||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_access_token(appId : Int32)
|
def get_access_token(app_id : Int32)
|
||||||
puts "Open this page, and save token to config.json\n\n"
|
puts "Open this page, and save token to config.json:".colorize(:yellow)
|
||||||
|
|
||||||
token_url = "https://oauth.vk.com/authorize?client_id="\
|
token_url = "https://oauth.vk.com/authorize?client_id=" \
|
||||||
"#{appId}&redirect_uri=vk.com&response_type=token"\
|
"#{app_id}&redirect_uri=vk.com&response_type=token" \
|
||||||
"&display=mobile&v=5.131&revoke=1&state=01010&scope=offline"
|
"&display=mobile&v=5.131&revoke=1&state=01010&scope=offline"
|
||||||
|
|
||||||
puts token_url
|
puts token_url.colorize(:green).mode(:bold)
|
||||||
end
|
end
|
||||||
|
|
||||||
if json["accessToken"] == nil
|
if json["accessToken"] == nil
|
||||||
|
@ -26,19 +62,19 @@ if json["accessToken"] == nil
|
||||||
else
|
else
|
||||||
response = Crest.get(
|
response = Crest.get(
|
||||||
"https://api.vk.com/method/account.setOnline",
|
"https://api.vk.com/method/account.setOnline",
|
||||||
params: { :voip => "0", :v => "5.131",
|
params: {:voip => "0", :v => "5.131",
|
||||||
:access_token => json["accessToken"].as_s,
|
:access_token => json["accessToken"].as_s,
|
||||||
:user_ids => json["userIds"].as_i }
|
:user_ids => json["userIds"].as_i}
|
||||||
)
|
)
|
||||||
|
|
||||||
status = JSON.parse(response.body)
|
status = JSON.parse(response.body)
|
||||||
|
|
||||||
begin # Missing hash key
|
begin # Missing hash key
|
||||||
if status["error"]
|
if status["error"]
|
||||||
puts status["error"]["error_msg"]
|
puts status["error"]["error_msg"].colorize(:yellow).mode(:bold)
|
||||||
puts "Error code #{status["error"]["error_code"]}"
|
puts "Error code #{status["error"]["error_code"]}".colorize(:red)
|
||||||
|
|
||||||
puts "---"
|
puts "---".colorize(:dark_gray)
|
||||||
|
|
||||||
get_access_token(json["appID"].as_i)
|
get_access_token(json["appID"].as_i)
|
||||||
end
|
end
|
||||||
|
@ -48,7 +84,7 @@ else
|
||||||
|
|
||||||
begin # Status set
|
begin # Status set
|
||||||
if status["response"] == 1
|
if status["response"] == 1
|
||||||
puts "Complete!"
|
puts "Complete!".colorize(:green).mode(:bold)
|
||||||
end
|
end
|
||||||
rescue
|
rescue
|
||||||
# execute if an exception is raised
|
# execute if an exception is raised
|
||||||
|
|
Loading…
Reference in New Issue
Block a user