Skip to content

Sourcery refactored master branch - #1

Open
sourcery-ai[bot] wants to merge 1 commit into
masterfrom
sourcery/master
Open

Sourcery refactored master branch#1
sourcery-ai[bot] wants to merge 1 commit into
masterfrom
sourcery/master

Conversation

@sourcery-ai

@sourcery-ai sourcery-ai Bot commented Dec 15, 2022

Copy link
Copy Markdown

Branch master refactored 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 master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai
sourcery-ai Bot requested a review from xbinner18 December 15, 2022 07:00
Comment thread bot/myteam.py
def create_chat(self, name, about="", rules="", members=[], public=False, join_moderation=False, default_role="member"):
return self.http_session.get(
url="{}/chats/createChat".format(self.api_base_url),
url=f"{self.api_base_url}/chats/createChat",

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function create_chat refactored with the following changes:

Comment thread bot/types.py
Comment on lines -53 to -60
i = 1
row = []
for button in args:
for i, button in enumerate(args, start=1):
row.append(button.to_dic())
if i % self.buttons_in_row == 0:
self.keyboard.append(row)
row = []
i += 1

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function InlineKeyboardMarkup.add refactored with the following changes:

Comment thread bot/types.py
Comment on lines -64 to +62
btn_array = []
for button in args:
btn_array.append(button.to_dic())
btn_array = [button.to_dic() for button in args]

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function InlineKeyboardMarkup.row refactored with the following changes:

Comment thread bot/types.py
Comment on lines -112 to +108
result = {}
for key in self.styles.keys():
result[key] = self.styles[key].to_dic()
result = {key: self.styles[key].to_dic() for key in self.styles.keys()}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Format.to_json refactored with the following changes:

Comment thread example/test_bot.py
Comment on lines -38 to +41
bot.send_text(chat_id=event.data['chat']['chatId'], text="User command: {}".format(event.data['text']))
bot.send_text(
chat_id=event.data['chat']['chatId'],
text=f"User command: {event.data['text']}",
)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_cb refactored with the following changes:

Comment thread example/test_bot.py
Comment on lines -53 to +59
bot.send_text(chat_id=event.data['chat']['chatId'], text="Private user command: {}".format(event.data['text']))
bot.send_text(
chat_id=event.data['chat']['chatId'],
text=f"Private user command: {event.data['text']}",
)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function private_command_cb refactored with the following changes:

Comment thread example/test_bot.py
Comment on lines -75 to +84
bot.send_text(chat_id=event.data['chat']['chatId'], text="Message {} was pinned".format(event.data['msgId']))
bot.send_text(
chat_id=event.data['chat']['chatId'],
text=f"Message {event.data['msgId']} was pinned",
)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function pinned_message_cb refactored with the following changes:

Comment thread example/test_bot.py
Comment on lines -79 to +91
bot.send_text(chat_id=event.data['chat']['chatId'], text="Message {} was unpinned".format(event.data['msgId']))
bot.send_text(
chat_id=event.data['chat']['chatId'],
text=f"Message {event.data['msgId']} was unpinned",
)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function unpinned_message_cb refactored with the following changes:

Comment thread example/test_bot.py
Comment on lines -83 to +98
bot.send_text(chat_id=event.data['chat']['chatId'], text="Message {} was edited".format(event.data['msgId']))
bot.send_text(
chat_id=event.data['chat']['chatId'],
text=f"Message {event.data['msgId']} was edited",
)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function edited_message_cb refactored with the following changes:

Comment thread example/test_bot.py
Comment on lines -87 to +105
bot.send_text(chat_id=event.data['chat']['chatId'], text="Message {} was deleted".format(event.data['msgId']))
bot.send_text(
chat_id=event.data['chat']['chatId'],
text=f"Message {event.data['msgId']} was deleted",
)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function deleted_message_cb refactored with the following changes:

Comment thread example/test_bot.py
Comment on lines -107 to +126
text="Reply to message: {}".format(msg_id),
reply_msg_id=msg_id
text=f"Reply to message: {msg_id}",
reply_msg_id=msg_id,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function reply_to_message_cb refactored with the following changes:

Comment thread bot/bot.py
Comment on lines -81 to +90
name=self.name if self.name is not None else requests.get(url="{}/self/get".format(self.api_base_url),
params={"token": self.token}
).json().get('nick'),
# name=self.name,
name=self.name
if self.name is not None
else requests.get(
url=f"{self.api_base_url}/self/get", params={"token": self.token}
)
.json()
.get('nick'),
version=self.version if self.version is not None else 'base',
uin="" if self.uin is None else self.uin,
library_version=version
library_version=version,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Bot.user_agent refactored with the following changes:

This removes the following comments ( why? ):

# name=self.name,

Comment thread bot/bot.py
Comment on lines -106 to +114
if response:
if "description" in response.json() and response.json()["description"] == 'Invalid token':
raise InvalidToken(response.json())
if (
response
and "description" in response.json()
and response.json()["description"] == 'Invalid token'
):
raise InvalidToken(response.json())

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Bot._start_polling refactored with the following changes:

Comment thread bot/bot.py
Comment on lines -162 to +174
url="{}/events/get".format(self.api_base_url),
url=f"{self.api_base_url}/events/get",
params={
"token": self.token,
"pollTime": poll_time_s,
"lastEventId": last_event_id
"lastEventId": last_event_id,
},
timeout=poll_time_s + self.timeout_s
timeout=poll_time_s + self.timeout_s,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Bot.events_get refactored with the following changes:

Comment thread bot/bot.py
Comment on lines -178 to +186
url="{}/self/get".format(self.api_base_url),
params={
"token": self.token
},
timeout=self.timeout_s
url=f"{self.api_base_url}/self/get",
params={"token": self.token},
timeout=self.timeout_s,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Bot.self_get refactored with the following changes:

Comment thread bot/bot.py
Comment on lines -283 to +287
url="{}/messages/sendText".format(self.api_base_url),
url=f"{self.api_base_url}/messages/sendText",

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Bot.send_text refactored with the following changes:

Comment thread bot/bot.py
Comment on lines -444 to +433
url="{}/chats/getPendingUsers".format(self.api_base_url),
params={
"token": self.token,
"chatId": chat_id
},
timeout=self.timeout_s
url=f"{self.api_base_url}/chats/getPendingUsers",
params={"token": self.token, "chatId": chat_id},
timeout=self.timeout_s,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Bot.get_chat_pending_users refactored with the following changes:

Comment thread bot/bot.py
Comment on lines -454 to +445
url="{}/chats/blockUser".format(self.api_base_url),
url=f"{self.api_base_url}/chats/blockUser",
params={
"token": self.token,
"chatId": chat_id,
"userId": user_id,
"delLastMessages": str(del_last_messages).lower()
"delLastMessages": str(del_last_messages).lower(),
},
timeout=self.timeout_s
timeout=self.timeout_s,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Bot.chat_block_user refactored with the following changes:

Comment thread bot/bot.py
Comment on lines -466 to +452
url="{}/chats/unblockUser".format(self.api_base_url),
params={
"token": self.token,
"chatId": chat_id,
"userId": user_id
},
timeout=self.timeout_s
url=f"{self.api_base_url}/chats/unblockUser",
params={"token": self.token, "chatId": chat_id, "userId": user_id},
timeout=self.timeout_s,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Bot.chat_unblock_user refactored with the following changes:

Comment thread bot/bot.py
Comment on lines -477 to +465
url="{}/chats/resolvePending".format(self.api_base_url),
url=f"{self.api_base_url}/chats/resolvePending",
params={
"token": self.token,
"chatId": chat_id,
"approve": str(approve).lower(),
"userId": user_id,
"everyone": str(everyone).lower()
"everyone": str(everyone).lower(),
},
timeout=self.timeout_s
timeout=self.timeout_s,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Bot.chat_resolve_pending refactored with the following changes:

Comment thread bot/bot.py
Comment on lines -490 to +472
url="{}/chats/setTitle".format(self.api_base_url),
params={
"token": self.token,
"chatId": chat_id,
"title": title
},
timeout=self.timeout_s
url=f"{self.api_base_url}/chats/setTitle",
params={"token": self.token, "chatId": chat_id, "title": title},
timeout=self.timeout_s,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Bot.set_chat_title refactored with the following changes:

Comment thread bot/bot.py
Comment on lines -501 to +479
url="{}/chats/setAbout".format(self.api_base_url),
params={
"token": self.token,
"chatId": chat_id,
"about": about
},
timeout=self.timeout_s
url=f"{self.api_base_url}/chats/setAbout",
params={"token": self.token, "chatId": chat_id, "about": about},
timeout=self.timeout_s,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Bot.set_chat_about refactored with the following changes:

Comment thread bot/bot.py
Comment on lines -512 to +486
url="{}/chats/setRules".format(self.api_base_url),
params={
"token": self.token,
"chatId": chat_id,
"rules": rules
},
timeout=self.timeout_s
url=f"{self.api_base_url}/chats/setRules",
params={"token": self.token, "chatId": chat_id, "rules": rules},
timeout=self.timeout_s,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Bot.set_chat_rules refactored with the following changes:

Comment thread bot/bot.py
Comment on lines -523 to +493
url="{}/files/getInfo".format(self.api_base_url),
params={
"token": self.token,
"fileId": file_id
},
timeout=self.timeout_s
url=f"{self.api_base_url}/files/getInfo",
params={"token": self.token, "fileId": file_id},
timeout=self.timeout_s,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Bot.get_file_info refactored with the following changes:

Comment thread bot/bot.py
Comment on lines -533 to +500
url="{}/chats/pinMessage".format(self.api_base_url),
params={
"token": self.token,
"chatId": chat_id,
"msgId": msg_id
},
timeout=self.timeout_s
url=f"{self.api_base_url}/chats/pinMessage",
params={"token": self.token, "chatId": chat_id, "msgId": msg_id},
timeout=self.timeout_s,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Bot.pin_message refactored with the following changes:

Comment thread bot/bot.py
Comment on lines -544 to +507
url="{}/chats/unpinMessage".format(self.api_base_url),
params={
"token": self.token,
"chatId": chat_id,
"msgId": msg_id
},
timeout=self.timeout_s
url=f"{self.api_base_url}/chats/unpinMessage",
params={"token": self.token, "chatId": chat_id, "msgId": msg_id},
timeout=self.timeout_s,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Bot.unpin_message refactored with the following changes:

Comment thread example/test_bot.py
Comment on lines -53 to +59
bot.send_text(chat_id=event.data['chat']['chatId'], text="Private user command: {}".format(event.data['text']))
bot.send_text(
chat_id=event.data['chat']['chatId'],
text=f"Private user command: {event.data['text']}",
)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function private_command_cb refactored with the following changes:

Comment thread example/test_bot.py
Comment on lines -75 to +84
bot.send_text(chat_id=event.data['chat']['chatId'], text="Message {} was pinned".format(event.data['msgId']))
bot.send_text(
chat_id=event.data['chat']['chatId'],
text=f"Message {event.data['msgId']} was pinned",
)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function pinned_message_cb refactored with the following changes:

Comment thread example/test_bot.py
Comment on lines -79 to +91
bot.send_text(chat_id=event.data['chat']['chatId'], text="Message {} was unpinned".format(event.data['msgId']))
bot.send_text(
chat_id=event.data['chat']['chatId'],
text=f"Message {event.data['msgId']} was unpinned",
)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function unpinned_message_cb refactored with the following changes:

Comment thread example/test_bot.py
Comment on lines -83 to +98
bot.send_text(chat_id=event.data['chat']['chatId'], text="Message {} was edited".format(event.data['msgId']))
bot.send_text(
chat_id=event.data['chat']['chatId'],
text=f"Message {event.data['msgId']} was edited",
)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function edited_message_cb refactored with the following changes:

Comment thread example/test_bot.py
Comment on lines -87 to +105
bot.send_text(chat_id=event.data['chat']['chatId'], text="Message {} was deleted".format(event.data['msgId']))
bot.send_text(
chat_id=event.data['chat']['chatId'],
text=f"Message {event.data['msgId']} was deleted",
)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function deleted_message_cb refactored with the following changes:

Comment thread example/test_bot.py
Comment on lines -107 to +126
text="Reply to message: {}".format(msg_id),
reply_msg_id=msg_id
text=f"Reply to message: {msg_id}",
reply_msg_id=msg_id,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function reply_to_message_cb refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants