This file is indexed.

/usr/lib/python2.7/dist-packages/gplugs/lns.py is in gozerbot 0.99.1-5.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# http://ln-s.net short ln-s
# (c) Wijnand "tehmaze" Modderman - http://tehmaze.com
# BSD License

from gozerbot.aliases import aliases
from gozerbot.callbacks import callbacks
from gozerbot.commands import cmnds
from gozerbot.generic import rlog
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.persist.persiststate import PlugState
from gozerbot.plughelp import plughelp
from gozerbot.examples import examples
from gozerbot.tests import tests

import re
import urllib, urllib2

plughelp.add('lns', 'use the ln-s.net redirector')

re_url_match = re.compile(r'((?:http|https|ftp)://\S+)')

cfg = PersistConfig()
cfg.define('url-api', 'http://ln-s.net/home/api.jsp')
cfg.define('url-len', 64)

state = None

def init():
    global state
    state = PlugState()
    state.define('ln-s', {})
    return 1

def shutdown():
    if state:
        state.save()
        return 1

def lnsurl(url):
    req = urllib2.Request(url=cfg.get('url-api'),
        data=urllib.urlencode({'url': url}))
    out = urllib2.urlopen(req)
    ret = out.read().strip()
    return ret.split(' ', 1)[1]

def lnscb(bot, ievent):
    if not state:
        return
    if not bot.name in state['ln-s']:
        return
    if not ievent.channel.lower() in state['ln-s'][bot.name]:
        return
    if not state['ln-s'][bot.name][ievent.channel.lower()]:
        return
    try:
        test_urls = re_url_match.findall(ievent.txt)
        for url in test_urls:
            if len(url) >= cfg.get('url-len'):
                host = url.split(':')[1].lstrip('/').split('/')[0]
                short = lnsurl(url)
                ievent.reply('%s (at %s)' % (short, host))
    except Exception,e:
        rlog(10, 'lns', 'EXCEPTION: %s' % str(e))

def handle_ln_on(bot, ievent):
    if not state:
        return
    if not bot.name in state['ln-s']:
        state['ln-s'][bot.name] = {}
    if not ievent.channel.lower() in state['ln-s'][bot.name]:
        state['ln-s'][bot.name][ievent.channel.lower()] = True
    ievent.reply('ok')

def handle_ln_off(bot, ievent):
    if not state:
        return
    if not bot.name in state['ln-s']:
        state['ln-s'][bot.name] = {}
    if not ievent.channel.lower() in state['ln-s'][bot.name]:
        state['ln-s'][bot.name][ievent.channel.lower()] = False
    ievent.reply('ok')

callbacks.add('PRIVMSG', lnscb)
cmnds.add('ln-on', handle_ln_on, 'USER')
examples.add('ln-on', 'enable ln in channel the command was given in', 'ln-on')
tests.add('ln-on')
cmnds.add('ln-off', handle_ln_off, 'USER')
examples.add('ln-off', 'diable ln in channel the command was given in', \
'ln-off')
tests.add('ln-off')
aliases.data['lns-on'] = 'ln-on'
aliases.data['lns-off'] = 'lns-off'