This file is indexed.

/usr/share/pyshared/jsb/lib/partyline.py is in jsonbot 0.84.4-1.

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
# jsb/socklib/partyline.py
#
#

""" provide partyline functionality .. manage dcc sockets. """


__copyright__ = 'this file is in the public domain'
__author__ = 'Aim'

## jsb imports

from jsb.lib.fleet import getfleet
from jsb.utils.exception import handle_exception
from jsb.lib.threads import start_new_thread
from jsb.imports import getjson
json = getjson()

## basic imports

import thread
import pickle
import socket
import logging

## classes

class PartyLine(object):

    """ partyline can be used to talk through dcc chat connections. """

    def __init__(self):
        self.socks = [] # partyline sockets list
        self.jids = []
        self.lock = thread.allocate_lock()

    def size(self):
        return len(self.socks)

    def resume(self, sessionfile):
        """ resume bot from session file. """
        try:
            session = json.load(open(sessionfile, 'r'))
            self._resume(session) 
        except: handle_exception()

    def _resume(self, data, reto=None):
        """ resume a party line connection after reboot. """
        fleet = getfleet()
        for i in data['partyline']:
            logging.warn("partyline - resuming %s" % i)
            bot = fleet.byname(i['botname'])
            if not bot: logging.error("partyline - can't find bot") ; continue
            sock = socket.fromfd(i['fileno'], socket.AF_INET, socket.SOCK_STREAM)
            sock.setblocking(1)
            nick = i['nick']
            userhost = i['userhost']
            channel = i['channel']
            if not bot:
                logging.error("partyline - can't find %s bot in fleet" % i['botname'])
                continue
            self.socks.append({'bot': bot, 'sock': sock, 'nick': nick, 'userhost': userhost, 'channel': channel, 'silent': i['silent']})
            bot._dccresume(sock, nick, userhost, channel)        
            if reto: self.say_nick(nick, 'rebooting done')

    def _resumedata(self):
        """ return data used for resume. """
        result = []
        for i in self.socks: result.append({'botname': i['bot'].cfg.name, 'fileno': i['sock'].fileno(), 'nick': i['nick'], 'userhost': i['userhost'], 'channel': i['channel'], 'silent': i['silent']})
        return result

    def stop(self, bot):
        """ stop all users on bot. """
        for i in self.socks:
            if i['bot'] == bot:
                try:
                    i['sock'].shutdown(2)
                    i['sock'].close()
                except: pass
                 
    def stop_all(self):
        """ stop every user on partyline. """
        for i in self.socks:
            try:
                i['sock'].shutdown(2)
                i['sock'].close()
            except:
                pass

    def loud(self, nick): 
        """ enable broadcasting of txt for nick. """
        for i in self.socks:
            if i['nick'] == nick: i['silent'] = False

    def silent(self, nick):
        """ disable broadcasting txt from/to nick. """
        for i in self.socks:
            if i['nick'] == nick: i['silent'] = True

    def add_party(self, bot, sock, nick, userhost, channel):
        ''' add a socket with nick to the list. '''
        for i in self.socks:
            if i['sock'] == sock: return            
        self.socks.append({'bot': bot, 'sock': sock, 'nick': nick, 'userhost': userhost, 'channel': channel, 'silent': False})
        logging.warn("partyline - added user %s" % nick)

    def del_party(self, nick):
        ''' remove a socket with nick from the list. '''
        nick = nick.lower()
        self.lock.acquire()
        try:
            for socknr in range(len(self.socks)-1, -1, -1):	
                if self.socks[socknr]['nick'].lower() == nick: del self.socks[socknr]
            logging.debug('partyline - removed user %s' % nick)
        finally: self.lock.release()

    def list_nicks(self):
        ''' list all connected nicks. '''
        result = []
        for item in self.socks: result.append(item['nick'])
        return result

    def say_broadcast(self, txt):
        ''' broadcast a message to all ppl on partyline. '''
        for item in self.socks:
            if not item['silent']: item['sock'].send("%s\n" % txt)

    def say_broadcast_notself(self, nick, txt):
        ''' broadcast a message to all ppl on partyline, except the sender. '''
        nick = nick.lower()
        for item in self.socks:
            if item['nick'] == nick: continue
            if not item['silent']: item['sock'].send("%s\n" % txt)

    def say_nick(self, nickto, msg):
        ''' say a message on the partyline to an user. '''
        nickto = nickto.lower()
        for item in self.socks:
            if item['nick'].lower() == nickto:
                if not '\n' in msg: msg += "\n"
                item['sock'].send("%s" % msg)
                return

    def is_on(self, nick):
        ''' checks if user an is on the partyline. '''
        nick = nick.lower()
        for item in self.socks:
            if item['nick'].lower() == nick: return True
        return False

## global partyline object

partyline = PartyLine()

def size():
    return partyline.size()