Skip to content

Commit

Permalink
Merge pull request #56 from BBArikL/Beta
Browse files Browse the repository at this point in the history
V4.7
  • Loading branch information
BBArikL authored Feb 27, 2023
2 parents 1811c41 + ca3e524 commit 4077f35
Show file tree
Hide file tree
Showing 7 changed files with 757 additions and 643 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ Discord bot that post bd strips. Simple as that!
- Garfield's classics https://www.gocomics.com/garfield-classics
- Peanuts https://www.gocomics.com/peanuts
- Peanuts Begins https://www.gocomics.com/peanuts-begins
- Dilbert https://dilbert.com/
- Dilbert classics https://www.gocomics.com/dilbert-classics
- Cyanide and Happiness https://explosm.net/
- Frazz https://www.gocomics.com/frazz
- Garfield minus Garfield https://garfieldminusgarfield.net/
Expand Down Expand Up @@ -57,6 +55,19 @@ Discord bot that post bd strips. Simple as that!
- Poorly Drawn Lines https://www.gocomics.com/en/poorly-drawn-lines
- Heathcliff https://www.gocomics.com/heathcliff
- Andy Capp https://www.gocomics.com/andycapp
- Ziggy https://www.gocomics.com/ziggy
- Junk Drawer https://www.gocomics.com/junk-drawer
- Working Daze https://www.gocomics.com/working-daze
- Compu-Toon https://www.gocomics.com/compu-toon
- Pixie and Brutus https://www.webtoons.com/en/challenge/pixie-and-brutus/list?title_no=452175
- Sarah's Scribbles https://www.gocomics.com/sarahs-scribbles

### Removed comics
Dilbert: See https://www.bbc.com/news/world-us-canada-64775250 . Functionality is still there but this is a public bot and I cannot take the risk of keeping it.

~~- Dilbert https://dilbert.com/~~

~~- Dilbert classics https://www.gocomics.com/dilbert-classics~~

## Related GitHub pages:
CalvinBot : https://github.com/wdr1/CalvinBot
Expand Down
48 changes: 34 additions & 14 deletions bdbot/bdbot_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,25 +502,45 @@ def remove_comic_from_database(comic_number: int):
guild = data[gid]
for channel in guild["channels"]:
channel_data = guild["channels"][channel]
for date in channel_data["date"]:
date_data = channel_data["date"][date]
for hour in date_data:
hour_data: list = date_data[hour]
if comic_number_remove in hour_data:
hour_data.remove(comic_number_remove)

new_hour_data = []
for cmc_nb in hour_data:
if cmc_nb > comic_number_remove:
new_hour_data.append(cmc_nb - 1)
else:
new_hour_data.append(cmc_nb)
data[gid]["channels"][channel]["date"][date][hour] = new_hour_data

if "latest" in channel_data:
data[gid]["channels"][channel]["latest"] = remove_from_array(
channel_data["latest"], comic_number_remove
)

if "date" in channel_data:
for date in channel_data["date"]:
date_data = channel_data["date"][date]
for hour in date_data:
hour_data: list = date_data[hour]
data[gid]["channels"][channel]["date"][date][
hour
] = remove_from_array(hour_data, comic_number_remove)

save_json(data)
logger.info("Database update done!")


def remove_from_array(array, comic_number_remove) -> list[str]:
"""Remove the comic number from the array and shift all other numbers
:param array:
:param comic_number_remove:
:return:
"""
new_arr = []
if comic_number_remove in array:
array.remove(comic_number_remove)

for cmc_nb in array:
if cmc_nb > comic_number_remove:
new_arr.append(cmc_nb - 1)
else:
new_arr.append(cmc_nb)

return new_arr


def modify(comics: dict, comic: str):
"""Modify a comic
Expand Down
Loading

0 comments on commit 4077f35

Please sign in to comment.