Skip to content

Commit

Permalink
fix useless posts to irc
Browse files Browse the repository at this point in the history
  • Loading branch information
noqqe committed Mar 27, 2017
1 parent eaac4ac commit 3666bb0
Showing 1 changed file with 42 additions and 12 deletions.
54 changes: 42 additions & 12 deletions plugins/urls.py
@@ -1,20 +1,50 @@
from plugin import Plugin

class Urls(Plugin):
def help_text(self, bot):

def help_text(self, bot):
return (bot.translate("url_help") + "\n" + bot.translate("url_help2"))

def on_msg(self, bot, user_nick, host, channel, message):
if bot.httpregex.search(message.lower()) is not None:
urls = bot.geturlsfrommsg(message)
for url in urls:
title = bot.sanitize(bot.geturltitle(url))
if title == "":
title = url
if message.lower().startswith('!private') or message.lower().startswith('!pr'):
def on_msg(self, bot, user_nick, host, channel, message):
ms = message.lower()

if bot.httpregex.search(ms) is None:
return False

# extract list of arrays from message
urls = bot.geturlsfrommsg(message)

# loop through all items
for url in urls:

# fetch html <title> element
title = bot.sanitize(bot.geturltitle(url))

# Check if link can be added to wiki
if not ms.startswith('!private') and not ms.startswith('!pr') and not ms.startswith('!nsfw'):

# Set proper wikititle
if title == "":
title = url

# call bot and paste to wiki
bot.get_plugin("MediaWiki").wikiupdate(wikititle, url)

# If empty title, dont paste to irc
if title == "":
continue

# check if private link
if ms.startswith('!private') or ms.startswith('!pr'):
bot.send_message(channel, "[private] " + "Title: {title}".format(title=title), user_nick)
elif message.lower().startswith('!nsfw'):

# check if link was marked as nsfw from sender
elif ms.startswith('!nsfw'):
bot.send_message(channel, "[nsfw] " + "Title: {title}".format(title=title), user_nick)
else:

# send title to
else:
bot.send_message(channel, "Title: {title}".format(title=title), user_nick)
print bot.get_plugin("MediaWiki").wikiupdate(title, url)



0 comments on commit 3666bb0

Please sign in to comment.