Browse Source

Flake8 Compliancy

Nicolas "Colin" Neht 4 months ago
parent
commit
9cd192917f

+ 4
- 0
.flake8 View File

@@ -0,0 +1,4 @@
1
+[flake8]
2
+exclude = .git,__pycache__
3
+max_line_length = 100
4
+count = True

+ 10
- 10
pyrobot/__init__.py View File

@@ -7,8 +7,8 @@ import dotenv
7 7
 
8 8
 # We need logging this early for our Version Check
9 9
 logging.basicConfig(
10
-    format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s',
11
-    level = logging.INFO)
10
+    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
11
+    level=logging.INFO)
12 12
 logging.getLogger("pyrogram").setLevel(logging.WARN)
13 13
 LOGS = logging.getLogger(__name__)
14 14
 
@@ -19,10 +19,10 @@ if sys.version_info[0] < 3 or sys.version_info[1] < 6:
19 19
 
20 20
 # Now for the rest
21 21
 __version__ = '0.2.0'
22
-__author__  = 'Nicolas "Colin" Neht'
23
-__source__      = 'https://git.colinshark.de/PyroBot/PyroBot'
24
-__copyright__   = 'Copyright (c) 2019 ' + __author__
25
-__copystring__  = f"PyroBot v{__version__} | {__copyright__}"
22
+__author__ = 'Nicolas "Colin" Neht'
23
+__source__ = 'https://git.colinshark.de/PyroBot/PyroBot'
24
+__copyright__ = 'Copyright (c) 2019 ' + __author__
25
+__copystring__ = f"PyroBot v{__version__} | {__copyright__}"
26 26
 
27 27
 # Load our .env file
28 28
 dotenv.load_dotenv()
@@ -43,10 +43,10 @@ else:
43 43
 
44 44
 # Prepare the bot
45 45
 BOT = Client(
46
-    session_name = "PyroBot",
47
-    api_id = API_ID,
48
-    api_hash = API_HASH,
49
-    app_version = f"PyroBot \U0001f525\U0001F916 v{__version__}"
46
+    session_name="PyroBot",
47
+    api_id=API_ID,
48
+    api_hash=API_HASH,
49
+    app_version=f"PyroBot \U0001f525\U0001F916 v{__version__}"
50 50
 )
51 51
 
52 52
 # Global Variables

+ 3
- 3
pyrobot/helpers.py View File

@@ -1,8 +1,8 @@
1 1
 from pyrobot import BOT, LOGGER, LOGGER_GROUP
2 2
 
3
+
3 4
 def LogMessage(logmsg):
4 5
     if LOGGER:
5 6
         BOT.send_message(
6
-            chat_id = LOGGER_GROUP,
7
-            text = logmsg
8
-        )
7
+            chat_id=LOGGER_GROUP,
8
+            text=logmsg)

+ 2
- 1
pyrobot/interval.py View File

@@ -3,6 +3,7 @@
3 3
 
4 4
 import re
5 5
 
6
+
6 7
 class IntervalHelper(object):
7 8
 
8 9
     class IntervalError(Exception):
@@ -38,4 +39,4 @@ class IntervalHelper(object):
38 39
         elif unit == 'w':
39 40
             return [num*60*60*24*7, num, "week" if num == 1 else "weeks"]
40 41
 
41
-    interval = property(lambda self: self._interval)
42
+    interval = property(lambda self: self._interval)

+ 3
- 0
pyrobot/modules/1start.py View File

@@ -10,14 +10,17 @@ REPO = ("Userbot is available on Gitea:\n"
10 10
 
11 11
 # -- Constants End -- #
12 12
 
13
+
13 14
 @BOT.on_message(Filters.command("alive", ".") & Filters.me)
14 15
 def _alive(bot: BOT, message: Message):
15 16
     message.edit(ALIVE)
16 17
 
18
+
17 19
 @BOT.on_message(Filters.command("help", ".") & Filters.me)
18 20
 def _help(bot: BOT, message: Message):
19 21
     message.edit(HELP)
20 22
 
23
+
21 24
 @BOT.on_message(Filters.command("repo", ".") & Filters.me)
22 25
 def _repo(bot: BOT, message: Message):
23 26
     message.edit(REPO)

+ 2
- 0
pyrobot/modules/__init__.py View File

@@ -1,5 +1,6 @@
1 1
 from pyrobot import LOGS
2 2
 
3
+
3 4
 def __list_all_modules():
4 5
     from os.path import dirname, basename, isfile
5 6
     import glob
@@ -12,6 +13,7 @@ def __list_all_modules():
12 13
     ]
