notification for avalaible updates for termux
This commit is contained in:
parent
373f317754
commit
1e25e4f9c5
2 changed files with 26 additions and 2 deletions
23
src/updatenotif.py
Normal file
23
src/updatenotif.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
from loguru import logger
|
||||
import os
|
||||
import asyncio
|
||||
|
||||
|
||||
async def git_notifications_update():
|
||||
logger.info('module for checking updates started')
|
||||
while True:
|
||||
termux_api = os.system('termux-api-start')
|
||||
if termux_api == 0:
|
||||
logger.info('Checking for updates...')
|
||||
fetching_git = os.system('git fetch')
|
||||
if fetching_git == 0:
|
||||
commits = os.popen('git log --oneline HEAD..origin/$(git rev-parse --abbrev-ref HEAD)').read()
|
||||
cwd = os.getcwd()
|
||||
os.system(f"termux-notification --title 'ub4tg: update avalaible!' --content 'For apply tap button Get update and restart bot\nChanges:\n{commits}' --button1 'Get update' --button1-action 'cd {cwd}; git pull'")
|
||||
else:
|
||||
os.system("termux-toast '[ub4tg]: failed fetching update, maybe connection error'")
|
||||
else:
|
||||
logger.warning('For getting updates via notifications, you should:')
|
||||
logger.warning('pkg install termux-api')
|
||||
logger.warning('download the apk: https://f-droid.org/repo/com.termux.api_51.apk')
|
||||
await asyncio.sleep(6 * 60 * 60)
|
5
ubot.py
5
ubot.py
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# https://docs-python.ru/packages/telegram-klient-telethon-python/ <-info
|
||||
from src import avocmine, victimsbackup
|
||||
from src import avocmine, victimsbackup, updatenotif
|
||||
import asyncio
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
|
@ -50,7 +50,6 @@ default_directory = ''
|
|||
default_config_file_path = 'config.json'
|
||||
treat_as_true = ('true', '1', 't', 'y', 'yes', 'yeah', 'yup', 'certainly', 'uh-huh')
|
||||
if is_termux:
|
||||
# TODO: make notifications about update for termux
|
||||
default_directory = '/sdcard/ub4tg'
|
||||
os.system(f'mkdir -p {default_directory}')
|
||||
default_config_file_path = f'{default_directory}/config.json'
|
||||
|
@ -254,6 +253,8 @@ async def main():
|
|||
return response
|
||||
|
||||
####################################################################
|
||||
if is_termux:
|
||||
asyncio.ensure_future(updatenotif.git_notifications_update())
|
||||
await victimsbackup.bio_backup_stealing(client, c, conn, default_directory)
|
||||
|
||||
@client.on(events.NewMessage(pattern='.*йобнув.*|.*подверг(ла)?.*|.*infected.*|.*сикди.*|.*насрал.*|.*выебал.*|.*за допомогою довіреності.*|.*by authorization infected.*|.*при помощи анонимуса атаковала.*'))
|
||||
|
|
Loading…
Reference in a new issue