fixed bug
This commit is contained in:
@@ -4,8 +4,10 @@
|
||||
<!-- - [x] ~~Discord bot /bk_help command~~ -->
|
||||
<!-- - [x] ~~Scrape the data~~ -->
|
||||
<!-- - [x] ~~Put it in a JSON~~ -->
|
||||
<!-- - [x] ~~Multithread so it can run both Discord and Reddit bot!!!~~ -->
|
||||
<!-- - [x] ~~Multithread so it can run both Discord and Reddit bot!!!~~ -->¨
|
||||
- [ ] Security that only allows bk mods to run these commands
|
||||
- [ ] Allow updating the data autonomously and via manual commands.
|
||||
- [ ] 30-minute schedule
|
||||
- [ ] Manually add posts
|
||||
- [ ] via `u/[bot] add`
|
||||
<!-- - [x] ~~via `/bk_week_add [url]`~~ -->
|
||||
|
||||
+1
-1
@@ -159,7 +159,7 @@ pub async fn bk_week_add(
|
||||
|
||||
if let Some(bk_week) = reddit_data.get(BK_WEEK) {
|
||||
let a = approve.unwrap_or_else(|| false);
|
||||
let r = websocket::send_cmd_json("add_post_url", json!([&url, a])).await.unwrap();
|
||||
let r = websocket::send_cmd_json("add_post_url", json!([&url, a, true])).await.unwrap();
|
||||
|
||||
if !r["value"].as_bool().unwrap() {
|
||||
send_msg(
|
||||
|
||||
@@ -22,7 +22,6 @@ use tokio::sync::Mutex;
|
||||
use serde_json;
|
||||
|
||||
|
||||
// TODO: /bk_week_adds sets as added by bot instead of human
|
||||
// TODO: bot command permissions
|
||||
// TODO: bk_mod verification system
|
||||
|
||||
|
||||
+5
-4
@@ -105,7 +105,7 @@ async def from_url(bot: botPy.Bot, url: str) -> tuple[bool, models.Submission]:
|
||||
return False, None
|
||||
|
||||
|
||||
def get_post_details(post: models.Submission) -> data.PostData:
|
||||
def get_post_details(post: models.Submission, added_by_h: bool = False) -> data.PostData:
|
||||
media = has_media(post)
|
||||
|
||||
return data.PostData(
|
||||
@@ -115,16 +115,17 @@ def get_post_details(post: models.Submission) -> data.PostData:
|
||||
int(post.created_utc),
|
||||
media[1],
|
||||
media[3],
|
||||
added_by_bot = True,
|
||||
added_by_bot = not added_by_h,
|
||||
added_by_human = added_by_h
|
||||
)
|
||||
|
||||
|
||||
async def add_post_url(bot, url: str, approve: bool) -> bool:
|
||||
async def add_post_url(bot, url: str, approve: bool, added_by_h: bool = False) -> bool:
|
||||
result, post = await from_url(bot, url)
|
||||
|
||||
if not result:
|
||||
return False
|
||||
|
||||
post_data = get_post_details(post)
|
||||
post_data = get_post_details(post, added_by_h)
|
||||
post_data.approved_by_human = approve
|
||||
return data.add_post_to_data(bot, post_data, True)
|
||||
Reference in New Issue
Block a user