Exemple #1
0
def group_chat_logging(bot, update):
    """handle text msgs in group chat. MessageHandler((Filters.text & Filters.group)"""
    log.info(log_msg(update))
    
    user_id = update.effective_user.id
    full_name = update.effective_user.full_name
    msg_len = len(update.message.text)
    msg = update.message.text
    
    Chat.create(user_id=user_id, full_name=full_name, msg_len=msg_len, msg=msg)
Exemple #2
0
def set_or_create_chat(id=-1, inited=True):
    try:
        chat = Chat.create(id=id, inited=inited)
    except:
        chat = Chat.get(id=id)
        chat.inited = inited

    chat.save()

    return chat
Exemple #3
0
    def post(self):
        _reqparse = reqparse.RequestParser()
        _reqparse.add_argument('username',
                               type=self.username_validator,
                               required=True,
                               location='json')
        _reqparse.add_argument('botname',
                               type=self.botname_validator,
                               required=True,
                               location='json')

        chat = Chat.create(**_reqparse.parse_args())
        tasks_app.send_task('tasks.start_chat', kwargs={'chat': chat})
        #tasks.start_chat.delay(chat)
        return {'chat': chat}, 201
Exemple #4
0
 def chat(self, **kwargs):
     chat_id = kwargs.pop("chat_id", None) or randint(100000, 200000)
     return Chat.create(chat_id=chat_id, **kwargs)