Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring - Sorting imports with isort and linting with black #141

Merged
merged 1 commit into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/honeybot/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

try:
from honeybot.api import commands, memory
from honeybot.api.utils import (configfile_to_list, get_requirements,
prevent_none)
from honeybot.api.utils import configfile_to_list, get_requirements, prevent_none
except Exception as e:
raise e

Expand Down
3 changes: 1 addition & 2 deletions src/honeybot/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
from honeybot.api.generate import gen_pluginsinfo
from honeybot.api.init import init
from honeybot.api.main import Bot_core
from honeybot.api.print import (print_connect_settings,
print_honeybot_manifesto)
from honeybot.api.print import print_connect_settings, print_honeybot_manifesto
except Exception as e:
print(e)

Expand Down
11 changes: 2 additions & 9 deletions src/honeybot/plugins/downloaded/age/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,15 @@ def __age(day, mo, yr):
if months < 0 or (months == 0 and day < 0):
years -= 1

msg = "You are {0}yrs. {1}mo. and {2} days old.".format(
years, abs(months), abs(days)
)
msg = "You are {0}yrs. {1}mo. and {2} days old.".format(years, abs(months), abs(days))
return msg

def run(self, incoming, methods, info, bot_info):
try:
msgs = info["args"][1:][0].split()
print(len(msgs))
if info["command"] == "PRIVMSG" and msgs[0] == ".age":
if (
len(msgs) == 4
and len(msgs[1]) < 3
and len(msgs[2]) < 3
and len(msgs[3]) == 4
):
if len(msgs) == 4 and len(msgs[1]) < 3 and len(msgs[2]) < 3 and len(msgs[3]) == 4:
day = int(msgs[1])
mo = int(msgs[2])
yr = int(msgs[3])
Expand Down
4 changes: 1 addition & 3 deletions src/honeybot/plugins/downloaded/bitcoin/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ def run(self, incoming, methods, info, bot_info):
# msgs = info['args'][1:][0].split()

if info["command"] == "PRIVMSG" and info["args"][1] == ".btc":
response = requests.get(
"https://api.coinmarketcap.com/v1/ticker/bitcoin/"
)
response = requests.get("https://api.coinmarketcap.com/v1/ticker/bitcoin/")
response_json = response.json()
methods["send"](info["address"], "$" + response_json[0]["price_usd"])