13 14
     return all_modules
14 15
 
16
+
15 17
 ALL_MODULES = sorted(__list_all_modules())
16 18
 LOGS.info("Modules to load:\n{}\n".format(", ".join(ALL_MODULES)))
17 19
 __all__ = ALL_MODULES + ["ALL_MODULES"]

+ 40
- 29
pyrobot/modules/admin.py View File

@@ -1,6 +1,6 @@
1 1
 from time import sleep, time
2 2
 
3
-from pyrobot import BOT, LOGS
3
+from pyrobot import BOT
4 4
 from pyrogram import Filters, Message
5 5
 from pyrogram.errors import UserAdminInvalid
6 6
 
@@ -46,6 +46,7 @@ KICKED_LOG = (
46 46
 
47 47
 # -- Helpers -- #
48 48
 
49
+
49 50
 def ReplyCheck(message):
50 51
     if not message.reply_to_message:
51 52
         message.edit(f"`{message.command[0]}` needs to be a reply.")
@@ -58,16 +59,17 @@ def ReplyCheck(message):
58 59
     else:
59 60
         return True
60 61
 
62
+
61 63
 def AdminCheck(message):
62 64
     SELF = BOT.get_chat_member(
63 65
         chat_id=message.chat.id,
64 66
         user_id=message.from_user.id)
65
-    
67
+
66 68
     if SELF.status not in ranks:
67 69
         message.edit("__I'm not Admin!__")
68 70
         sleep(2)
69 71
         message.delete()
70
-    
72
+
71 73
     else:
72 74
         if SELF.status is not admin:
73 75
             return True
@@ -76,31 +78,36 @@ def AdminCheck(message):
76 78
         else:
77 79
             message.edit("__No permissions to restrict Members__")
78 80
 
81
+
79 82
 def RestrictFailed(message):
80 83
     message.edit(f"I can't {message.command[0]} this user.")
81 84
     sleep(2)
82 85
     message.delete()
83 86
 
87
+
84 88
 def Timer(message: Message):
85 89
     if len(message.command) > 1:
86 90
         secs = IntervalHelper(message.command[1])
87 91
         return int(str(time()).split(".")[0]) + secs.to_secs()[0]
88 92
     else:
89 93
         return 0
94
+
95
+
90 96
 def TimerString(message: Message):
91 97
     secs = IntervalHelper(message.command[1])
92 98
     return f"{secs.to_secs()[1]} {secs.to_secs()[2]}"
93 99
 
94 100
 # -- Helpers End -- #
95 101
 
102
+
96 103
 @BOT.on_message(Filters.command("ban", "?") & Filters.me)
97 104
 def ban_hammer(bot: BOT, message: Message):
98 105
     if ReplyCheck(message) is True and AdminCheck(message) is True:
99 106
         try:
100 107
             BOT.kick_chat_member(
101
-                chat_id = message.chat.id,
102
-                user_id = message.reply_to_message.from_user.id,
103
-                until_date = Timer(message)
108
+                chat_id=message.chat.id,
109
+                user_id=message.reply_to_message.from_user.id,
110
+                until_date=Timer(message)
104 111
             )
105 112
             if len(message.command) > 1:
106 113
                 message.edit(BANNED_TIME.format(
@@ -114,13 +121,14 @@ def ban_hammer(bot: BOT, message: Message):
114 121
         except UserAdminInvalid:
115 122
             RestrictFailed(message)
116 123
 
124
+
117 125
 @BOT.on_message(Filters.command("unban", "?") & Filters.me)
118 126
 def unban(bot: BOT, message: Message):
119 127
     if ReplyCheck(message) is True and AdminCheck(message) is True:
120 128
         try:
121 129
             BOT.unban_chat_member(
122
-                chat_id = message.chat.id,
123
-                user_id = message.reply_to_message.from_user.id
130
+                chat_id=message.chat.id,
131
+                user_id=message.reply_to_message.from_user.id
124 132
             )
125 133
             message.edit(UNBANNED.format(message))
126 134
             LogMessage(UNBANNED_LOG.format(
@@ -129,15 +137,16 @@ def unban(bot: BOT, message: Message):
129 137
         except UserAdminInvalid:
130 138
             message.edit("I can't unban this user")
131 139
 
140
+
132 141
 @BOT.on_message(Filters.command("mute", "?") & Filters.me)
133 142
 def mute_hammer(bot: BOT, message: Message):
134 143
     if ReplyCheck(message) is True and AdminCheck(message) is True:
135 144
         try:
136 145
             BOT.restrict_chat_member(
137
-                chat_id = message.chat.id,
138
-                user_id = message.reply_to_message.from_user.id,
139
-                until_date = Timer(message),
140
-                can_send_messages = False,
146
+                chat_id=message.chat.id,
147
+                user_id=message.reply_to_message.from_user.id,
148
+                until_date=Timer(message),
149
+                can_send_messages=False,
141 150
             )
142 151
             if len(message.command) > 1:
143 152
                 message.edit(MUTED_TIME.format(
@@ -151,22 +160,23 @@ def mute_hammer(bot: BOT, message: Message):
151 160
         except UserAdminInvalid:
152 161
             RestrictFailed(message)
153 162
 
163
+
154 164
 @BOT.on_message(Filters.command("unmute", "?") & Filters.me)
155 165
 def unmute(bot: BOT, message: Message):
156 166
     if ReplyCheck(message) is True and AdminCheck(message) is True:
157 167
         try:
158 168
             BOT.restrict_chat_member(
159
-                chat_id = message.chat.id,
160
-                user_id = message.reply_to_message.from_user.id,
161
-                until_date = 0,
162
-                can_send_messages = True,
163
-                can_send_media_messages = True,
164
-                can_send_other_messages = True,
165
-                can_add_web_page_previews = True,
166
-                can_send_polls = True,
167
-                can_change_info = True,
168
-                can_invite_users = True,
169
-                can_pin_messages = True
169
+                chat_id=message.chat.id,
170
+                user_id=message.reply_to_message.from_user.id,
171
+                until_date=0,
172
+                can_send_messages=True,
173
+                can_send_media_messages=True,
174
+                can_send_other_messages=True,
175
+                can_add_web_page_previews=True,
176
+                can_send_polls=True,
177
+                can_change_info=True,
178
+                can_invite_users=True,
179
+                can_pin_messages=True
170 180
             )
171 181
             message.edit(UNMUTED.format(message))
172 182
             LogMessage(UNMUTED_LOG.format(
@@ -175,17 +185,18 @@ def unmute(bot: BOT, message: Message):
175 185
         except UserAdminInvalid:
176 186
             RestrictFailed(message)
177 187
 
178
-@BOT.on_message(Filters.command("kick", "?")  & Filters.me)
188
+
189
+@BOT.on_message(Filters.command("kick", "?") & Filters.me)
179 190
 def kick_user(bot: BOT, message: Message):
180 191
     if ReplyCheck(message) is True and AdminCheck(message) is True:
181 192
         try:
182 193
             BOT.kick_chat_member(
183
-                chat_id = message.chat.id,
184
-                user_id = message.reply_to_message.from_user.id,
185
-                until_date = 0)
194
+                chat_id=message.chat.id,
195
+                user_id=message.reply_to_message.from_user.id,
196
+                until_date=0)
186 197
             BOT.unban_chat_member(
187
-                chat_id = message.chat.id,
188
-                user_id = message.reply_to_message.from_user.id)
198
+                chat_id=message.chat.id,
199
+                user_id=message.reply_to_message.from_user.id)
189 200
             message.edit(KICKED.format(message))
190 201
             LogMessage(KICKED_LOG.format(
191 202
                 message,

+ 7
- 6
pyrobot/modules/cloudconvert.py View File

@@ -12,9 +12,10 @@ CC_Convert = (
12 12
 
13 13
 ccapi = cloudconvert.Api(CC_API)
14 14
 
15
+
15 16
 @BOT.on_message(Filters.command("conv", "!") & Filters.me)
16 17
 def cc_gif(bot: BOT, message: Message):
17
-    try: # delete if file still exists
18
+    try:  # delete if file still exists
18 19
         os.remove("animation.mp4")
19 20
         os.remove("animation.1.mp4")
20 21
     except FileNotFoundError:
@@ -41,19 +42,19 @@ def cc_gif(bot: BOT, message: Message):
41 42
     except cloudconvert.exceptions.APIError as e:
42 43
         message.edit(
43 44
             f"Error: {e}\n{conv_url}",
44
-            disable_web_page_preview = True)
45
+            disable_web_page_preview=True)
45 46
         return
46 47
 
47 48
     message.edit("`Uploading . . .`")
48 49
 
49 50
     try:
50 51
         BOT.send_animation(
51
-            chat_id = message.chat.id,
52
-            animation = "animation.mp4")
52
+            chat_id=message.chat.id,
53
+            animation="animation.mp4")
53 54
     except errors.FileIdInvalid:
54 55
         BOT.send_animation(
55
-            chat_id = message.chat.id,
56
-            animation = "animation.1.mp4")
56
+            chat_id=message.chat.id,
57
+            animation="animation.1.mp4")
57 58
     message.delete()
58 59
     try:
59 60
         os.remove("animation.mp4")

+ 16
- 13
pyrobot/modules/evaluation.py View File

@@ -2,21 +2,20 @@ import os
2 2
 from time import sleep
3 3
 
4 4
 from pyrogram import Filters, Message
5
-from pyrogram.api import functions, types
6 5
 
7
-from pyrobot import BOT, LOGS
6
+from pyrobot import BOT
8 7
 
9 8
 from ..helpers import LogMessage
10 9
 
11 10
 # -- Constants -- #
12 11
 
13
-RUNNING     = "**Expression:**\n```{}```\n\n**Running...**"
14
-ERROR       = "**Expression:**\n```{}```\n\n**Error:**\n```{}```"
15
-SUCCESS     = "**Expression:**\n```{}```\n\n**Success** | `None`"
16
-RESULT      = "**Expression:**\n```{}```\n\n**Result:**\n```{}```"
12
+RUNNING = "**Expression:**\n```{}```\n\n**Running...**"
13
+ERROR = "**Expression:**\n```{}```\n\n**Error:**\n```{}```"
14
+SUCCESS = "**Expression:**\n```{}```\n\n**Success** | `None`"
15
+RESULT = "**Expression:**\n```{}```\n\n**Result:**\n```{}```"
17 16
 RESULT_FILE = "**Expression:**\n```{}```\n\n**Result:**\nView `output.txt` below ⤵"
18 17
 
19
-ERROR_LOG   = (
18
+ERROR_LOG = (
20 19
     "**Evaluation Query**\n"
21 20
     "```{}```\n"
22 21
     "erred in chat \"[{}](t.me/c/{}/{})\" with error\n"
@@ -27,7 +26,7 @@ SUCCESS_LOG = (
27 26
     "```{}```\n"
28 27
     "succeeded in \"[{}](t.me/c/{}/{})\"")
29 28
 
30
-RESULT_LOG  = (
29
+RESULT_LOG = (
31 30
     "Evaluation Query\n"
32 31
     "```{}```\n"
33 32
     "executed in chat \"[{}](t.me/c/{}/{})\".")
@@ -35,6 +34,7 @@ RESULT_LOG  = (
35 34
 # -- Constants End -- #
36 35
 # -- Helpers -- #
37 36
 
37
+
38 38
 def ReplyCheck(message: Message):
39 39
     reply_id = None
40 40
 
@@ -46,19 +46,21 @@ def ReplyCheck(message: Message):
46 46
 
47 47
     return reply_id
48 48
 
49
+
49 50
 def SendLong(message: Message, cmdstr: str, result):
50
-    with open("output.txt", 'w+', encoding = 'utf8') as f:
51
+    with open("output.txt", 'w+', encoding='utf8') as f:
51 52
         f.write(str(result))
52 53
     BOT.send_document(
53
-        chat_id = message.chat.id,
54
-        document = "output.txt",
55
-        caption = "`Output too long, sent as file.`",
56
-        reply_to_message_id = ReplyCheck(message)
54
+        chat_id=message.chat.id,
55
+        document="output.txt",
56
+        caption="`Output too long, sent as file.`",
57
+        reply_to_message_id=ReplyCheck(message)
57 58
     )
58 59
     os.remove("output.txt")
59 60
 
60 61
 # -- Helpers End -- #
61 62
 
63
+
62 64
 @BOT.on_message(Filters.command("eval", ".") & Filters.me)
63 65
 def evaluation(bot: BOT, message: Message):
64 66
     try:
@@ -107,6 +109,7 @@ def evaluation(bot: BOT, message: Message):
107 109
                 str(message.chat.id).replace("-100", ""),
108 110
                 str(expr.message_id)))
109 111
 
112
+
110 113
 @BOT.on_message(Filters.command("exec", ".") & Filters.me)
111 114
 def execution(bot: BOT, message: Message):
112 115
     try:

+ 12
- 10
pyrobot/modules/get_info.py View File

@@ -1,5 +1,4 @@
1 1
 from time import sleep
2
-from html import escape, unescape
3 2
 
4 3
 from pyrogram import Filters, Message
5 4
 from pyrobot import BOT
@@ -32,6 +31,7 @@ MEMBER_INFO = (
32 31
 
33 32
 # -- Constants End -- #
34 33
 
34
+
35 35
 @BOT.on_message(Filters.command("admins", "!") & Filters.me)
36 36
 def get_admins(bot: BOT, message: Message):
37 37
     if message.chat.type == 'private':
@@ -41,17 +41,17 @@ def get_admins(bot: BOT, message: Message):
41 41
 
42 42
     else:
43 43
         all_admins = BOT.iter_chat_members(
44
-            chat_id = message.chat.id,
45
-            filter = 'administrators')
44
+            chat_id=message.chat.id,
45
+            filter='administrators')
46 46
         creator = None
47 47
         admins = []
48 48
 
49 49
         for admin in all_admins:
50
-            if admin.status is 'creator':
50
+            if admin.status == 'creator':
51 51
                 creator = admin
52
-            elif admin.status is 'administrator':
52
+            elif admin.status == 'administrator':
53 53
                 admins.append(admin)
54
-        sorted_admins = sorted(admins, key = lambda usid: usid.user.id)
54
+        sorted_admins = sorted(admins, key=lambda usid: usid.user.id)
55 55
 
56 56
         AdminList = ADMINTITLE.format(message.chat.title)
57 57
 
@@ -89,16 +89,17 @@ def get_admins(bot: BOT, message: Message):
89 89
         message.edit(AdminList)
90 90
         LogMessage(AdminList)
91 91
 
92
+
92 93
 @BOT.on_message(Filters.command("members", "!") & Filters.me)
93 94
 def get_members(bot: BOT, message: Message):
94
-    if message.chat.type is 'private':
95
+    if message.chat.type == 'private':
95 96
         message.delete()
96 97
 
97 98
     else:
98
-        total   = 0
99
-        admins  = 0
99
+        total = 0
100
+        admins = 0
100 101
         members = 0
101
-        bots    = 0
102
+        bots = 0
102 103
         deleted = 0
103 104
 
104 105
         for member in BOT.iter_chat_members(message.chat.id):
@@ -124,6 +125,7 @@ def get_members(bot: BOT, message: Message):
124 125
         message.edit(member_count_text)
125 126
         LogMessage(member_count_text)
126 127
 
128
+
127 129
 @BOT.on_message(Filters.command("id", ".") & Filters.me)
128 130
 def get_file(bot: BOT, message: Message):
129 131
     file_id = None

+ 15
- 12
pyrobot/modules/memes.py View File

@@ -1,4 +1,4 @@
1
-import requests, re
1
+import requests
2 2
 from time import sleep
3 3
 
4 4
 from pyrobot import BOT
@@ -6,6 +6,7 @@ from pyrogram import Filters, Message
6 6
 
7 7
 # -- Helpers -- #
8 8
 
9
+
9 10
 def ReplyCheck(message: Message):
10 11
     reply_id = None
11 12
 
@@ -19,27 +20,29 @@ def ReplyCheck(message: Message):
19 20
 
20 21
 # -- Helpers End -- #
21 22
 
23
+
22 24
 @BOT.on_message(Filters.command(["🐶", "🐕", "🐩", "dog"], "") & Filters.me)
23 25
 def send_dog(bot: BOT, message: Message):
24 26
     doggo = requests.get('https://random.dog/woof.json?filter=webm,mp4').json()
25 27
     BOT.send_photo(
26
-        chat_id = message.chat.id,
27
-        photo = doggo['url'],
28
-        caption = "doggo",
29
-        reply_to_message_id = ReplyCheck(message)
28
+        chat_id=message.chat.id,
29
+        photo=doggo['url'],
30
+        caption="doggo",
31
+        reply_to_message_id=ReplyCheck(message)
30 32
     )
31 33
     if message.from_user.is_self:
32 34
         message.delete()
33 35
 
36
+
34 37
 @BOT.on_message(Filters.command("mock", ".") & Filters.me)
35 38
 def mock_people(bot: BOT, message: Message):
36 39
     cmd = message.command
37 40
 
38 41
     if len(cmd) > 1:
39 42
         mock_text = " ".join(cmd[1:])
40
-    elif message.reply_to_message and len(cmd) is 1:
43
+    elif message.reply_to_message and len(cmd) == 1:
41 44
         mock_text = message.reply_to_message.text
42
-    elif not message.reply_to_message and len(cmd) is 1:
45
+    elif not message.reply_to_message and len(cmd) == 1:
43 46
         message.edit("I need something to mock")
44 47
         sleep(2)
45 48
         message.delete()
@@ -50,8 +53,8 @@ def mock_people(bot: BOT, message: Message):
50 53
         mock_text)
51 54
     message.delete()
52 55
     BOT.send_inline_bot_result(
53
-        chat_id = message.chat.id,
54
-        query_id = mock_results.query_id,
55
-        result_id = mock_results.results[0].id,
56
-        reply_to_message_id = ReplyCheck(message),
57
-        hide_via = True)
56
+        chat_id=message.chat.id,
57
+        query_id=mock_results.query_id,
58
+        result_id=mock_results.results[0].id,
59
+        reply_to_message_id=ReplyCheck(message),
60
+        hide_via=True)

+ 2
- 2
pyrobot/modules/misc.py View File

@@ -1,7 +1,7 @@
1 1
 from datetime import datetime
2 2
 
3 3
 from pyrogram import Filters, Message
4
-from pyrobot import BOT, LOGS, START_TIME
4
+from pyrobot import BOT, START_TIME
5 5
 
6 6
 # -- Constants -- #
7 7
 
@@ -10,7 +10,7 @@ UPTIME = "Current Uptime\n{}"
10 10
 # -- Constants End -- #
11 11
 
12 12
 # Edit the sent message to display the current uptime.
13
-@BOT.on_message(Filters.command(["up","uptime"], ".") & Filters.me)
13
+@BOT.on_message(Filters.command(["up", "uptime"], ".") & Filters.me)
14 14
 def uptime(bot: BOT, message: Message):
15 15
     now = datetime.now()
16 16
     uptime = now - START_TIME

+ 25
- 25
pyrobot/modules/purge.py View File

@@ -1,13 +1,12 @@
1 1
 from pyrogram import Filters, Message
2 2
 from pyrobot import BOT
3 3
 
4
-from ..helpers import LogMessage
5
-
6 4
 # -- Helpers -- #
7 5
 
6
+
8 7
 def GetOwnMessages(message):
9 8
     all_msgs = BOT.get_history(
10
-        chat_id = message.chat.id)
9
+        chat_id=message.chat.id)
11 10
 
12 11
     to_delete = []
13 12
     for msg in all_msgs:
@@ -25,6 +24,7 @@ def GetOwnMessages(message):
25 24
 
26 25
 # -- Helpers End -- #
27 26
 
27
+
28 28
 @BOT.on_message(Filters.command("purgeall", "?") & Filters.me)
29 29
 def purge_all(bot: BOT, message: Message):
30 30
 
@@ -34,28 +34,28 @@ def purge_all(bot: BOT, message: Message):
34 34
 
35 35
         if message.reply_to_message:
36 36
             all_msg = BOT.get_history(
37
-                chat_id = message.chat.id,
38
-                limit = n,
39
-                offset_id = message.reply_to_message.message_id,
40
-                reverse = True)
37
+                chat_id=message.chat.id,
38
+                limit=n,
39
+                offset_id=message.reply_to_message.message_id,
40
+                reverse=True)
41 41
 
42 42
         else:
43 43
             all_msg = BOT.get_history(
44
-                chat_id = message.chat.id,
45
-                limit = n + 1)
44
+                chat_id=message.chat.id,
45
+                limit=n + 1)
46 46
     # Otherwise do this instead
47 47
     else:
48 48
         if not message.reply_to_message:
49 49
             return
50
-        
50
+
51 51
         all_msg = BOT.get_history(
52
-            chat_id = message.chat.id,
53
-            offset_id = message.reply_to_message.message_id)
54
-        
52
+            chat_id=message.chat.id,
53
+            offset_id=message.reply_to_message.message_id)
54
+
55 55
     # finally delete
56 56
     BOT.delete_messages(
57
-        chat_id = message.chat.id,
58
-        message_ids = [x.message_id for x in all_msg.messages])
57
+        chat_id=message.chat.id,
58
+        message_ids=[x.message_id for x in all_msg.messages])
59 59
 
60 60
 
61 61
 @BOT.on_message(Filters.command("purgeme", "?") & Filters.me)
@@ -67,23 +67,23 @@ def purge_me(bot: BOT, message: Message):
67 67
 
68 68
         if message.reply_to_message:
69 69
             all_msg = BOT.get_history(
70
-                chat_id = message.chat.id,
71
-                limit = n,
72
-                offset_id = message.reply_to_message.message_id,
73
-                reverse = True)
70
+                chat_id=message.chat.id,
71
+                limit=n,
72
+                offset_id=message.reply_to_message.message_id,
73
+                reverse=True)
74 74
 
75 75
         else:
76 76
             all_msg = BOT.get_history(
77
-                chat_id = message.chat.id,
78
-                limit = n + 1)
77
+                chat_id=message.chat.id,
78
+                limit=n + 1)
79 79
     # Otherwise do this instead
