This file is indexed.

/usr/share/doc/python-twisted-words/examples/minchat.py is in python-twisted-words 13.2.0-1ubuntu1.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
 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
#!/usr/bin/env python

# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.


"""
A very simple twisted.words.im-based logbot.

To run the script:
$ python minchat.py
"""

from twisted.words.im import basechat, baseaccount, ircsupport


# A list of account objects. We might as well create them at runtime, this is
# supposed to be a Minimalist Implementation, after all.

accounts = [
    ircsupport.IRCAccount("IRC", 1,
        "Tooty",            # nickname
        "",                 # passwd
        "irc.freenode.net", # irc server
        6667,               # port
        "#twisted",         # comma-seperated list of channels
    )
]


class AccountManager (baseaccount.AccountManager):
    """
    This class is a minimal implementation of the Acccount Manager.

    Most implementations will show some screen that lets the user add and
    remove accounts, but we're not quite that sophisticated.
    """

    def __init__(self):

        self.chatui = MinChat()

        if len(accounts) == 0:
            print "You have defined no accounts."
        for acct in accounts:
            acct.logOn(self.chatui)


class MinConversation(basechat.Conversation):
    """
    This class is a minimal implementation of the abstract Conversation class.

    This is all you need to override to receive one-on-one messages.
    """
    def show(self):
        """
        If you don't have a GUI, this is a no-op.
        """
        pass
    
    def hide(self):
        """
        If you don't have a GUI, this is a no-op.
        """
        pass
    
    def showMessage(self, text, metadata=None):
        print "<%s> %s" % (self.person.name, text)
        
    def contactChangedNick(self, person, newnick):
        basechat.Conversation.contactChangedNick(self, person, newnick)
        print "-!- %s is now known as %s" % (person.name, newnick)


class MinGroupConversation(basechat.GroupConversation):
    """
    This class is a minimal implementation of the abstract GroupConversation class.

    This is all you need to override to listen in on a group conversaion.
    """
    def show(self):
        """
        If you don't have a GUI, this is a no-op.
        """
        pass

    def hide(self):
        """
        If you don't have a GUI, this is a no-op.
        """
        pass

    def showGroupMessage(self, sender, text, metadata=None):
        print "<%s/%s> %s" % (sender, self.group.name, text)

    def setTopic(self, topic, author):
        print "-!- %s set the topic of %s to: %s" % (author, 
            self.group.name, topic)

    def memberJoined(self, member):
        basechat.GroupConversation.memberJoined(self, member)
        print "-!- %s joined %s" % (member, self.group.name)

    def memberChangedNick(self, oldnick, newnick):
        basechat.GroupConversation.memberChangedNick(self, oldnick, newnick)
        print "-!- %s is now known as %s in %s" % (oldnick, newnick,
            self.group.name)

    def memberLeft(self, member):
        basechat.GroupConversation.memberLeft(self, member)
        print "-!- %s left %s" % (member, self.group.name)


class MinChat(basechat.ChatUI):
    """
    This class is a minimal implementation of the abstract ChatUI class.

    There are only two methods that need overriding - and of those two, 
    the only change that needs to be made is the default value of the Class
    parameter.
    """

    def getGroupConversation(self, group, Class=MinGroupConversation, 
        stayHidden=0):

        return basechat.ChatUI.getGroupConversation(self, group, Class, 
            stayHidden)

    def getConversation(self, person, Class=MinConversation, 
        stayHidden=0):

        return basechat.ChatUI.getConversation(self, person, Class, stayHidden)


if __name__ == "__main__":
    from twisted.internet import reactor

    AccountManager()

    reactor.run()