Skip to content
This repository was archived by the owner on Jun 20, 2024. It is now read-only.

Commit bf2ba44

Browse files
author
Ari Archer
committed
2.0.0 : anon api update
Signed-off-by: Ari Archer <[email protected]>
1 parent 93a5d57 commit bf2ba44

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

awc/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from . import const, exc, util
1313

14-
__version__: typing.Final[str] = "1.3.0"
14+
__version__: typing.Final[str] = "2.0.0"
1515

1616

1717
class Awc:

awc/api.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def applied(awc: Awc) -> bool:
182182
return util.resp_to_bool(awc.get(api="applied").text)
183183

184184

185-
def anon(awc: Awc, content: str) -> requests.Response:
185+
def anon(awc: Awc, content: str) -> str:
186186
"""send message to server anonymously
187187
188188
awc: awc.Awc -- the awc.Awc instance to work on
@@ -195,4 +195,4 @@ def anon(awc: Awc, content: str) -> requests.Response:
195195
data={
196196
"content": util.truncate(content, const.MAX_CONTENT_LEN),
197197
},
198-
)
198+
).text

awc/sql/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ class AnonMsg(SQLTable):
145145

146146
cid: pypika.Column = t.cid # type: ignore
147147
content: pypika.Column = t.content # type: ignore
148+
headers: pypika.Column = t.headers # type: ignore
148149

149150

150151
def sql(query: pypika.queries.QueryBuilder) -> str:

awc/sql/helpers.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,19 @@ def censor_comments(
102102
]
103103

104104

105-
def get_anon_msg(cid: int) -> typing.List[pypika.queries.QueryBuilder]:
105+
def get_anon_msg(ip: str) -> typing.List[pypika.queries.QueryBuilder]:
106106
"""get an anonymous message by id
107107
108-
cid: int -- content id
108+
ip: str -- content id ( ip )
109109
110110
return typing.List[pypika.queries.QueryBuilder] -- the queries"""
111-
return [AnonMsg.select(AnonMsg.cid == cid, AnonMsg.content)] # type: ignore
111+
return [AnonMsg.select(AnonMsg.cid == ip, AnonMsg.content)] # type: ignore
112112

113113

114-
def del_anon_msg(cid: int) -> typing.List[pypika.queries.QueryBuilder]:
114+
def del_anon_msg(ip: str) -> typing.List[pypika.queries.QueryBuilder]:
115115
"""delete an anonymous message by id
116116
117-
cid: int -- content id
117+
ip: str -- content id ( ip )
118118
119119
return typing.List[pypika.queries.QueryBuilder] -- the queries"""
120-
return [delete(AnonMsg.query(AnonMsg.cid == cid))] # type: ignore
120+
return [delete(AnonMsg.query(AnonMsg.cid == ip))] # type: ignore

examples/main.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,15 @@ def main() -> int:
132132
print("whoami api returned", (author := awc.api.whoami(api)))
133133

134134
print(
135-
"anon message with id",
136-
(anon_id := int(awc.api.anon(api, infinput("anonymous message")).text)),
135+
"anon api returned",
136+
awc.api.anon(api, infinput("anonymous message")),
137137
)
138138

139-
print(
140-
"anon msg :",
141-
awc.api.sql(api, awc.sql.multisql(awc.sql.helpers.get_anon_msg(anon_id))),
142-
)
139+
print("anon msgs")
140+
print(awc.api.sql(api, "SELECT * FROM anon;"))
143141

144142
print("deleting the anon msg")
145-
print(awc.api.sql(api, awc.sql.multisql(awc.sql.helpers.del_anon_msg(anon_id))))
143+
print(awc.api.sql(api, "DELETE FROM anon;"))
146144

147145
print("imma ban you wait")
148146
print(awc.api.sql(api, awc.sql.multisql(awc.sql.helpers.ban(author))))

0 commit comments

Comments
 (0)