80 80
     else:
81 81
         if not message.reply_to_message:
82 82
             return
83 83
 
84 84
         all_msg = BOT.get_history(
85
-            chat_id = message.chat.id,
86
-            offset_id = message.reply_to_message.message_id)
85
+            chat_id=message.chat.id,
86
+            offset_id=message.reply_to_message.message_id)
87 87
     # Check if messages are from self
88 88
     to_delete = []
89 89
     for msg in all_msg.messages:
@@ -92,5 +92,5 @@ def purge_me(bot: BOT, message: Message):
92 92
 
93 93
     # finally delete
94 94
     BOT.delete_messages(
95
-        chat_id = message.chat.id,
96
-        message_ids = to_delete)
95
+        chat_id=message.chat.id,
96
+        message_ids=to_delete)

+ 6
- 6
pyrobot/modules/steam.py View File

@@ -27,6 +27,7 @@ ACC_MSG = (
27 27
 
28 28
 # -- Constants End -- #
29 29
 
30
+
30 31
 @BOT.on_message(Filters.command("acc", "?") & Filters.me)
31 32
 def steam_accgen(bot: BOT, message: Message):
32 33
     if ACCGEN_API is None or "":
@@ -36,13 +37,12 @@ def steam_accgen(bot: BOT, message: Message):
36 37
         message.delete()
37 38
         return
38 39
     acc = requests.get(API).json()
39
-    # Uncomment if you want to save to console output
40
-    # LOGS.info(acc)
40
+
41 41
     message.edit(
42 42
         ACC_MSG.format(
43
-            login = acc['login'],
44
-            password = acc['password'],
45
-            steamid = acc['steamid']
43
+            login=acc['login'],
44
+            password=acc['password'],
45
+            steamid=acc['steamid']
46 46
         ),
47
-        disable_web_page_preview = True
47
+        disable_web_page_preview=True
48 48
     )

+ 32
- 26
pyrobot/modules/whois.py View File

@@ -1,4 +1,3 @@
1
-from time import sleep, strftime
2 1
 from datetime import datetime
3 2
 
4 3
 from pyrogram import Filters, Message, User
@@ -36,8 +35,10 @@ WHOIS_PIC = (
36 35
     "Bio:\n{bio}")
37 36
 
38 37
 # -- Constants End -- #
38
+
39 39
 # -- Helpers -- #
40 40
 
41
+
41 42
 def ReplyCheck(message: Message):
42 43
     reply_id = None
43 44
 
@@ -49,6 +50,7 @@ def ReplyCheck(message: Message):
49 50
 
50 51
     return reply_id
51 52
 
53
+
52 54
 def LastOnline(user: User):
53 55
     if user.status.recently:
54 56
         return "Recently"
@@ -63,28 +65,32 @@ def LastOnline(user: User):
63 65
     elif user.status.offline:
64 66
         return datetime.fromtimestamp(user.status.date).strftime("%a, %d %b %Y, %H:%M:%S")
65 67
 
68
+
66 69
 def GetCommon(get_user):
67 70
     common = BOT.send(
68 71
         functions.messages.GetCommonChats(
69
-            user_id = BOT.resolve_peer(get_user),
70
-            max_id = 0,
71
-            limit = 0))
72
+            user_id=BOT.resolve_peer(get_user),
73
+            max_id=0,
74
+            limit=0))
72 75
     return common
