-
Notifications
You must be signed in to change notification settings - Fork 0
Sourcery refactored main branch #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
PasswordUtils.py
Outdated
| password = ''.join(random.choice(letters)+random.choice(symbols) for i in range(8)) | ||
| password = ''.join( | ||
| random.choice(letters) + random.choice(symbols) for _ in range(8) | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function PasswordUtils.passwordgen refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore)
PerevodLimitsX.py
Outdated
| ''' - [Ник перевода] [Сколько переводить] - Перевод лимитов''' | ||
| args = utils.get_args_split_by(message, " ") | ||
| async with self.client.conversation("@mine_evo_bot") as conv: | ||
| await conv.send_message("б") | ||
| res = await conv.get_response() | ||
| pattern = "<b>Баланс:</b> (.*?)\n" | ||
| match = re.search(pattern, res.text,re.DOTALL) | ||
| if match: | ||
| balance = match.group(1) | ||
| balance = match.group(1) | ||
| await conv.send_message(f"Перевести {args[0]} {balance}") | ||
| res = await conv.get_response() | ||
| if "недостаточно денег" in res.text: | ||
| await utils.answer(message,"⚠️ Откройте конверт! Я не смог выяснить лимит игрока из-за бага майнево!") | ||
| return | ||
| pattern = "\n(.*?)$" | ||
| match = re.search(pattern, res.message, re.DOTALL) | ||
| if match: | ||
| sum = match.group(1).replace("$","") | ||
| ''' - [Ник перевода] [Сколько переводить] - Перевод лимитов''' | ||
| args = utils.get_args_split_by(message, " ") | ||
| async with self.client.conversation("@mine_evo_bot") as conv: | ||
| await conv.send_message("б") | ||
| res = await conv.get_response() | ||
| pattern = "<b>Баланс:</b> (.*?)\n" | ||
| match = re.search(pattern, res.text,re.DOTALL) | ||
| if match: | ||
| balance = match.group(1) | ||
| balance = match.group(1) | ||
| await conv.send_message(f"Перевести {args[0]} {balance}") | ||
| res = await conv.get_response() | ||
| if "недостаточно денег" in res.text: | ||
| await utils.answer(message,"⚠️ Откройте конверт! Я не смог выяснить лимит игрока из-за бага майнево!") | ||
| return | ||
| pattern = "\n(.*?)$" | ||
| if match := re.search(pattern, res.message, re.DOTALL): | ||
| sum = match.group(1).replace("$","") | ||
|
|
||
| conv.cancel() | ||
| ost = 0 | ||
| self.set("full",args[1]) | ||
| await utils.answer(message,"💖 Я начал переводить!") | ||
| for i in range(int(args[1])+1): | ||
| self._db.get(__name__,"ost",0) | ||
| await self.client.send_message("@mine_evo_bot",f"Перевести {args[0]} {sum}") | ||
| await asyncio.sleep(self.config["time_perevod"]) | ||
| ost += 1 | ||
| self.set("ost",ost) | ||
| await utils.answer(message,"💸 Я всё перевёл") | ||
| await self.client.send_message(self._backup_channel,f"🎉 <b>Я перевел все лимиты игроку:</b> <code>{args[0]}</code> <b>В количстве:</b> <code>{args[1]}</code>") | ||
| conv.cancel() | ||
| ost = 0 | ||
| self.set("full",args[1]) | ||
| await utils.answer(message,"💖 Я начал переводить!") | ||
| for _ in range(int(args[1])+1): | ||
| self._db.get(__name__,"ost",0) | ||
| await self.client.send_message("@mine_evo_bot",f"Перевести {args[0]} {sum}") | ||
| await asyncio.sleep(self.config["time_perevod"]) | ||
| ost += 1 | ||
| self.set("ost",ost) | ||
| await utils.answer(message,"💸 Я всё перевёл") | ||
| await self.client.send_message(self._backup_channel,f"🎉 <b>Я перевел все лимиты игроку:</b> <code>{args[0]}</code> <b>В количстве:</b> <code>{args[1]}</code>") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function PerevodLimitsX.perevodx refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression) - Replace unused for index with underscore (
for-index-underscore)
| elif isinstance(peer, PeerChat) or isinstance(peer, PeerChannel): | ||
| elif isinstance(peer, (PeerChat, PeerChannel)): | ||
| added = self.strings("added").format( | ||
| message.chat_id, | ||
| entity.title | ||
| ) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function PinMoreChats.pinchat refactored with the following changes:
- Merge isinstance calls (
merge-isinstance)
| if isinstance(peer, PeerUser): | ||
| name = entity.first_name | ||
| elif isinstance(peer, PeerChat): | ||
| name = entity.title | ||
| elif isinstance(peer, PeerChannel): | ||
| name = entity.title | ||
| else: | ||
| name = entity.title | ||
| name = entity.first_name if isinstance(peer, PeerUser) else entity.title | ||
| except Exception: | ||
| pass | ||
| messages = await self.client.get_messages(chat_id, limit=1) | ||
| max_message_id = messages[0].id | ||
| chats += f"<a href=tg://privatepost?channel={chat}&post={max_message_id}>{name}</a>\n" | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function PinMoreChats.listpinchats refactored with the following changes:
- Merge duplicate blocks in conditional (
merge-duplicate-blocks) - Replace if statement with if expression (
assign-if-exp)
SpyEVO.py
Outdated
| converts = self.get("converts",0) | ||
| r_converts = self.get("r_converts",0) | ||
| case = self.get("case",0) | ||
| r_case = self.get("r_case",0) | ||
| mif = self.get("mif",0) | ||
| crystal = self.get("crystal",0) | ||
| plasma = self.get("plasma",0) | ||
| zv = self.get("zv",0) | ||
| scrap = self.get("scrap",0) | ||
| medals = self.get("medals",0) | ||
|
|
||
| if message.chat_id == 5522271758 and message.text == "✉ Ты нашел(ла) конверт.": | ||
| converts += 1 | ||
| self.set("converts",converts) | ||
| if message.chat_id == 5522271758 and message.text == "🧧 Ты нашел(ла) редкий конверт.": | ||
| r_converts +=1 | ||
| self.set("r_converts",converts) | ||
| if message.chat_id == 5522271758 and message.text == "📦 Ты нашел(ла) Кейс!": | ||
| case += 1 | ||
| self.set("case",case) | ||
| if message.chat_id == 5522271758 and message.text == "🗳 Ты нашел(ла) Редкий Кейс!": | ||
| r_case += 1 | ||
| self.set("r_case",r_case) | ||
| if message.chat_id == 5522271758 and message.raw_text == "🕋 Ты нашел(ла) Мифический Кейс!": | ||
| mif += 1 | ||
| self.set("mif",mif) | ||
| if message.chat_id == 5522271758 and message.raw_text == "💎 Ты нашел(ла) Кристальный Кейс!": | ||
| crystal += 1 | ||
| self.set("crystal",crystal) | ||
| if message.chat_id == 5522271758 and "🎆 Ты нашел(ла) 1 плазму" in message.text: | ||
| plasma += 1 | ||
| self.set("plasma",plasma) | ||
| if message.chat_id == 5522271758 and "💫" in message.text: | ||
| zv += 1 | ||
| self.set("zv",zv) | ||
| if message.chat_id == 5522271758 and "🎆 Ты нашел(ла) 2 плазмы" in message.text: | ||
| plasma += 2 | ||
| self.set("plasma",plasma) | ||
| if message.chat_id == 5522271758 and "Медаль" in message.text: | ||
| pattern = "Медаль +(.*?)</b>" | ||
| match = re.search(pattern, message.text, re.DOTALL) | ||
| if match: | ||
| medali = int(match.group(1)) | ||
| medals += medali | ||
| self.set("medals",medals) | ||
| if message.chat_id == 5522271758 and "Скрап" in message.text: | ||
| pattern = "Скрап +(.*?)</b>" | ||
| match = re.search(pattern, message.text, re.DOTALL) | ||
| if match: | ||
| scrapi = int(match.group(1)) | ||
| scrap += scrapi | ||
| self.set("scrap",scrap) | ||
| converts = self.get("converts",0) | ||
| r_converts = self.get("r_converts",0) | ||
| case = self.get("case",0) | ||
| r_case = self.get("r_case",0) | ||
| mif = self.get("mif",0) | ||
| crystal = self.get("crystal",0) | ||
| plasma = self.get("plasma",0) | ||
| zv = self.get("zv",0) | ||
| scrap = self.get("scrap",0) | ||
| medals = self.get("medals",0) | ||
|
|
||
| if message.chat_id == 5522271758 and message.text == "✉ Ты нашел(ла) конверт.": | ||
| converts += 1 | ||
| self.set("converts",converts) | ||
| if message.chat_id == 5522271758 and message.text == "🧧 Ты нашел(ла) редкий конверт.": | ||
| r_converts +=1 | ||
| self.set("r_converts",converts) | ||
| if message.chat_id == 5522271758 and message.text == "📦 Ты нашел(ла) Кейс!": | ||
| case += 1 | ||
| self.set("case",case) | ||
| if message.chat_id == 5522271758 and message.text == "🗳 Ты нашел(ла) Редкий Кейс!": | ||
| r_case += 1 | ||
| self.set("r_case",r_case) | ||
| if message.chat_id == 5522271758 and message.raw_text == "🕋 Ты нашел(ла) Мифический Кейс!": | ||
| mif += 1 | ||
| self.set("mif",mif) | ||
| if message.chat_id == 5522271758 and message.raw_text == "💎 Ты нашел(ла) Кристальный Кейс!": | ||
| crystal += 1 | ||
| self.set("crystal",crystal) | ||
| if message.chat_id == 5522271758 and "🎆 Ты нашел(ла) 1 плазму" in message.text: | ||
| plasma += 1 | ||
| self.set("plasma",plasma) | ||
| if message.chat_id == 5522271758 and "💫" in message.text: | ||
| zv += 1 | ||
| self.set("zv",zv) | ||
| if message.chat_id == 5522271758 and "🎆 Ты нашел(ла) 2 плазмы" in message.text: | ||
| plasma += 2 | ||
| self.set("plasma",plasma) | ||
| if message.chat_id == 5522271758 and "Медаль" in message.text: | ||
| pattern = "Медаль +(.*?)</b>" | ||
| if match := re.search(pattern, message.text, re.DOTALL): | ||
| medali = int(match.group(1)) | ||
| medals += medali | ||
| self.set("medals",medals) | ||
| if message.chat_id == 5522271758 and "Скрап" in message.text: | ||
| pattern = "Скрап +(.*?)</b>" | ||
| if match := re.search(pattern, message.text, re.DOTALL): | ||
| scrapi = int(match.group(1)) | ||
| scrap += scrapi | ||
| self.set("scrap",scrap) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function SpyEVO.watcher refactored with the following changes:
- Use named expression to simplify assignment and conditional [×2] (
use-named-expression)
| self._chats.append(message.chat_id) | ||
| added = True | ||
| elif message.chat_id in self._chats: | ||
| else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Autoreader.autoread refactored with the following changes:
- Remove redundant conditional (
remove-redundant-if)
autoreader.py
Outdated
|
|
||
| if str(args).startswith("-100"): | ||
| value = int(str(args)[4:]) | ||
|
|
||
| elif args > 2**64 - 1 or args < 0: | ||
| await utils.answer(message,"Неверный айди!") | ||
| else: | ||
| await self.client.send_read_acknowledge(int(args),clear_mentions=True) | ||
| await self.client.send_read_acknowledge(args, clear_mentions=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Autoreader.read refactored with the following changes:
- Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast)
filters.py
Outdated
|
|
||
| elif filter_txt == "capitalize": | ||
| try: | ||
| await message.edit(message.text.capitalize()) | ||
| except Exception: | ||
| pass | ||
| elif filter_txt == "off": | ||
| pass # Ну а чо делать | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function TextFilters.watcher refactored with the following changes:
- Remove empty elif clause (
remove-pass-elif)
This removes the following comments ( why? ):
# Ну а чо делать
sendmsg.py
Outdated
| message.message = " ".join(args.split()[1:]) | ||
| try: | ||
| if error == False: | ||
| if not error: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function SendMSGA.SendMSG refactored with the following changes:
- Simplify comparison to boolean [×2] (
simplify-boolean-comparison)
Branch
mainrefactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
mainbranch, then run:Help us improve this pull request!