Skip to content

Commit 4fd00a2

Browse files
committed
Move monkeypatch down
1 parent c554c4d commit 4fd00a2

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

plugins/map_plugin.py

+15-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
1-
import PIL.ImageDraw
2-
3-
def textsize(self: PIL.ImageDraw.ImageDraw, *args, **kwargs):
4-
x, y, w, h = self.textbbox((0, 0), *args, **kwargs)
5-
return w, h
6-
7-
# Monkeypatch fix for https://github.com/flopp/py-staticmaps/issues/39
8-
PIL.ImageDraw.ImageDraw.textsize = textsize
9-
101
import io
112
import math
123
import random
134
import re
145

6+
import PIL.ImageDraw
157
import s2sphere
168
import staticmaps
179
from nio import AsyncClient, UploadResponse
@@ -20,6 +12,15 @@ def textsize(self: PIL.ImageDraw.ImageDraw, *args, **kwargs):
2012
from plugins.base_plugin import BasePlugin
2113

2214

15+
def textsize(self: PIL.ImageDraw.ImageDraw, *args, **kwargs):
16+
x, y, w, h = self.textbbox((0, 0), *args, **kwargs)
17+
return w, h
18+
19+
20+
# Monkeypatch fix for https://github.com/flopp/py-staticmaps/issues/39
21+
PIL.ImageDraw.ImageDraw.textsize = textsize
22+
23+
2324
class TextLabel(staticmaps.Object):
2425
def __init__(self, latlng: s2sphere.LatLng, text: str, fontSize: int = 12) -> None:
2526
staticmaps.Object.__init__(self)
@@ -218,7 +219,11 @@ async def send_room_image(
218219
await client.room_send(
219220
room_id=room_id,
220221
message_type="m.room.message",
221-
content={"msgtype": "m.image", "url": upload_response.content_uri, "body": "image.png"},
222+
content={
223+
"msgtype": "m.image",
224+
"url": upload_response.content_uri,
225+
"body": "image.png",
226+
},
222227
)
223228

224229

0 commit comments

Comments
 (0)