73 76
 
77
+
74 78
 def FullName(user: User):
75 79
     return user.first_name + " " + user.last_name if user.last_name else user.first_name
76 80
 
81
+
77 82
 def ProfilePicUpdate(user_pic):
78 83
     return datetime.fromtimestamp(user_pic.photos[0].date).strftime("%d.%m.%Y, %H:%M:%S")
79 84
 
80 85
 # -- Helpers End -- #
81 86
 
87
+
82 88
 @BOT.on_message(Filters.command("whois", ".") & Filters.me)
83 89
 def who_is(bot: BOT, message: Message):
84 90
     cmd = message.command
85
-    if not message.reply_to_message and len(cmd) is 1:
91
+    if not message.reply_to_message and len(cmd) == 1:
86 92
         get_user = message.from_user.id
87
-    elif message.reply_to_message and len(cmd) is 1:
93
+    elif message.reply_to_message and len(cmd) == 1:
88 94
         get_user = message.reply_to_message.from_user.id
89 95
     elif len(cmd) > 1:
90 96
         get_user = cmd[1]
@@ -100,29 +106,29 @@ def who_is(bot: BOT, message: Message):
100 106
     if not user.photo:
101 107
         message.edit(
102 108
             WHOIS.format(
103
-                full_name = FullName(user),
104
-                user_id = user.id,
105
-                first_name = user.first_name,
106
-                last_name = user.last_name if user.last_name else "",
107
-                username = user.username if user.username else "",
108
-                last_online = LastOnline(user),
109
-                common_groups = len(common.chats),
110
-                bio = desc if desc else "`No bio set up.`"),
111
-            disable_web_page_preview = True)
109
+                full_name=FullName(user),
110
+                user_id=user.id,
111
+                first_name=user.first_name,
112
+                last_name=user.last_name if user.last_name else "",
113
+                username=user.username if user.username else "",
114
+                last_online=LastOnline(user),
115
+                common_groups=len(common.chats),
116
+                bio=desc if desc else "`No bio set up.`"),
117
+            disable_web_page_preview=True)
112 118
     elif user.photo:
