1
0
Fork 0
forked from bioeb_org/ub4tg

Compare commits

...

20 commits

Author SHA1 Message Date
db317cc226 Merge pull request 'main' (#1) from bioeb_org/ub4tg:main into main
Reviewed-on: #1
2024-12-21 07:52:33 +02:00
Your Name
5ea22e534b set title of running bot user id 2024-12-21 08:45:41 +03:00
Your Name
698462b3d5 fix aiohttp fails to build on python 3.13, YOU SHOULD pip3 install -r requirements.txt 2024-12-21 08:45:19 +03:00
Your Name
70cff5f756 invisible labs should works... yes, again 2024-12-19 23:45:35 +03:00
Your Name
22422e5d0b now really works parse invisible lab infection 2024-12-19 23:19:31 +03:00
Your Name
e00b3ff2bf detection theme changes:
Try parse invisible labs
Full matching theme instead only one index, this prevent some errors
2024-12-19 22:40:09 +03:00
Your Name
68252d6102 theme finder in separated definition 2024-12-19 21:52:26 +03:00
Your Name
722a3d95af fix bioebmass arg 2024-12-19 15:40:53 +03:00
Your Name
e4141534b2 theme fix 2024-12-19 15:09:30 +03:00
Your Name
72c8879989 forgot database column remove 2024-12-19 14:54:34 +03:00
Your Name
c1d8006cca forgot database column remove 2024-12-19 14:53:05 +03:00
Your Name
418e2b7753 аферисты в сетях theme added 2024-12-19 13:03:26 +03:00
Your Name
9833a1a1f2 part 2024-12-19 12:48:18 +03:00
Your Name
c916b9e0ae fuckin' markdown 2024-12-19 12:47:04 +03:00
Your Name
65c8fead14 system requirements for termux 2024-12-19 12:43:51 +03:00
Your Name
c898e6b161 forgotten quote 2024-12-19 11:33:48 +03:00
Your Name
1203049e60 i forgot what tee command exists 2024-12-19 11:31:12 +03:00
Your Name
46add00fbf shlex totally fucked up updater, trying use file as input via pipe 2024-12-19 01:55:50 +03:00
Your Name
c4633d4e02 fix google translate in ukr Termux instruction 2024-12-19 01:45:13 +03:00
Your Name
7ee068367d Merge branch 'S1S13AF7-main' 2024-12-19 01:42:46 +03:00
7 changed files with 121 additions and 88 deletions

View file

@ -16,8 +16,8 @@ Termux:API apk, якщо ви хочете отримувати сповіщен
Для повторного запуску бота (якщо Termux перезавантажено) просто введіть:<br/>
`cd ub4tg; ./run`<br/>
Для швидкого доступу до бота створіть псевдонім:<br/>
`echo "псевдонім ub4tg='cd ~/ub4tg; ./run'" >> .bashrc`<br/>
Для швидкого доступу до бота створіть alias:<br/>
`echo "alias ub4tg='cd ~/ub4tg; ./run'" >> .bashrc`<br/>
потім<br/>
`джерело ~/.bashrc`<br/>
`source ~/.bashrc`<br/>
Тепер ви можете запускати бота у будь-якому каталозі, просто введіть: `ub4tg`

View file

@ -1,5 +1,13 @@
Termux apk here: https://f-droid.org/repo/com.termux_1020.apk
Termux:API apk if you want get notifications about updates of this code: https://f-droid.org/repo/com.termux.api_51.apk
System requirements:
Android 7+ and at least 500 Mb - 5 GB on storage, is official requirements from their wiki https://wiki.termux.com/wiki/FAQ#What_are_system_requirements
Personally I recommend also:
* 1.5 GB in storage is minimum for good perfomance, do not continue, if you have small storage, because it cause "no enough space" error
* arm64 proccessor and 64-bit OS, because on S1S13AF7 smartphone (Redmi 6A) have perfomance issues with 32 bit system, but maybe if install PostmarketOS on this smartphone it will be better because is more native Linux system than java wrapped Termux... Maybe also MIUI firmware issues.
Anyway if you have low-end device, in step 1 when copying oneliner skip part with 'pkg update && pkg upgrade && ', but no any warranty, it can broke bot without upgrade Termux bootstrap packages. Also if your speed downloading updates very slow, press Ctrl+C, and try run `termux-change-repo` and select other region.
0. Optional step: allow permission on storage in Termux before start, after this, step 3-4 can be skipped
1. Run termux and enter this oneliner:

View file

@ -1,7 +1,7 @@
# requirements.txt
loguru
aiohttp==3.9.0b0
aiohttp==3.11.11
Telethon-Mod
#aiosqlite
asyncio

View file

@ -10,6 +10,100 @@ import random
import re
def find_infect_theme(text):
# NOTE: theme hell... any ideas for improvment required
# but not use huge regular expression like|that|fuckin|way|a|aaaa|aaaaaaaa
# because it makes re.findall like mess...
default_bioexpr_theme = r"Прибыль: ([0-9\.\,k]+)"
default_infected_days_theme = r' на ([0-9\ ]+) д.*'
default_pathogen_remaining_theme = r'Осталось: ([0-9\ ]+)'
bio_attack_themes = ( # I guess if too many themes it will be slow, but acceptable, because python slow as is.
# current order in theme:
# ('infected', 'bio_expr', 'infected days', 'pathogen remaining')
# UA theme
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> йобнув.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
r"([0-9\.\,k]+) біо-ресурса",
default_infected_days_theme,
default_pathogen_remaining_theme),
# RU theme
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> подверг.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
default_bioexpr_theme,
default_infected_days_theme,
default_pathogen_remaining_theme),
# EN theme
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> infected.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
r"([0-9\.\,k]+) pcs\.",
r' for ([0-9\ ]+) d.*',
r'Remaining: ([0-9\ ]+)'),
# AZ theme
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> сикди.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
r"верир: ([0-9\.\,k]+)",
default_infected_days_theme,
default_pathogen_remaining_theme),
# "ПК гик" theme
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> насрал.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
r"потеряет: ([0-9\.\,k]+)",
default_infected_days_theme,
default_pathogen_remaining_theme),
# "Новогодняя" theme
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> подверг заморозке.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
default_bioexpr_theme,
default_infected_days_theme,
default_pathogen_remaining_theme),
# "Сексуальная индустрия" theme
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a>.+выебал.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
r"кончила ([0-9\.\,k]+)",
r' ещё ([0-9\ ]+) д.*',
default_pathogen_remaining_theme),
# "Аферисты в сетях" theme
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> атаковал.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
r"приносит: ([0-9\.\,k]+)",
default_infected_days_theme,
default_pathogen_remaining_theme),
# "Квадробер" theme
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a>.+бешенству.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
r"корма: ([0-9\.\,k]+)",
default_infected_days_theme,
default_pathogen_remaining_theme),
# UA theme [via trust]
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> за допомогою довіреності зазнала зараження.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
r"([0-9\.\,k]+) біо-ресурса",
default_infected_days_theme,
default_pathogen_remaining_theme),
# RU theme [via trust]
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> при помощи доверенности подвергла заражению.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
default_bioexpr_theme,
default_infected_days_theme,
default_pathogen_remaining_theme),
# EN theme [via trust]
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> by authorization infected.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
r"([0-9\.\,k]+) pcs\.",
r' for ([0-9\ ]+) d.*',
r'Remaining: ([0-9\ ]+)'),
# idk what is theme [via trust]
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> при помощи анонимуса атаковала.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
r'приносит: ([0-9\.\,k]+)',
default_infected_days_theme,
default_pathogen_remaining_theme),
)
for theme in bio_attack_themes:
trying_theme_index = bio_attack_themes.index(theme)
logger.debug(f'trying theme {trying_theme_index}...')
r, bioexp, days, remaining = re.findall(theme[0], text), re.findall(theme[1], text), re.findall(theme[2], text), re.findall(theme[3], text)
if r and bioexp and days and remaining:
logger.debug(f'found theme {trying_theme_index}')
return r, bio_attack_themes[trying_theme_index]
for theme in bio_attack_themes:
trying_theme_index = bio_attack_themes.index(theme)
logger.debug(f'trying theme {trying_theme_index} [without first lab]...')
r, bioexp, days, remaining = re.findall(theme[0].split('</a>', 1)[1], text), re.findall(theme[1], text), re.findall(theme[2], text), re.findall(theme[3], text)
if r and bioexp and days and remaining:
logger.debug(f'found theme {trying_theme_index}, but invisible first lab it will be replaced to avocado id')
r = [(f'tg://openmessage?user_id={avocado_id}', r[0])]
return r, bio_attack_themes[trying_theme_index]
return r, None
async def eb(client, c, conn, con, d, get_id, my_id, message_q):
@client.on(events.NewMessage(
pattern='.*йобнув.*|.*подверг(ла)?.*|.*infected.*|.*сикди.*|.*насрал.*|.*выебал.*|.*за допомогою довіреності.*|.*by authorization infected.*|.*при помощи анонимуса атаковала.*',
@ -24,82 +118,10 @@ async def eb(client, c, conn, con, d, get_id, my_id, message_q):
logger.debug(f"in chat '{chat_name}'")
states.stats_most_infect_spam_chats[chat_name] += 1
t = m.raw_text
# NOTE: theme hell... any ideas for improvment required
# but not use huge regular expression like|that|fuckin|way|a|aaaa|aaaaaaaa
# because it makes re.findall like mess...
default_bioexpr_theme = r"Прибыль: ([0-9\.\,k]+)"
default_infected_days_theme = r' на ([0-9\ ]+) д.*'
default_pathogen_remaining_theme = r'Осталось: ([0-9\ ]+)'
bio_attack_themes = ( # I guess if too many themes it will be slow, but acceptable, because python slow as is.
# current order in theme:
# ('infected', 'bio_expr', 'infected days', 'pathogen remaining')
# UA theme
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> йобнув.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
r"([0-9\.\,k]+) біо-ресурса",
default_infected_days_theme,
default_pathogen_remaining_theme),
# RU theme
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> подверг.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
default_bioexpr_theme,
default_infected_days_theme,
default_pathogen_remaining_theme),
# EN theme
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> infected.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
r"([0-9\.\,k]+) pcs\.",
r' for ([0-9\ ]+) d.*',
r'Remaining: ([0-9\ ]+)'),
# AZ theme
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> сикди.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
r"верир: ([0-9\.\,k]+)",
default_infected_days_theme,
default_pathogen_remaining_theme),
# "ПК гик" theme
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> насрал.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
r"потеряет: ([0-9\.\,k]+)",
default_infected_days_theme,
default_pathogen_remaining_theme),
# "Новогодняя" theme
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> подверг заморозке.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
default_bioexpr_theme,
default_infected_days_theme,
default_pathogen_remaining_theme),
# "Сексуальная индустрия" theme
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> выебал.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
r"кончила ([0-9\.\,k]+)",
r' ещё ([0-9\ ]+) д.*',
default_pathogen_remaining_theme),
# UA theme [via trust]
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> за допомогою довіреності зазнала зараження.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
r"([0-9\.\,k]+) біо-ресурса",
default_infected_days_theme,
default_pathogen_remaining_theme),
# RU theme [via trust]
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> при помощи доверенности подвергла заражению.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
default_bioexpr_theme,
default_infected_days_theme,
default_pathogen_remaining_theme),
# EN theme [via trust]
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> by authorization infected.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
r"([0-9\.\,k]+) pcs\.",
r' for ([0-9\ ]+) d.*',
r'Remaining: ([0-9\ ]+)'),
# idk what is theme [via trust]
(r'<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">.*</a> при помощи анонимуса атаковала.+<a href="(tg://openmessage\?user_id=\d+|https://t\.me/\w+)">',
r'приносит: ([0-9\.\,k]+)',
default_infected_days_theme,
default_pathogen_remaining_theme),
)
if len(m.entities) > 1:
h = utils.sanitize_parse_mode(
'html').unparse(t, m.entities) # HTML
for theme in bio_attack_themes:
trying_theme_index = bio_attack_themes.index(theme)
logger.debug(f'trying theme {trying_theme_index}...')
r = re.findall(theme[0], h)
if r:
logger.debug(f'found theme {trying_theme_index}')
break
r, bio_attack_theme = find_infect_theme(h)
if r == []:
logger.warning(
'theme not found or lost part of message, showing original message: ' + m.text)
@ -111,12 +133,11 @@ async def eb(client, c, conn, con, d, get_id, my_id, message_q):
u2id = await get_id(u2url)
bio_excludes = [x[0] for x in c.execute(
'select user_id from avocado_exclude').fetchall()]
# print(f'{u1url} [@{u1id}] подверг(ла) {u2url} [@{u2id}]')#показать
when = int(datetime.timestamp(m.date))
days = int(re.findall(bio_attack_themes[trying_theme_index][2], t)[
days = int(re.findall(bio_attack_theme[2], t)[
0].replace(' ', ''))
experience = re.findall(
bio_attack_themes[trying_theme_index][1], t)[0].strip()
bio_attack_theme[1], t)[0].strip()
if ',' in experience:
experience = re.sub(r',', r'.', experience)
if 'k' in experience:
@ -125,7 +146,7 @@ async def eb(client, c, conn, con, d, get_id, my_id, message_q):
else:
exp_int = int(experience)
pathogen_remaining = int(re.findall(
bio_attack_themes[trying_theme_index][3], t)[0])
bio_attack_theme[3], t)[0])
if pathogen_remaining <= states.auto_bioeb_pathogen_threshold and u1id == my_id:
states.auto_bioeb_sleep_interval = states.auto_bioeb_max_interval
logger.warning(
@ -324,6 +345,9 @@ async def eb(client, c, conn, con, d, get_id, my_id, message_q):
arg = int(arg[1])
except:
await event.edit('Argument should be integer from 1 to 10')
else:
arg = None
reply = await client.get_messages(event.peer_id, ids=event.reply_to.reply_to_msg_id)
when = int(datetime.timestamp(event.date))
t = reply.raw_text

View file

@ -1,7 +1,6 @@
from loguru import logger
import os
import asyncio
import shlex
async def git_notifications_update():
@ -14,14 +13,14 @@ async def git_notifications_update():
logger.info('Checking for updates...')
fetching_git = os.system('git fetch')
if fetching_git == 0:
os.system("printf 'For apply tap button Get update and restart bot\nChanges:\n' > upd_info")
commits = os.popen(
"git log --pretty=format:'%h %s%n%b' HEAD..origin/$(git rev-parse --abbrev-ref HEAD)").read()
"git log --pretty=format:'%h %s%n%b' HEAD..origin/$(git rev-parse --abbrev-ref HEAD) | tee upd_info").read()
if len(commits) <= 5:
logger.info('updates not found, nothing to do')
else:
commits = shlex.quote(commits)
os.system(
f"termux-notification -i ub4tgupd --title 'ub4tg: update avalaible!' --content 'For apply tap button Get update and restart bot\nChanges:\n{commits}' --button1 'Get update' --button1-action 'termux-notification-remove ub4tgupd; cd {cwd}; git pull; termux-toast 'ub4tg updated, now restart it for apply update'")
f"cat upd_info | termux-notification -i ub4tgupd --title 'ub4tg: update avalaible!' --button1 'Get update' --button1-action 'termux-notification-remove ub4tgupd'; cd {cwd}; git pull; termux-toast 'ub4tg updated, now restart it for apply update'")
else:
os.system(
"termux-toast '[ub4tg]: failed fetching update, maybe connection error, check console log for more info'")

