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

Commit

Permalink
Removed .posted, .lines, augmented title retrieval.
Browse files Browse the repository at this point in the history
  • Loading branch information
andreimarcu authored and mutantmonkey committed Apr 2, 2014
1 parent f8c25e5 commit 2da9ed0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 69 deletions.
7 changes: 1 addition & 6 deletions modules/head.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from html.entities import name2codepoint
import web
from tools import deprecated
from modules.linx import get_title as linx_gettitle


def head(phenny, input):
Expand Down Expand Up @@ -90,11 +89,7 @@ def noteuri(phenny, input):

def snarfuri(phenny, input):
uri = input.group(1)

if phenny.config.linx_api_key != "":
title = linx_gettitle(phenny, uri, input.sender)
else:
title = gettitle(phenny, uri)
title = gettitle(phenny, uri)

if title:
phenny.msg(input.sender, title)
Expand Down
64 changes: 2 additions & 62 deletions modules/linx.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@
import json


def get_title(phenny, url, channel):
""" Have linx retrieve the (augmented) title """
try:
return web.post("https://linx.li/vtluuggettitle", {'url': url, 'channel': channel, 'api_key': phenny.config.linx_api_key})
except:
return


def linx(phenny, input, short=False):
""".linx <url> - Upload a remote URL to linx.li."""

Expand All @@ -27,9 +19,9 @@ def linx(phenny, input, short=False):
return

try:
req = web.post("https://linx.li/vtluug", {'url': url, 'short': short, 'api_key': phenny.config.linx_api_key})
req = web.post("https://linx.li/upload/remote", {'url': url, 'short': short, 'api_key': phenny.config.linx_api_key})
except (web.HTTPError, web.ConnectionError):
raise GrumbleError("THE INTERNET IS FUCKING BROKEN. Please try again later.")
raise GrumbleError("Couldn't reach linx.li")

data = json.loads(req)
if len(data) <= 0 or not data['success']:
Expand All @@ -46,55 +38,3 @@ def lnx(phenny, input):
"""
linx(phenny, input, True)
lnx.rule = (['lnx'], r'(.*)')


def lines(phenny, input):
""".lines <nickname> (<today/yesterday/YYYYMMDD>) - Returns the number of lines a user posted on a specific date."""

if input.group(2):
info = input.group(2).split(" ")

if len(info) == 1:
nickname = info[0]
date = "today"
elif len(info) == 2:
nickname = info[0]
date = info[1]
else:
phenny.reply(".lines <nickname> (<today/yesterday/YYYYMMDD>) - Returns the number of lines a user posted on a specific date.")
return

else:
nickname = input.nick
date = "today"

try:
req = web.post("https://linx.li/vtluuglines", {'nickname': nickname, 'date': date, 'sender': input.nick, 'channel': input.sender, 'api_key': phenny.config.linx_api_key})
except (web.HTTPError, web.ConnectionError):
raise GrumbleError("THE INTERNET IS FUCKING BROKEN. Please try again later.")

phenny.reply(req)

lines.rule = (['lines'], r'(.*)')


def posted(phenny, input):
""".posted <message> - Checks if <message> has already been posted."""

message = input.group(2)
if not message:
phenny.say(".posted <message> - Checks if <message> has already been posted.")
return

try:
req = web.post("https://linx.li/vtluugposted", {'message': message, 'sender': input.nick, 'channel': input.sender, 'api_key': phenny.config.linx_api_key})
except (web.HTTPError, web.ConnectionError):
raise GrumbleError("THE INTERNET IS FUCKING BROKEN. Please try again later.")

phenny.reply(req)

posted.rule = (['posted'], r'(.*)')


if __name__ == '__main__':
print(__doc__.strip())
2 changes: 1 addition & 1 deletion phenny
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def create_default_config(fn):
# password = 'example'
# serverpass = 'serverpass'
# linx-enabled features (.linx, .posted, .lines, snarfuri with special capabilities)
# linx-enabled features (.linx, .lnx)
# leave the api key blank to not use them and be sure to add the 'linx' module to the ignore list.
linx_api_key = ""
Expand Down

0 comments on commit 2da9ed0

Please sign in to comment.