113 119
         BOT.send_photo(
114 120
             message.chat.id,
115 121
             user_pic.photos[0].sizes[-1].file_id,
116 122
             WHOIS_PIC.format(
117
-                full_name = FullName(user),
118
-                user_id = user.id,
119
-                first_name = user.first_name,
120
-                last_name = user.last_name if user.last_name else "",
121
-                username = user.username if user.username else "",
122
-                last_online = LastOnline(user),
123
-                profile_pics = user_pic.total_count,
124
-                common_groups = len(common.chats),
125
-                bio = desc if desc else "`No bio set up.`",
126
-                profile_pic_update = ProfilePicUpdate(user_pic)),
127
-            reply_to_message_id = ReplyCheck(message))
123
+                full_name=FullName(user),
124
+                user_id=user.id,
125
+                first_name=user.first_name,
126
+                last_name=user.last_name if user.last_name else "",
127
+                username=user.username if user.username else "",
128
+                last_online=LastOnline(user),
129
+                profile_pics=user_pic.total_count,
130
+                common_groups=len(common.chats),
131
+                bio=desc if desc else "`No bio set up.`",
132
+                profile_pic_update=ProfilePicUpdate(user_pic)),
133
+            reply_to_message_id=ReplyCheck(message))
128 134
         message.delete()

