Exemplo n.º 1
0
    def run(self):
        update = self.update
        bot = self.bot
        
        if isDos(update): return
        
        chat_id = getID(update)
        while status.get(chat_id) == "photo_update":
            add_query_photo_lock.get(chat_id).acquire()
            add_query_photo_lock.get(chat_id).release()

        if status.get(chat_id) == "add_step2":
            status.pop(chat_id)
            update.message.reply_text('正在新增店家...')
            cur_classification = add_query_classification.get(chat_id)
            cur_shopname = add_query_shopname.get(chat_id)
            if(chat_id in add_query_photolink):
                cur_photolink = add_query_photolink.get(chat_id)
            else:
                cur_photolink = [getNoMenuLink()]
            curMD.add(cur_classification, cur_shopname, menus=cur_photolink, pushNow=True)
            update.message.reply_text('新增店家 {} 於分類 {}, 新增完成。'.format(cur_shopname, cur_classification))
        else:
            add_query_update.update({chat_id:update})
            status.update({chat_id:'add_step0'})
            update.message.reply_text("請選擇分類",
                reply_markup = InlineKeyboardMarkup([
                    [InlineKeyboardButton(s, callback_data = '{} {} {}'.format(s, chat_id, 0)) for s in list(classMap.keys())[0::2]],
                    [InlineKeyboardButton(s, callback_data = '{} {} {}'.format(s, chat_id, 0)) for s in list(classMap.keys())[1::2]]
                ]))

        appendlog(getID(update), update.message.from_user.full_name, update.message.text)
Exemplo n.º 2
0
 def run(self):
     update = self.update
     bot = self.bot
     
     if isDos(update): return
     update.message.reply_text(help_zh)
     appendlog(getID(update), update.message.from_user.full_name, update.message.text)
Exemplo n.º 3
0
    def run(self):
        update = self.update
        bot = self.bot

        if isDos(update): return
        DealWithPhotolink(update, update.message.document.file_id)
        appendlog(getID(update), update.message.from_user.full_name, 'getfile')
Exemplo n.º 4
0
 def run(self):
     update = self.update
     bot = self.bot
     
     if isDos(update): return
     chat_id = update.message.chat_id
     try:
         command, shopname, tag = update.message.text.split()
     except ValueError:
         update.message.reply_text('輸入格式為 /addtag 店家 標籤')
         return
         
     tag = '`' + tag + '`'
     list = curMD.getshops()
     Done = False
     for i in list:
         if shopname in i:
             Done = True
             tags = curMD.getTag(shopname)
             print(tags)
             if tag in tags:
                 update.message.reply_text('重複的標籤')
             else:
                 update.message.reply_text('正在新增標籤...')
                 tags.append(tag)
                 curMD.editTag(shopname, tags)
                 update.message.reply_text('在{}上新增標籤{},新增完成。'.format(shopname, tag))
             break
     if not Done:
         update.message.reply_text('無此店家')
         update.message.reply_text('可先用 /search 查詢正確名稱')
     
     appendlog(getID(update), update.message.from_user.full_name, update.message.text)
Exemplo n.º 5
0
    def run(self):
        update = self.update
        bot = self.bot

        if isDos(update): return

        chat_id = getID(update)
        status.update({chat_id: 'random'})
        add_query_update.update({chat_id: update})
        classlist = list(classMap.keys())
        classlist.append('無')
        update.message.reply_text(
            "有什麼要求嗎?",
            reply_markup=InlineKeyboardMarkup(
                [[
                    InlineKeyboardButton(s,
                                         callback_data='{} {} {}'.format(
                                             s, chat_id, 3))
                    for s in classlist[0::2]
                ],
                 [
                     InlineKeyboardButton(s,
                                          callback_data='{} {} {}'.format(
                                              s, chat_id, 3))
                     for s in classlist[1::2]
                 ]]))

        appendlog(getID(update), update.message.from_user.full_name,
                  update.message.text)
Exemplo n.º 6
0
    def run(self):
        update = self.update
        bot = self.bot
        
        if isDos(update): return
        if(not checkpermission(update)):   return

        update.message.reply_text(xhelp_en)
        
        appendlog(getID(update), update.message.from_user.full_name, update.message.text)
Exemplo n.º 7
0
    def run(self):
        update = self.update
        bot = self.bot

        if isDos(update): return
        if (not checkLowerPermission(update)): return

        update.message.reply_text("菜單修改功能實作中...")

        appendlog(getID(update), update.message.from_user.full_name,
                  update.message.text)
Exemplo n.º 8
0
    def run(self):
        update = self.update
        bot = self.bot

        if isDos(update): return

        update.message.reply_text('Bot正常運作中')
        update.message.reply_text('現在顯然有電')

        appendlog(getID(update), update.message.from_user.full_name,
                  update.message.text)
Exemplo n.º 9
0
    def run(self):
        update = self.update
        bot = self.bot

        if isDos(update): return
        update.message.reply_text('為確保資料完整性,請上傳未壓縮照片( /hint )。')
        update.message.reply_text('店家無菜單或傳送完畢請輸入 /add 結束傳送。',
                                  reply_markup=ForceReply(selective=True))
        # DealWithPhotolink(update, update.message.photo[0].file_id)
        appendlog(getID(update), update.message.from_user.full_name,
                  'getphoto')
Exemplo n.º 10
0
    def run(self):
        update = self.update
        bot = self.bot

        if isDos(update): return

        update.message.reply_text('Hello.')
        update.message.reply_text('I am just a Eating Bot.')
        update.message.reply_text(help_en)

        appendlog(getID(update), update.message.from_user.full_name,
                  update.message.text)