Expand Down
2 changes: 1 addition & 1 deletion src/honeybot/plugins/downloaded/bitcoin/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
requests
requests
40 changes: 10 additions & 30 deletions src/honeybot/plugins/downloaded/blackjack/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,11 @@ def next_turn(methods, info):
Plugin.turn += 1
if Plugin.turn == len(Plugin.player_lst):
# all players have find winner
total_lst = [
player.show_player_hand().hand_total()
for player in Plugin.player_lst
]
total_lst = [player.show_player_hand().hand_total() for player in Plugin.player_lst]
index, value = max(list(enumerate(total_lst)), key=lambda x: x[1])
if total_lst.count(value) == 1:
Plugin.winner = Plugin.player_lst[index].get_name()
methods["send"](
info["address"], "The winner is " + Plugin.winner + "!"
)
methods["send"](info["address"], "The winner is " + Plugin.winner + "!")
else:
methods["send"](info["address"], "This round has ended in a draw!")
Plugin.bj_created = False
Expand All @@ -76,19 +71,15 @@ def initPlayer(methods, info):
if not Plugin.round_started:
name = info["prefix"].split("!")[0]
if len(Plugin.player_lst) <= 5: # limit game to 6 players
if not (
name in [player.get_name() for player in Plugin.player_lst]
):
if not (name in [player.get_name() for player in Plugin.player_lst]):
Plugin.player_lst.append(
poker_assets.player.Player(
len(Plugin.player_lst), Plugin.starting_chips, name
)
)
methods["send"](info["address"], name + " joined the game!")
else:
methods["send"](
info["address"], "You are already in this round!"
)
methods["send"](info["address"], "You are already in this round!")
else:
methods["send"](info["address"], "This round is full already")
else:
Expand All @@ -105,10 +96,7 @@ def checkHand(methods, info, player):
name = player.get_name()
total = player.show_player_hand().hand_total()
cards = " ".join(
[
poker_assets.card.show_card()
for card in player.show_player_hand().show_hand_obj()
]
[poker_assets.card.show_card() for card in player.show_player_hand().show_hand_obj()]
)
if total > 21:
methods["send"](
Expand Down Expand Up @@ -158,8 +146,7 @@ def initGame(methods, info):
Plugin.DECK = poker_assets.deck.Deck()
methods["send"](
info["address"],
name + " has started a game of blackjack! "
"Use .blackjack join to join in!",
name + " has started a game of blackjack! " "Use .blackjack join to join in!",
)
else:
methods["send"](info["address"], "A game already exists!")
Expand All @@ -186,9 +173,7 @@ def hit(methods, info):
name = info["prefix"].split("!")[0]
if Plugin.winner is None:
if Plugin.player_lst[Plugin.turn].get_name() == name:
Plugin.player_lst[Plugin.turn].add_card_to_hand(
Plugin.DECK.draw_random_card()
)
Plugin.player_lst[Plugin.turn].add_card_to_hand(Plugin.DECK.draw_random_card())
Plugin.checkHand(methods, info, Plugin.player_lst[Plugin.turn])
else:
methods["send"](info["address"], "It is not your turn!")
Expand All @@ -206,21 +191,16 @@ def stand(methods, info):
if Plugin.player_lst[Plugin.turn].get_name() == name:
methods["send"](
info["address"],
info["prefix"].split("!")[0]
+ " has chosen not to pick another card!",
info["prefix"].split("!")[0] + " has chosen not to pick another card!",
)
Plugin.next_turn(methods, info)
else:
methods["send"](info["address"], "It is not your turn!")
else:
methods["send"](
info["adress"], "something went wrong, please try restarting"
)
methods["send"](info["adress"], "something went wrong, please try restarting")
Plugin.bj_created = False
else:
methods["send"](
info["address"], Plugin.winner + " has already won the game!"
)
methods["send"](info["address"], Plugin.winner + " has already won the game!")

"""
RUNNING PLUGIN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ def init_game(players, round):

for i in range(len(PLAYERS)):

PLAYERS[i].add_position(
(len(PLAYERS) * round + (i - (round - 1))) % len(PLAYERS)
)
PLAYERS[i].add_position((len(PLAYERS) * round + (i - (round - 1))) % len(PLAYERS))

return DECK, BOARD, POT, PLAYERS

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,7 @@

print(
" ".join(
[
c.show_card()
for h in game_init.game[3]
for c in h.show_player_hand().show_hand_obj()
]
[c.show_card() for h in game_init.game[3] for c in h.show_player_hand().show_hand_obj()]
)
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
requests
beautifulsoup4
beautifulsoup4
2 changes: 1 addition & 1 deletion src/honeybot/plugins/downloaded/comic/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
requests
requests
4 changes: 1 addition & 3 deletions src/honeybot/plugins/downloaded/conv_sniff/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ def run(self, incoming, methods, info, bot_info):
)
elif self.topics[topic]["checkin"] == "S":
for word in msgs:
meet = set(self.topics[topic]["elems"]).intersection(
set(word)
)
meet = set(self.topics[topic]["elems"]).intersection(set(word))
occurs = self.topics[topic]["occurs"]
if meet and len(meet) > occurs - 2:
methods["send"](
Expand Down
22 changes: 4 additions & 18 deletions src/honeybot/plugins/downloaded/converter/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,7 @@ def is_number(char):
return "invalid amount entered, it must be a number. default is 1"
else:
base_url = "https://www.x-rates.com/calculator/?"
url = (
base_url
+ "from="
+ base_cur
+ "&to="
+ target_cur
+ "&amount="
+ str(amount)
)
url = base_url + "from=" + base_cur + "&to=" + target_cur + "&amount=" + str(amount)
page = requests.get(url)
soup = BeautifulSoup(page.text, "html.parser")

Expand All @@ -130,13 +122,9 @@ def run(self, incoming, methods, info, bot_info):
msgs = info["args"][1:][0].split()
if info["command"] == "PRIVMSG" and msgs[0] == ".convert":
if len(msgs) == 3:
methods["send"](
info["address"], Plugin.conv(self, msgs[1], msgs[2])
)
methods["send"](info["address"], Plugin.conv(self, msgs[1], msgs[2]))
elif len(msgs) == 4:
methods["send"](
info["address"], Plugin.conv(self, msgs[1], msgs[2], msgs[3])
)
methods["send"](info["address"], Plugin.conv(self, msgs[1], msgs[2], msgs[3]))
elif len(msgs) == 2 and msgs[1] == "help":
methods["send"](info["address"], Plugin.help(self, methods, info))
elif len(msgs) == 2 and msgs[1] != "help":
Expand All @@ -151,9 +139,7 @@ def run(self, incoming, methods, info, bot_info):
)
methods["send"](info["address"], "or help")
elif len(msgs) == 1:
methods["send"](
info["address"], "converter plugin requires arguments:"
)
methods["send"](info["address"], "converter plugin requires arguments:")
methods["send"](
info["address"], "either two currencies with an optional amount"
)
Expand Down
2 changes: 1 addition & 1 deletion src/honeybot/plugins/downloaded/converter/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
requests
beautifulsoup4
beautifulsoup4
4 changes: 1 addition & 3 deletions src/honeybot/plugins/downloaded/corona/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ def scrape(self, country):
cases = doc.find_all(class_="maincounter-number")
data = doc.find_all("td")
if country == "global":
most_affected = (
[]
) # each element is an array as follows [country,cases,deaths]
most_affected = [] # each element is an array as follows [country,cases,deaths]
for index in range(0, 45, 11):
most_affected.append(
[
Expand Down
2 changes: 1 addition & 1 deletion src/honeybot/plugins/downloaded/corona/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
requests
beautifulsoup4
beautifulsoup4
2 changes: 1 addition & 1 deletion src/honeybot/plugins/downloaded/dadjoke/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
requests
requests
17 changes: 4 additions & 13 deletions src/honeybot/plugins/downloaded/diary/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ def delete(self, time):
"""check if entry exists and if it does delete it"""
path = Plugin.get_path(self, time)
if not os.path.exists(path):
return (
"There is no diary entry for that date. "
"Check the date is entered correctly!"
)
return "There is no diary entry for that date. " "Check the date is entered correctly!"
else:
os.remove(path)
return "Entry deleted successfully!"
Expand All @@ -107,9 +104,7 @@ def run(self, incoming, methods, info, bot_info):
index = info["prefix"].find("!")
name = info["prefix"][:index]
if name not in owner:
methods["send"](
info["address"], "Access denied! You are not the owner!"
)
methods["send"](info["address"], "Access denied! You are not the owner!")
else:

if msgs[1].lower() == "delete":
Expand Down Expand Up @@ -147,17 +142,13 @@ def run(self, incoming, methods, info, bot_info):

elif msgs[1].lower() == "help":
methods["send"](info["address"], "Try the following commands!")
methods["send"](
info["address"], ".diary record this is an example "
)
methods["send"](info["address"], ".diary record this is an example ")
methods["send"](
info["address"],
".diary show today or .diary show 01-01-2000",
)
methods["send"](info["address"], ".diary delete")
methods["send"](
info["address"], "That's all there is to this plugin!"
)
methods["send"](info["address"], "That's all there is to this plugin!")

except Exception as e:
print("woops, diary plugin error", e)
27 changes: 9 additions & 18 deletions src/honeybot/plugins/downloaded/fact/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ def run(self, incoming, methods, info, bot_info):
+ "Instead, they played piano music."
"Amelia Earhart and Eleanor Roosevelt once sneaked out of a White"
+ "House event, commandeered an airplane, and went on a joyride to Baltimore."
"The 100 folds in a chef's toque are said to represent 100 ways "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need to use + if it is a single string

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need to use + if it is a single string

These "+" was to obey the 100 char limit. I guess that new lint pass modified the original flake8 style

+ "to cook an egg."
"The 100 folds in a chef's toque are said to represent 100 ways " + "to cook an egg."
"The world’s oldest surviving piano is at the Metropolitan Museum of Art "
+ "in New York City. The instrument dates back to 1720, and was made by "
+ "an Italian man named Bartolomeo Cristofori."
Expand All @@ -50,16 +49,14 @@ def run(self, incoming, methods, info, bot_info):
+ "price reached $3,000 before it was shut down.",
"Google's founders were willing to sell to excite for under $1 million"
+ " in 1999--but excite turned them down.",
"There was a third Apple founder. Ronald Wayne sold his 10% stake "
+ "for $800 in 1976.",
"There was a third Apple founder. Ronald Wayne sold his 10% stake " + "for $800 in 1976.",
"Reed Hastings was inspired to start Netflix after racking up a "
+ "$40 late fee on a VHS copy of Apollo 13.",
"During WWI, German measles were called 'Liberty Measles' and "
+ "dachshunds became 'liberty hounds.'",
"A 2009 search for the loch ness monster came up empty. "
+ "Scientists did find over 100,000 golf balls.",
"In Japan, letting a sumo wrestler make your baby cry is considered "
+ "good luck.",
"In Japan, letting a sumo wrestler make your baby cry is considered " + "good luck.",
"When three-letter airport codes became a standard, airports that "
+ "been using two letters simply added an X.",
"The actor who was inside R2-D2 hated the guy who played C-3PO, "
Expand Down Expand Up @@ -95,8 +92,7 @@ def run(self, incoming, methods, info, bot_info):
"12+1 = 11+2, and 'Twelve plus one' is an anagram of 'eleven plus " + "two'.",
"At the height of Rin Tin Tin's fame, a chef prepared him a daily "
+ "steak lunch. Classical musicians played to aid his digestion.",
"The Arkansas school for the Deaf's nickname is the Leopards. The "
+ "Deaf Leopards.",
"The Arkansas school for the Deaf's nickname is the Leopards. The " + "Deaf Leopards.",
"If your dog's feet smell like corn chips, you're not alone. The term"
+ "'Frito feet' was coined to describe the scent.",
"Barry Manilow did not write his hit 'I Write the Songs'.",
Expand All @@ -109,15 +105,13 @@ def run(self, incoming, methods, info, bot_info):
"The medical term for ice cream headaches is Sphenopalatine " + "Ganglioneuralgia.",
"After Leonardo Da Vinci's death, King Francis I of France hung "
+ "the 'Mona Lisa' in his bathroom.",
"Redondo Beach, CA adopted the Goodyear Blimp as the cit's official "
+ "bird in 1983.",
"Redondo Beach, CA adopted the Goodyear Blimp as the cit's official " + "bird in 1983.",
"In 2001, Beaver College changed its name to Arcadia in part because "
+ "anti-porn filters blocked access to the school's website.",
"Quentin Tarantino played an Elvis impersonator on 'The Golden Girls'.",
"Wendy's founder Dave Thomas dropped out of high school but picked "
+ "up his GED in 1993. His GED class voted him most likely to succeed.",
"Sleeping through winter is hibernation, while sleeping through "
+ "summer is estivation.",
"Sleeping through winter is hibernation, while sleeping through " + "summer is estivation.",
"In Qaddafi's compound, Libyan rebels found a photo album filled "
+ "with pictures of Condoleezza Rice.",
"Marie Curie's notebooks are still radioactive. Researchers hoping "
Expand All @@ -126,8 +120,7 @@ def run(self, incoming, methods, info, bot_info):
+ "$1,000, and James Madison was on the $5,000.",
"In 1999, the U.S. government paid the Zapruder family $16 million "
+ "for the film of JFK's assassination.",
"Janis Joplin left $2,500 in her will for her friends to 'Have a "
+ "ball after I'm gone.",
"Janis Joplin left $2,500 in her will for her friends to 'Have a " + "ball after I'm gone.",
"In the mid-1960's, Slumber Party Barbie came with a book called "
+ "'How to Lose Weight.' One of the tips was 'Don't Eat.'",
"Ben & Jerry originally considered getting into the bagel business, "
Expand All @@ -141,8 +134,7 @@ def run(self, incoming, methods, info, bot_info):
+ "Ladies' for protection at an economic summit. She declined.",
"Before Google launched Gmail, 'G-Mail' was the name of a free email "
+ "service offered by Garfield's website.",
"The final speech by Gregory Peck in 'To Kill a Mockingbird' was "
+ "done in one take.",
"The final speech by Gregory Peck in 'To Kill a Mockingbird' was " + "done in one take.",
"In 1980, Detroit presented Saddam Hussein with a key to the city.",
"Crayola means 'oily chalk.' The name combines 'craie' (French for "
+ "'chalk') and 'ola'(short for 'oleaginous,' or 'oily').",
Expand All @@ -164,6 +156,5 @@ def run(self, incoming, methods, info, bot_info):
"Italy has the most UNECO sites in the world",
"Space is completly silent",
"The sunset on Mars appears blue",
'In the early drafts of "Star Wars: The Empire Strikes Back", '
+ "Yoda was named Buffy.",
'In the early drafts of "Star Wars: The Empire Strikes Back", ' + "Yoda was named Buffy.",
]
Loading