View file

@ -85,8 +85,8 @@ async def bio_backup_stealing(client, c, conn, default_directory):
else:
profit_int = int(profit)
if not c.execute(f'SELECT user_id FROM avocado WHERE user_id == {user_id}').fetchone() and not c.execute(f'SELECT user_id FROM avocado_exclude WHERE user_id == {user_id}').fetchone():
c.execute("INSERT INTO avocado(user_id,when_int,bio_str,bio_int,expr_int) VALUES (?, ?, ?, ?, ?)",
(int(user_id), int(when), str(profit), int(profit_int), 0))
c.execute("INSERT INTO avocado(user_id,when_int,bio_int,expr_int) VALUES (?, ?, ?, ?)",
(int(user_id), int(when), int(profit_int), 0))
added += 1
logger.debug(f'added {user_id} - {profit_int}')
else:

View file

@ -9,6 +9,7 @@ from loguru import logger
import time
import sys
import os
import asyncio
import re
@ -169,7 +170,8 @@ async def main():
####################################################################
if is_termux:
asyncio.ensure_future(updatenotif.git_notifications_update())
elif os.name == 'posix':
print(f'\33]0;bot {my_id}\a', end='', flush=True)
await victimsbackup.bio_backup_stealing(client, c, conn, default_directory)
if config.db_pymysql: