Compare commits

..

3 Commits

Author SHA1 Message Date
180cb159a7 add error handling for broken unicode 2019-09-13 19:01:08 -04:00
03eea368c3 readme 2019-09-13 19:00:46 -04:00
bee166f985 prevent flooding via .py command 2019-09-13 18:54:36 -04:00
3 changed files with 10 additions and 2 deletions

View File

@ -4,7 +4,7 @@ It's like Sopel, except rewritten from scratch using Twisted as a base and over
## Requirements ## Requirements
Python 3.6+ Python 3.6+
Python packages: `twisted, python-dateutil, requests, bs4, wolfram, pyenchant, emoji, Pillow, xml2dict, ipython, numpy, numpngw` Python packages: `twisted python-dateutil requests bs4 wolframalpha pyenchant emoji Pillow xml2dict ipython numpy numpngw`
## Config ## Config
`nickname` - The nickname the bot will use. `nickname` - The nickname the bot will use.

7
bot.py
View File

@ -616,6 +616,13 @@ class Fulvia(irc.IRCClient):
self.whoisIdle(nick, idle, signon) self.whoisIdle(nick, idle, signon)
def lineReceived(self, line):
"""Overridden to fix broken unicode issues."""
if bytes != str and isinstance(line, bytes):
line = line.decode('utf-8', errors='surrogateescape')
super().lineReceived(line)
class FulviaWrapper(): class FulviaWrapper():
""" """
A wrapper class for Fulvia to provide default destinations for msg A wrapper class for Fulvia to provide default destinations for msg

View File

@ -41,8 +41,9 @@ def py(bot, trigger):
res = requests.get(uri + query) res = requests.get(uri + query)
res.raise_for_status() res.raise_for_status()
answer = res.text answer = res.text
answer = answer[:2000]
if answer: if answer:
#bot.msg can potentially lead to 3rd party commands triggering. #bot.msg can potentially lead to 3rd party commands triggering.
bot.msg(answer) bot.msg(answer, length=300)
else: else:
bot.reply('Sorry, no result.') bot.reply('Sorry, no result.')