This file is indexed.

/usr/lib/python2.7/dist-packages/gplugs/greeting.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
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# plugs/greeting.py
#
#

""" say greet message when user joins """

__copyright__ = 'this file is in the public domain'

from gozerbot.utils.generic import convertpickle
from gozerbot.commands import cmnds
from gozerbot.examples import examples
from gozerbot.persist.pdol import Pdol
from gozerbot.datadir import datadir
from gozerbot.users import users
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.callbacks import callbacks, jcallbacks
from gozerbot.plughelp import plughelp
from gozerbot.tests import tests

## basic imports

import random
import os
import logging

plughelp.add('greeting', 'the greeting plugin allows users to set messages \
to be said when they join a channel')

## UPGRADE PART

def upgrade():
    convertpickle(datadir + os.sep + 'old' + os.sep + 'greetings', \
datadir + os.sep + 'plugs' + os.sep + 'greeting' + os.sep + 'greetings')

cfg = PersistConfig()
cfg.define('enable', [])

greetings = None

def init():
    """ init the greeting plugin """
    global greetings
    greetings = Pdol(datadir + os.sep + 'plugs' + os.sep + 'greeting' + \
os.sep + 'greetings')
    if not greetings.data:
        upgrade()
        greetings = Pdol(datadir + os.sep + 'plugs' + os.sep + 'greeting' + \
os.sep + 'greetings')
    return 1

def greetingtest(bot, ievent):
    """ check if greeting callback should be called """
    logging.warn("greeting - checking %s" % ievent.orig)
    try:
        if ievent.time < bot.timejoined[ievent.channel] + 5:
            return 0
    except KeyError:
        return 0
    if greetings and ievent.channel not in cfg.get('enable'):
        return 0
    if ievent.channel not in bot.state['joinedchannels']:
        return 0
    if ievent.fromm == bot.user:
        return 0
    if bot.type == 'xmpp':
        logging.warn(ievent.c)
        if ievent.c == 'http://jabber.org/protocol/caps':
            return 0
        if  ievent.type == "available":
            return 1
    else:
        return 1
    return 0

def greetingcallback(bot, ievent):
    """ do the greeting """
    #username = users.getname(ievent.userhost)
    try:
        greetingslist = greetings[ievent.channel]

        if greetingslist:

            if bot.type == 'xmpp' and ievent.nick.rfind('guest') != -1:
                return

            bot.say(ievent.channel, ievent.nick + ', ' + random.choice(greetingslist))

    except KeyError:
        pass

callbacks.add('JOIN', greetingcallback, greetingtest)
callbacks.add('Presence', greetingcallback, greetingtest)

def handle_greetingon(bot, ievent):
    cfg['enable'].append(ievent.channel)
    cfg.save()
    ievent.done()

cmnds.add('greeting-on', handle_greetingon, 'USER')
examples.add('greeting-on', 'enable greeting in a channel', 'greeting-on')

def handle_greetingoff(bot, ievent):
    try:
        cfg['enable'].remove(ievent.channel)
        cfg.save()
    except ValueError:
        pass

    ievent.done()

cmnds.add('greeting-off', handle_greetingoff, 'USER')
examples.add('greeting-off', 'disable  greeting in a channel', 'greeting-off')

def handle_greetingadd(bot, ievent):
    """ add greetings txt """
    if not greetings:
        ievent.reply('the greet plugin is not properly initialised')
        return
    if not ievent.rest:
        ievent.missing('<txt>')
        return
    #username = users.getname(ievent.userhost)
    greetings.add(ievent.channel, ievent.rest)
    greetings.save()
    ievent.reply('greeting message added')

cmnds.add('greeting-add', handle_greetingadd, 'USER')
examples.add('greeting-add', "add greeting message", 'greeting-add yooo dudes')
tests.add('greetng-add boooo', 'added')

def handle_greetingdel(bot, ievent):
    """ delete greetings txt """
    if not greetings:
        ievent.reply('the greet plugin is not properly initialised')
        return
    try:
        nr = int(ievent.args[0])
    except (IndexError, ValueError):
        ievent.missing('<nr>')
        return
    #username = users.getname(ievent.userhost)
    try:
        del greetings.data[ievent.channel][nr]
    except (IndexError, KeyError):
        ievent.reply("can't delete greeting %s" % nr)
        return
    greetings.save()
    ievent.reply('greeting message %s removed' % nr)

cmnds.add('greeting-del', handle_greetingdel, 'USER')
examples.add('greeting-del', "delete greeting message", 'greeting-delete 1')
tests.add('greeting-del 1')

def handle_greetinglist(bot, ievent):
    """ list the greetings list of an user """
    if not greetings:
        ievent.reply('the greet plugin is not properly initialised')
        return
    #username = users.getname(ievent.userhost)
    result = greetings.get(ievent.channel)
    if result:
        ievent.reply("greetings: ", result, nr=0)
    else:
        ievent.reply('no greetings set')

cmnds.add('greeting-list', handle_greetinglist, 'USER')
examples.add('greeting-list', 'show greetings of user', 'greeting-list')
tests.add('greeting-list', 'boo')