Compare commits

..

3 commits

Author SHA1 Message Date
dece b7b6ca71be wikipedia: catch all filthy exceptions 2021-06-11 11:31:45 +02:00
dece 5ca4a25b1f bot: graceful exception catch 2021-06-11 11:28:22 +02:00
dece 19e5408ba2 youtube_parser: remove annoying logs 2021-06-11 11:27:11 +02:00
3 changed files with 4 additions and 4 deletions

View file

@ -114,6 +114,8 @@ class Bot(irc.client.SimpleIRCClient, Logger):
try: try:
self.start() self.start()
except KeyboardInterrupt: except KeyboardInterrupt:
self.log_i("Caught keyboard interrupt.")
finally:
self.log_i("Stopping Edmond.") self.log_i("Stopping Edmond.")
self.__save_storage() self.__save_storage()

View file

@ -40,7 +40,7 @@ class WikipediaPlugin(Plugin):
try: try:
summary = wikipedia.summary(wikipedia.random(), sentences=1) summary = wikipedia.summary(wikipedia.random(), sentences=1)
break break
except wikipedia.exceptions.WikipediaException: except: # The wikipedia package can raise a lot of different stuff.
pass pass
retries -= 1 retries -= 1
if summary: if summary:
@ -59,7 +59,7 @@ class WikipediaPlugin(Plugin):
except wikipedia.exceptions.PageError: except wikipedia.exceptions.PageError:
summary = self.config["empty_response"] summary = self.config["empty_response"]
break break
except wikipedia.exceptions.WikipediaException: except:
summary = self.bot.config["error_message"] summary = self.bot.config["error_message"]
# Keep trying after a slight delay. # Keep trying after a slight delay.
time.sleep(1) time.sleep(1)

View file

@ -35,10 +35,8 @@ class YoutubeParserPlugin(Plugin):
def on_pubmsg(self, event): def on_pubmsg(self, event):
words = event.arguments[0].split() words = event.arguments[0].split()
for word in words: for word in words:
self.bot.log_d("testing " + word)
match = self.VIDEO_URL_RE.match(word) match = self.VIDEO_URL_RE.match(word)
if match: if match:
self.bot.log_d("match!")
return self.handle_match(match, event.target) return self.handle_match(match, event.target)
return False return False