Exemplo n.º 11
0
    def run(self):
        update = self.update
        bot = self.bot
        
        if isDos(update): return
        if(not checkpermission(update)):   return
 
        # print('hi')
        chat_id = getID(update)
        text = 'hihi~~'    
        bot.send_message(chat_id, text)
        # update.message.reply_text(update.toString())
        appendlog(getID(update), update.message.from_user.full_name, update.message.text)
Exemplo n.º 12
0
    def run(self):
        update = self.update
        bot = self.bot

        if isDos(update): return
        if (not checkpermission(update)): return

        update.message.reply_text("備份中...")
        curMD.push(manual=True, hackmd=True)

        update.message.reply_text("手動備份完成")
        appendlog(getID(update), update.message.from_user.full_name,
                  update.message.text)
Exemplo n.º 13
0
    def run(self):
        update = self.update
        bot = self.bot
        
        if isDos(update): return
        if(not checkpermission(update)):   return

        update.message.reply_text("還原中...")
        # overwrite('filename_auto_back_up.txt')
        curData = Concat_Lines(read('filename.txt'))
        write('filename.txt', Concat_Lines(read('filename_auto_back_up.txt')))
        write('filename_auto_back_up.txt', curData)

        update.message.reply_text("以自動備份檔還原完成")

        appendlog(getID(update), update.message.from_user.full_name, update.message.text)
Exemplo n.º 14
0
    def run(self):
        update = self.update
        bot = self.bot

        if isDos(update): return
        chat_id = getID(update)

        try:
            command, keyword = update.message.text.split()
            findmenu(keyword, update)
        except:
            status.update({chat_id: 'search'})
            update.message.reply_text('請輸入店家名稱',
                                      reply_markup=ForceReply(selective=True))

        appendlog(getID(update), update.message.from_user.full_name,
                  update.message.text)
Exemplo n.º 15
0
    def run(self):
        update = self.update
        bot = self.bot

        if isDos(update): return

        text = update.message.text.split()
        if len(text) == 1:
            update.message.reply_text('請使用以下格式回報問題:\n/report 回報內容\n')
            return

        name = update.message.from_user.full_name
        chat_type = update.message.chat.type
        text = Concat_Lines(text[1:])
        append('user_report.txt',
               '{} as {}: {}\n'.format(name, chat_type, text))
        update.message.reply_text('已將您的問題回報給開發者,感謝您的使用')

        appendlog(getID(update), update.message.from_user.full_name,
                  update.message.text)
Exemplo n.º 16
0
    def run(self):
        update = self.update
        bot = self.bot

        if isDos(update): return

        chat_id = getID(update)
        if chat_id in status:
            status.pop(chat_id)
        if chat_id in add_query_shopname:
            add_query_shopname.pop(chat_id)
        if chat_id in add_query_classification:
            add_query_classification.pop(chat_id)
        if chat_id in add_query_photolink:
            add_query_photolink.pop(chat_id)
        if chat_id in add_query_update:
            add_query_update.pop(chat_id)
        update.message.reply_text("已清除您的所有要求")

        appendlog(getID(update), update.message.from_user.full_name, update.message.text)
Exemplo n.º 17
0
    def run(self):
        update = self.update
        bot = self.bot

        if isDos(update): return
        if (not checkLowerPermission(update)): return

        try:
            command, shopname = update.message.text.split()
        except:
            update.messge.reply_text('格式錯誤,正確格式為:')
            update.messge.reply_text('/delete 店家名稱')
            return

        curMD.delete(curMD.getCategory(shopname), shopname, pushNow=True)

        update.message.reply_text('店家 {} 已刪除'.format(shopname))

        appendlog(getID(update), update.message.from_user.full_name,
                  update.message.text)
Exemplo n.º 18
0
    def run(self):
        update = self.update
        bot = self.bot

        if isDos(update): return
        if (not checkpermission(update)): return

        chat_id = getID(update)

        text = update.message.text.split()
        if len(text) > 2:
            update.message.reply_text('type error.')
        elif len(text) == 2:
            if not text[1].isdecimal():
                update.message.reply_text('type error.')
            else:
                singleReport(update, int(text[1]))
        else:
            for i in range(1, 4):
                singleReport(update, i)
        appendlog(getID(update), update.message.from_user.full_name,
                  update.message.text)
Exemplo n.º 19
0
    def run(self):
        update = self.update
        bot = self.bot

        if isDos(update): return
        if (not checkpermission(update)): return

        update.message.reply_text('備份中...')

        curMD.push(hackmd=True)

        if curMD.text == requests.get(
                'https://hackmd.io/Tz5EFYy-T-Sp9LqpvJkGLg'
        ).text.split(
                '<div id="doc" class="markdown-body container-fluid" data-hard-breaks="true">'
        )[1].split('</div>')[0]:
            update.message.reply_text('備份成功')
        else:
            update.message.reply_text('備份失敗')

        appendlog(getID(update), update.message.from_user.full_name,
                  update.message.text)
Exemplo n.º 20
0
    def run(self):
        update = self.update
        bot = self.bot

        if isDos(update): return
        if (not checkpermission(update)): return

        try:
            correct, wrong = update.message.text[len('/addtypo '):].split()
        except:
            update.message.reply_text('格式錯誤,請使用格式')
            update.message.reply_text('/addtypo 正確詞 錯誤詞')
            return
        r = read("typo.json")
        if correct in r: r[correct].append(wrong)
        else: r[correct] = [wrong]
        r = str(r)
        r = r.replace("\'", "\"")
        write("typo.json", r)
        update.message.reply_text("已新增")

        appendlog(getID(update), update.message.from_user.full_name,
                  update.message.text)