File size: 566 Bytes
ef3d4ad
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from ._citations import NoCitations

class MessageHandler:
    def __init__(self, client, citecls=None):
        self.client = client
        self.citecls = citecls or NoCitations

    def __call__(self, message):
        return '\n'.join(self.each(message))

    def each(self, message):
        refn = 1

        for m in message:
            for c in m.content:
                cite = self.citecls(c.text.annotations, self.client, refn)
                body = cite.replace(c.text.value)
                refn = len(cite) + 1

                yield f'{body}{cite}'