forked from asrdri/yt-metabot-user-js
-
Notifications
You must be signed in to change notification settings - Fork 4
/
update_bot_accounts
executable file
·55 lines (45 loc) · 1.78 KB
/
update_bot_accounts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/env php
<?php
ob_start();
# mainDB
$st1 = file_get_contents('https://raw.githubusercontent.com/YTObserver/YT-ACC-DB/master/mainDB');
$st1 = preg_replace('/(.+)=(.+?)\s*\[(.+)\].*/', "'$1': {date_rus:'$2', comment: '$3'},", $st1);
# smm
$st2 = file_get_contents('https://raw.githubusercontent.com/YTObserver/YT-ACC-DB/master/additional_list_smm');
$st2 = substr($st2, strpos($st2, "\n"));
$st2 = preg_replace('/(.+)=(.+)\r/', "'$1': {date_rus:'$2'},", $st2);
$st2 = preg_replace('/ #/', "', comment: 'СММ #", $st2);
# political
$st3 = file_get_contents('https://raw.githubusercontent.com/YTObserver/YT-ACC-DB/master/additional_list_political');
$st3 = substr($st3, strpos($st3, "\n"));
$st3 = preg_replace('/(.+)=(.+?)\s*\[(.+)\].*/', "'$1': {date_rus:'$2', comment: '$3'},", $st3);
echo
"/**
* @updated ".date('H:i:s d.m.Y')."
* @source https://github.com/YTObserver/YT-ACC-DB\n */\n\nvar BOT_ACCOUNTS = {
$st1
$st2
$st3
}\n";
file_put_contents('bot_accounts.js', ob_get_clean());
# bump version
$st = file_get_contents($fname = 'manifest.json');
if (preg_match('/("version\D*)([\d\.]+)/', $st, $m))
{
$v = explode('.', $m[2]);
$v[count($v)-1]++;
define('NEW_VERSION', implode('.', $v));
$st = file_get_contents($fname = 'manifest.json');
$st_= preg_replace('/("version\D*)([\d\.])+/s', '${1}'.NEW_VERSION, $st);
if ($st != $st_)
file_put_contents($fname, $st_);
$st = file_get_contents($fname = 'updates.xml');
$st_= preg_replace('/(updatecheck.+version=\D*)([\d\.])+/', '${1}'.NEW_VERSION, $st);
if ($st != $st_)
file_put_contents($fname, $st_);
# repack for chrome store
passthru('./update_extension');
# git commit
passthru('git add metabot.crx updates.xml manifest.json bot_accounts.js; git commit -m "'.NEW_VERSION.' - обновление базы"');
passthru('git push');
}