+ 9
- 6
pyrobot/modules/www.py View File

@@ -26,11 +26,12 @@ NearestDC = (
26 26
 
27 27
 # -- Helpers -- #
28 28
 
29
+
29 30
 def SpeedConvert(size):
30 31
     power = 2**10
31 32
     zero = 0
32 33
     units = {
33
-        0 : '',
34
+        0: '',
34 35
         1: 'Kbit/s',
35 36
         2: 'Mbit/s',
36 37
         3: 'Gbit/s',
@@ -70,14 +71,15 @@ def speed_test(bot: BOT, message: Message):
70 71
     results = spd.results.dict()
71 72
 
72 73
     SpeedMsg = SpeedTest.format(
73
-        start = results['timestamp'],
74
-        ping = results['ping'],
75
-        download = SpeedConvert(results['download']),
76
-        upload = SpeedConvert(results['upload']),
77
-        isp = results['client']['isp'])
74
+        start=results['timestamp'],
75
+        ping=results['ping'],
76
+        download=SpeedConvert(results['download']),
77
+        upload=SpeedConvert(results['upload']),
78
+        isp=results['client']['isp'])
78 79
     message.edit(SpeedMsg)
79 80
     LogMessage(SpeedMsg)
80 81
 
82
+
81 83
 @BOT.on_message(Filters.command("dc", ".") & Filters.me)
82 84
 def neardc(bot: BOT, message: Message):
83 85
     dc = BOT.send(
@@ -88,6 +90,7 @@ def neardc(bot: BOT, message: Message):
88 90
             dc.nearest_dc,
89 91
             dc.this_dc))
90 92
 
93
+
91 94
 @BOT.on_message(Filters.command("ping", ".") & Filters.me)
92 95
 def pingme(bot: BOT, message: Message):
93 96
     start = datetime.now()

Loading…
Cancel
Save