Skip to content
This repository has been archived by the owner on Mar 13, 2019. It is now read-only.

Fixes twitter image links to always have :orig at the end of the links #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
10 changes: 9 additions & 1 deletion volaparrot/commands/tard.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
from .command import Command


__all__ = ["EightballCommand", "RevolverCommand", "DiceCommand", "ChenCommand", "XDanielCommand"]
__all__ = ["EightballCommand", "RevolverCommand", "DiceCommand", "ChenCommand", "XDanielCommand",
"DotCommand"]

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -143,6 +144,13 @@ def __call__(self, cmd, remainder, msg):
self.post("{}: M{}RC", user, "E" * min(50, max(1, cmd.lower().count("e"))))
return True

class DotCommand(Command):
handlers = "...", "....", "....."

def __call__(self, cmd, remainder, msg):
self.post("{} = gay".format(msg.nick))
return True

class ProfanityCommand(Command):
extract = re.compile(r"1:.*?\s+warning\s+(.*?)\s\S+$")
handlers = "!analyze", "!sjw", "!profanity"
Expand Down
9 changes: 9 additions & 0 deletions volaparrot/commands/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,15 @@ def onurl(self, url, msg):
imgs = [html.unescape(i.group(1))
for i in self.images.finditer(resp)
if "profile_images" not in i.group(1)]

# Not very elegant but at least it works :^)
for i in range(0, len(imgs)):
if not re.match(":orig$", imgs[i], re.I):
if imgs[i].find(":") != imgs[i].rfind(":"):
imgs[i] = imgs[i][:imgs[i].rfind(":")]

imgs[i] += ":orig"

imgs = " ".join(imgs)
if imgs:
info = "{title}:\n{desc}\n{imgs}".format(title=title, desc=desc, imgs=imgs)
Expand Down