Exemple #1
0
 def add_comment(self,
                 _thing_id,
                 _content,
                 _submitted=False,
                 _signature=None):
     if _signature is None:
         _signature = self.signature
     last_id = _thing_id
     extra_len = len('\n\n--- continued below ---') + len(_signature)
     while (True):
         if len(_content) <= 0:
             return
         content_parts = _content.split('\n')
         stiched_content = ''
         for part in content_parts:
             if len(stiched_content) + len(part +
                                           '\n') + extra_len <= 10000:
                 stiched_content += part + '\n'
             else:
                 break
         row = bot_comments()
         row.thing_id = last_id
         row.submitted = _submitted
         if _content[len(stiched_content):] == '':
             row.content = stiched_content + _signature
         else:
             row.content = stiched_content + '\n\n--- continued below ---' + _signature
         session.add(row)
         session.commit()
         last_id = 'i{}'.format(
             session.query(bot_comments).order_by(desc(
                 bot_comments.id)).first().id)
         _content = _content[len(stiched_content):]
 def add_comment(self, _thing_id, _content, _submitted=False, _signature=None):
     if _signature is None:
         _signature = self.signature
     last_id = _thing_id
     extra_len = len("\n\n--- continued below ---") + len(_signature)
     while True:
         if len(_content) <= 0:
             return
         content_parts = _content.split("\n")
         stiched_content = ""
         for part in content_parts:
             if len(stiched_content) + len(part + "\n") + extra_len <= 10000:
                 stiched_content += part + "\n"
             else:
                 break
         row = bot_comments()
         row.thing_id = last_id
         row.submitted = _submitted
         if _content[len(stiched_content) :] == "":
             row.content = stiched_content + _signature
         else:
             row.content = stiched_content + "\n\n--- continued below ---" + _signature
         session.add(row)
         session.commit()
         last_id = "i{}".format(session.query(bot_comments).order_by(desc(bot_comments.id)).first().id)
         _content = _content[len(stiched_content) :]
def prepare_comment(_thing_id, _submitted, _content):
    last_id = _thing_id
    while True:
        _current_content = _content[: 10000 - len("\n\n--- continued below ---") - len(cfg_file["reddit"]["signature"])]
        if len(_content) == 0:
            return
        row = bot_comments()
        row.thing_id = last_id
        row.submitted = _submitted
        if _content[len(_current_content) :] == "":
            row.content = _current_content + cfg_file["reddit"]["signature"]
        else:
            row.content = _current_content + "\n\n--- continued below ---" + cfg_file["reddit"]["signature"]
        session.add(row)
        session.commit()
        last_id = "i" + str(session.query(bot_comments).order_by(desc(bot_comments.id)).first().id)
        _content = _content[len(_current_content) :]
def prepare_comment(_thing_id, _submitted, _content):
    last_id = _thing_id
    while(True):            
        _current_content = _content[:10000 - len('\n\n--- continued below ---') - len(cfg_file['reddit']['signature'])]
        if len(_content) == 0:
            return
        row = bot_comments()
        row.thing_id = last_id
        row.submitted = _submitted
        if _content[len(_current_content):] == '':
            row.content = _current_content + cfg_file['reddit']['signature']
        else:
            row.content = _current_content + '\n\n--- continued below ---' + cfg_file['reddit']['signature']
        session.add(row)
        session.commit()
        last_id = 'i' + str(session.query(bot_comments).order_by(desc(bot_comments.id)).first().id)
        _content = _content[len(_current_content):]