-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from markelovstyle/master
Some changes
- Loading branch information
Showing
8 changed files
with
44 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,20 @@ | ||
from vkbottle import Message | ||
from vkbottle.api import UserApi | ||
|
||
api = UserApi.get_current() | ||
|
||
async def edit(ans: Message, text: str): | ||
data = ans.__dict__ | ||
keys_to_pop = [ | ||
"message", | ||
"flags", | ||
"timestamp", | ||
"text", | ||
"random_id", | ||
"id", | ||
"conversation_message_id", | ||
"from_id", | ||
"date", | ||
"out", | ||
"read_state", | ||
"ref", | ||
"ref_source", | ||
"important", | ||
"reply_message", | ||
"fwd_messages", | ||
"action", | ||
] | ||
for key in keys_to_pop: | ||
data.pop(key, None) | ||
if ans.geo is not None: | ||
lat, long = ans.geo.coordinates.latitude, ans.geo.coordinates.longitude | ||
data["lat"] = lat | ||
data["long"] = long | ||
data.pop("geo", None) | ||
await ans.api.messages.edit( | ||
message=text, | ||
attachment=",".join(data.pop("attachments")), | ||
**data, | ||
keep_forward_messages=True | ||
|
||
def get_params(obj: dict) -> dict: | ||
return { | ||
k: v for k, v in obj.items() | ||
if v is not None and k != "params" | ||
} | ||
|
||
|
||
async def edit( | ||
peer_id: int, msg_id: int, | ||
text: str, **params | ||
): | ||
locals().update(params) | ||
return await api.messages.edit( | ||
**get_params(locals()) | ||
) |