예제 #1
0
 def run(self, anon=False):
     react = Reaction(post=self.post,
                      is_like=self.is_like,
                      address=Address.new())
     if not anon:
         react.user = self.user_id
     react.save()
     self.send_message(
         TEXT_PAY.format(self.text_name, react.address.address))
     self.send_message(react.address.address)
예제 #2
0
파일: post.py 프로젝트: AHAPX/LibertatemBot
 def run(self, anon=False, forward=False):
     try:
         data = get_content(self.message)
     except ContentError as e:
         self.send.message(e)
     with config.DB.atomic() as tnx:
         try:
             content = Content.create(type=data[0],
                                      text=data[1],
                                      file_id=data[2])
             post = Post(content=content,
                         token=gen_token(),
                         address=Address.new())
             if not anon:
                 post.user = self.user_id
             if forward:
                 if self.message.forward_from:
                     self.send_message(
                         'you cannot forward messages for forward posting, write your message'
                     )
                     return (type(self), {'forward': forward})
                 post.forward_message_id = self.message.message_id
                 post.created_at = self.message.date
             post.save()
             if str(
                     self.user_id
             ) == config.ADMIN_ID and config.ADMIN_DEFAULT_BALANCE > 0 and not config.DEBUG:
                 post.send(config.ADMIN_DEFAULT_BALANCE, bot=self.bot)
                 post.address.is_accepted = True
                 post.address.save()
                 self.send_message('message posted')
             else:
                 self.send_message(TEXT_PAY.format(post.address.address))
                 self.send_message(post.address.address)
             tnx.commit()
         except Exception as e:
             logger.error(e)
             tnx.rollback()