This file is indexed.

/usr/share/pyshared/gplugs/drinks.py is in gozerbot 0.99.1-2.

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
# plugs/drinks.py
#
#

from gozerbot.commands import cmnds
from gozerbot.examples import examples
from gozerbot.plughelp import plughelp
from gozerbot.tests import tests

import os, string, random
import urllib, urllib2, json, re

plughelp.add('drinks', 'serve coffee/tea')

wikipedia_url = "http://en.wikipedia.org/w/api.php?"
wikipedia_url += "action=query&cmlimit=100&format=json"
wikipedia_url += "&list=categorymembers&cmtitle="

wikipedia_ns_main = '0'
wikipedia_ns_cat = '14'

coffee = []
tea = []

def init():
    global tea

    for tv in wikipedia_fetch('Category:Tea_varieties', wikipedia_ns_cat):
        for t in wikipedia_fetch(tv, wikipedia_ns_main):
            tea.append(t.strip())

    for c in wikipedia_fetch('Category:Coffee_beverages', wikipedia_ns_main):
        coffee.append(c.strip())

def wikipedia_fetch(category, ns):
    members = []

    try:
	args = urllib.quote_plus(category) + '&cmnamespace=' + ns
	response = urllib2.urlopen(wikipedia_url + args)
    except IOError:
	return members

    try:
	result = json.loads(response.read())
    except ValueError:
	return members
    for m in result['query']['categorymembers']:
	if m['title'].startswith('List of'):
	    continue
	title = re.sub("\ \(.*\)$", '', m['title'])
	members.append(title)

    return members

def handle_coffee(bot, ievent):
    """ get a coffee """
    if not coffee:
	return
    rand = random.randint(1,len(coffee))
    bot.action(ievent.channel, 
	"pours %s a cup of %s" % (ievent.nick, coffee[rand-1]))

def handle_tea(bot, ievent):
    """ get a tea """
    if not tea:
	return
    rand = random.randint(1,len(tea))
    bot.action(ievent.channel, 
	"pours %s a cup of %s" % (ievent.nick, tea[rand-1]))
    
cmnds.add('coffee', handle_coffee, 'USER')
examples.add('coffee', 'get a coffee', 'coffee')
tests.add('coffee')

cmnds.add('tea', handle_tea, 'USER')
examples.add('tea', 'get a tea', 'tea')
tests.add('tea')