예제 #1
0
파일: nude.py 프로젝트: Aokrip/anastasia
 def increase(self, type_, userId_, userName_):
     cursor = self.db.find({"user.id": userId_})
     if cursor.count() == 0:
         doc = {
             "user": {
                 "id": userId_,
                 "username": userName_,
             },
             "lastUsage": int(time.time()),
             "count": {
                 "daily": 1,
                 "men": 0,
                 "women": 0
             }
         }
         log.info("Adding new user to nudes DB : " + userName_)
         doc["count"][type_] += 1
         self.db.insert_one(doc)
     else:
         doc = cursor[0]
         doc["user"]["username"] = userName_
         currentTime = int(time.time())
         doc["lastUsage"] = currentTime
         doc["count"][type_] += 1
         self.db.replace_one({"user.id": userId_}, doc)
         cursor.close()
예제 #2
0
 def choose_day(self, bot, update):
     ma = re.match("calendar-day-([0-9]+)", update.callback_query.data)
     if ma is not None:
         chat_id = update.callback_query.message.chat.id
         date = datetime.strptime(
             str(self.current_shown_dates[chat_id][0][0]) +
             str(self.current_shown_dates[chat_id][0][1]),
             '%Y%m').replace(day=int(ma.group(1)))
         try:
             todo = self.add_todo(update.callback_query.message.chat_id,
                                  update.callback_query.message.message_id,
                                  date,
                                  self.current_shown_dates[chat_id][1], bot)
         except DuplicateKeyError:
             log.info("duplicatekey for : " + str(todo))
             # erase calendar
             bot.edit_message_text("todo existant",
                                   update.callback_query.from_user.id,
                                   update.callback_query.message.message_id,
                                   reply_markup="")
         log.info("add todo : " + str(todo))
         bot.edit_message_text(str(todo["date"].strftime("%d/%m")) + " : " +
                               todo["task"],
                               update.callback_query.from_user.id,
                               update.callback_query.message.message_id,
                               reply_markup="")
예제 #3
0
 def give_todo(self, bot, update, args):
     if len(args) == 0:
         log.info("Give the todolist")
         bot.sendMessage(chat_id=update.message.chat_id,
                         text=self.all_to_do_list(update.message.chat_id))
     elif len(args) == 2 and args[0] == "-d":
         log.info("Delete " + args[1] + " to the todolist")
         self.delete_todo(update.message.chat_id, args[1])
     else:
         log.info("Bad format command")
         bot.sendMessage(chat_id=update.message.chat_id, text=self.usage())
예제 #4
0
파일: nude.py 프로젝트: Aokrip/anastasia
 def __init__(self):
     log.info(mongoda.getDB())
     self.db = mongoda.getDB().nudes
예제 #5
0
 def add_todo(self, chat_id, message_id, date, task):
     todo = {"_id": message_id, "task": task, "date": date}
     id_todo = self.todos[chat_id].insert_one(todo)
     log.info("insert id : " + str(id_todo))
     return todo
예제 #6
0
 def __init__(self):
     log.info(mongoda.getDB())
     self.current_shown_dates = {}
     self.todos = mongoda.getDB().todos