langpack.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:SoftcatalaTelegramBot 作者: Softcatala 项目源码 文件源码
def testfiles_command(self, bot, update):
        user_id = update.message.from_user.id
        if str(user_id) in allowed_users.values():
             testfiles= 0
             #TEST ANDROID FILE_ID
             f= open(paths['file_ids']+"android_file_id.txt","r")
             fandroid= f.read(32)
             f.close()
             r = requests.get('https://api.telegram.org/bot' + params['token'] + '/getFile?file_id=' + fandroid)
             output= r.json()
             if output['ok']:
                   testandroid= ''
             else:
                   testfiles+= 1
                   testandroid= '    \U0001F6AB *Android*\n'
             #TEST IOS FILE_ID
             f= open(paths['file_ids']+"ios_file_id.txt","r")
             fios= f.read(32)
             f.close()
             r = requests.get('https://api.telegram.org/bot' + params['token'] + '/getFile?file_id=' + fios)
             output= r.json()
             if output['ok']:
                   testios= ''
             else:
                   testfiles+= 1
                   testios= '    \U0001F6AB *iOS*\n'
             #TEST TELEGRAM DESKTOP FILE_ID
             f= open(paths['file_ids']+"tdesktop_file_id.txt","r")
             ftdesktop= f.read(32)
             f.close()
             r = requests.get('https://api.telegram.org/bot' + params['token'] + '/getFile?file_id=' + ftdesktop)
             output= r.json()
             if output['ok']:
                   testtdesktop= ''
             else:
                   testfiles+= 1
                   testtdesktop= '    \U0001F6AB *Telegram Desktop*\n'
             if testfiles == 0:
                 bot.sendMessage(update.message.from_user.id,
                      parse_mode='Markdown',
                      text= "Els *file_id* dels tres fitxers són correctes.\nNo hi ha *cap* error.")
             elif testfiles > 0:
                 bot.sendMessage(update.message.from_user.id,
                      parse_mode='Markdown',
                      text= "Errors als *file_id* dels paquets de llengua: " +str(testfiles) + "\n  Fallen els paquets:\n" + testandroid + testios + testtdesktop)

        elif function['production']:
            f_name = update.message.from_user.first_name
            bot.sendMessage(
            update.message.chat_id,
            text= str(f_name) + ", no teniu permisos per utilitzar aquesta ordre. Les ordres que teniu disponibles ara mateix són: /baixa /android /ios /tdesktop i /help.",
            reply_markup=ReplyKeyboardHide()
            )
        else:
            bot.sendMessage(
            update.message.chat_id,
            text="Robot destinat a proves internes de Softcatalà. Si cerqueu el bot públic de Softcatalà el trobareu a @SoftcatalaBot.",
            reply_markup=ReplyKeyboardHide()
            )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号