Beispiel #1
0
def pybot(command, image=None):
    response = ''
    try:
        for key in bot_dict:
            if key in command:
                response = bot_dict[key]
                break

            if '平成' in command:
                response = heisei_command(command)
            if '長さ' in command:
                response = len_command(command)
            if '干支' in command:
                response = eto_command(command)
            if '選ぶ' in command:
                response = choice_command(command)
            if 'さいころ' in command:
                response = dice_command()
            if '今日' in command:
                response = today_command()
            if '現在' in command:
                response = now_command()
            if '曜日' in command:
                response = weekday_command(command)
            if '合計' in command:
                response = sum_command(command)

        if not response:
            response = '何ヲ言ッテルカ、ワカラナイ'
        return response

    except Exception as e:
        print('予期セヌ エラーガ 発生シマシタ')
        print('* 種類:', type(e))
        print('* 内容:', e)
Beispiel #2
0
def pybot(command):
    #command = input('pybot> ')
    reponse = ''
    try:
        """
        #print(command)
        if 'こんにちは' in command:
            print('コンニチハ')
        elif 'ありがとう' in command:
            print('どういたしまして')
        elif 'さようなら' in command:
            print('サヨウナラ')
            break
        else:
            print('何を言っているか、わかりません')
        """
        for key in bot_dict:
            if key in command:
                reponse = bot_dict[key]
                break

        if '平成' in command:
            reponse = heisei_command(command)
            """
            heisei, year_str = command.split()
            year = int(year_str)
            if year >= 1989:
                heisei_year = year - 1988
                reponse = '西暦{}年は平成{}年です'.format(year, heisei_year)
            else:
                reponse = '西暦{}年は、平成ではありません。'.format(year)
            """
        if '長さ' in command:
            reponse = length_command(command)
        if '選ぶ' in command:
            reponse = choice_command(command)
        if 'さいころ' in command:
            reponse = dice_command()
        if '今日' in command:
            reponse = today_command()
        if '現在' in command:
            reponse = now_command()
        if '曜日' in command:
            reponse = weekday_command(command)
        if '天気' in command:
            reponse = weather_command()
        if '辞典' in command:
            reponse = wikipedia_command(command)
        if not reponse:
            reponse = '何をいっているか、わからない'

        return reponse
        """    
        if 'さようなら' in command:
            break;
        """
    except Exception as e:
        print('予期せぬエラーが発生しました。')
        print('*種類:', type(e))
        print('内容:', e)
Beispiel #3
0
def pybot(command):
    #    command = input('pybot> ')
    response = ''
    try:
        for key in bot_dict:
            if key in command:
                response = bot_dict[key]
                break

        if '平成' in command:
            response = heisei_command(command)
        if '干支' in command:
            response = eto_command(command)
        if '選ぶ' in command:
            response = choice_command(command)
        if 'さいころ' in command:
            response = dice_command()
        if '曜日' in command:
            response = weekday_command(command)
        #仮想環境で外部パッケージ(requests)を使用
        if '天気' in command:
            response = weather_command()

        if not response:
            response = '何言ってるかわからない'
        return response

        #if "さようなら" in command:
        #    break
    except Exception as e:
        print('予期せぬエラーが発生しました')
        print('* 種類', type(e))
        print('* 内容', e)
def pybot(command):
    # command = input('pybot >')
    response = ''
    try:
        for message in bot_dict:
            if message in command:
                response = bot_dict[message]
                break

        if '平成' in command:
            response = heisei_command(command)

        if '長さ' in command:
            response = len_command(command)

        if '干支' in command:
            response = eto_command(command)

        if '選ぶ' in command:
            response = choice_command(command)

        if 'さいころ' in command:
            response = dice_command()

        if '今日' in command:
            response = today_command()

        if '現在' in command:
            response = now_command()

        if '曜日' in command:
            response = weekday_command(command)

        if '天気' in command:
            response = weather_command()

        if '事典' in command:
            response = wikipedia_command(command)

        if not response:
            response = '何を言っているか分からない'
        return response

        # if 'さようなら' in command:
        #     break
    except Exception as e:
        print('予期せぬエラーが発生しました')
        print('*種類:', type(e))
        print('*種類:', e)
Beispiel #5
0
def pybot(command):
    # command = input("pybot> ")
    response = ""
    try:

        for messege in bot_dict:
            if messege in command:
                response = bot_dict[messege]
                break

        if "和暦" in command:
            response = wareki_command(command)

        if "干支" in command:
            response = eto_command(command)

        if "選ぶ" in command:
            response = choice_command(command)

        if "さいころ" in command:
            response = dice_command(command)

        if "今日" in command:
            response = today_command()

        if "現在" in command:
            response = now_command()

        if "曜日" in command:
            response = weekday_command(command)

        if "平方根" in command:
            response = sqrt_command(command)

        if "イベント" in command:
            response = event_command(command)

        if "辞典" in command:
            response = wikipedia_command(command)

        if not response:
            response = "ナニヲイッテイルカワカラナイ"
        return response

        # if "さようなら" in command:
        #    break
    except Exception as e:
        print("予期せぬエラーが発生しました")
Beispiel #6
0
def pybot(command):
    # command = input('pybot> ');
    response = ''
    try:
        for message in bot_dict:
            if message in command:
                response = bot_dict[message]
                break

        if '平成' in command:
            response = heisei_command(command)
        if '長さ' in command:
            response = len_command(command)
        if '干支' in command:
            response = eto_command(command)
        if '選ぶ' in command:
            response = choice_command(command)
        if 'さいころ' in command:
            response = dice_command()
        if '今日' in command:
            response = today_command()
        if '現在' in command:
            response = now_command()
        if '曜日' in command:
            response = weekday_command(command)
        if '天気' in command:
            response = weather_command()
        if '事典' in command:
            response = wikiedia_command(command)

        if not response:
            response = 'ヨクワカリマセン'

        return response

        # if 'さようなら' in command:
        #    break;

    except Exception as e:
        print('予期セヌ エラーガ 発生シマシタ')
        print('* 種類:', type(e))
        print('* 内容:', e)
Beispiel #7
0
def pybot(command):
    # command = input('pybot> ')
    response = ''
    try:
        for key in bot_dict:
            if key in command:
                response = bot_dict[key]
                break

        if '平成' in command:
            response = heisei_command(command)
        if '長さ' in command:
            response = len_command(command)
        if '干支' in command:
            response = eto_command(command)
        if '選ぶ' in command:
            response = choice_command(command)
        if 'サイコロ' in command:
            response = dice_command()
        if '今日' in command:
            response = today_command()
        if '現在' in command:
            response = now_command()
        if '曜日' in command:
            response = weekday_command(command)
        if '天気' in command:
            response = weather_command()
        if '辞典' in command:
            response = wikipedia_command(command)

        if not response:
            response = 'ナニヲイッテイルノカワカラナイ'
        return response

        # if 'さようなら' in command:
        #     break
    except Exception as e:
        print('予期せぬエラーが発生しました')
        print('* 種類:', type(e))
        print('* 内容:', e)
Beispiel #8
0
def pybot(command):
    #command = input('pybot> ')
    response = ''
    try:
        for key in bot_dict:
            if key in command:
                response = bot_dict[key]
                break

        if '平成' in command:
            response = heisei_command(command)
        if '長さ' in command:
            response = len_command(command)
        if '干支' in command:
            response = eto_command(command)
        if '選ぶ' in command:
            response = choice_command(command)
        if 'さいころ' in command:
            response = dice_command()
        if '今日' in command:
            response = today_command()
        if '現在' in command:
            response = now_command()
        if '曜日' in command:
            response = weekday_command(command)
        if '天気' in command:
            response = weather_command()
        if '辞典' in command:
            response = wikipedia_command(command)

        if not response:
            response = '何ヲ言ッテルカ、ワカラナイ'
        return response

        #if 'さようなら' in command:
        #    break
    except Exception as e:
        print('予期セヌ エラーガ 発生シマシタ')
        print('* 種類', type(e))
        print('* 内容', e)
Beispiel #9
0
def pybot(command):
    # command = input('pybot> ')
    response = ''
    try:
        for message in bot_dict:
            if message in command:
                response = bot_dict[message]
                break

        if '和暦' in command:
            response = wareki_command(command)
        if '長さ' in command:
            response = len_command(command)
        if '干支' in command:
            response = eto_command(command)
        if '選ぶ' in command:
            response = choice_command(command)
        if 'さいころ' in command:
            response = dice_command()
        if '今日' in command:
            response = today_command()
        if '現在' in command:
            response = now_command()
        if '曜日' in command:
            response = weekday_command(command)
        if 'イベント' in command:
            response = event_command(command)
        if '事典' in command:
            response = wikipedia_command(command)

        if not response:
            response = '何ヲ言ッテルカ、ワカラナイ'
        return response

        # if 'さようなら' in command:
        #     break
    except Exception as e:
        print('予期セヌ エラーガ 発生シマシタ')
        print(f'* 種類: {type(e)}')
        print(f'* 内容: {e}')
Beispiel #10
0
        response = ""
        for key in bot_dict:
            if key in command:
                response = bot_dict[key]
                break

        if '平成' in command:
            response = heisei_command(command)
        if '長さ' in command:
            response = len_command(command)
        if '干支' in command:
            response = eto_command(command)
        if '選ぶ' in command:
            response = choice_command(command)
        if 'さいころ' in command:
            response = dice_command()
        if '今日' in command:
            response = today_command()
        if '現在' in command:
            response = now_command()
        if '曜日' in command:
            response = weekday_command(command)
        if '天気' in command:
            response = weather_command()
        if '事典' in command:
            response = wikipedia_command(command)

        if not response:
            response = '何ヲ言ッテルカ、ワカラナイ'
        print(response)
Beispiel #11
0
    try:
        for key in bot_dict:
            if key in command:
                responce = bot_dict[key]
                break

        if '平成' in command:
            responce = heisei_command(command)
        if '長さ' in command:
            responce = len_command(command)
        if '干支' in command:
            responce = eto_command(command)
        if '選ぶ' in command:
            responce = choice_command(command)
        if 'さいころ' in command:
            responce = dice_command(command)
        if '今日' in command:
            responce = today_command()
        if '現在' in command:
            responce = now_command()

        if not responce:
            responce = '何ヲ言ッテルカ、ワカラナイ'
        print(responce)

        if 'さようなら' in command:
            break
    except Exception as e:
        print('予期セヌ エラーガ 発生シマシタ')
        print('* 種類:', type(e))
        print('* 内容:', e)
Beispiel #12
0
def bot(command):
    #command = input("pybot> ")
    response = ""
    try:
        for key in bot_dict:
            if key in command:
                response = bot_dict[key]
                break

            if "意味" in command:
                response = wikipedia_command(command)
            if "長さ" in command:
                response = len_moji(command)

            if "干支" in command:
                response = eto_command(command)

            if "元号" in command:
                response = gengo_calculater(command)

            if "heisei" in command:
                response = heisei_calculater(command)
            if "平成" in command:
                response = heisei_calculater(command)

            if "reiwa" in command:
                response = reiwa_calculater(command)
            if "令和" in command:
                response = reiwa_calculater(command)

            if "昭和" in command:
                response = showa_calculater(command)
            if "showa" in command:
                response = showa_calculater(command)

            if "サイコロ" in command:
                response = dice_command()
            if "さいころ" in command:
                response = dice_command()
            if "dice" in command:
                response = dice_command()

            if "選ぶ" in command:
                response = choice_command(command)

            if "今日" in command:
                response = today_command()
            if "today" in command:
                response = today.command()

            if "現在" in command:
                response = now_command()
            if "now" in command:
                response = now_command()

            if "曜日" in command:
                response = weekday_command(command)
            if "weekday" in command:
                response = weekday_command(command)

            if "天気" in command:
                response = weather_command()
            if "weather" in command:
                response = weather_command()

            if '平均値' in command:
                response = heikin(command)

            if '中央値' in command:
                response = chuo_ti(command)

        if not response:
            response = "何言ってるかわからん\(^o^)/オワタ\nこれから勉強します(^^♪"
            output_file = open("new_word.txt", "a", encoding="utf-8")
            output_file.write("{}\n".format(command))
            output_file.close()
        return response

    except Exception as e:
        print("予期せぬエラーが発生しました。")
        print("* 種類:", type(e))
        print("* 内容:", e)
        error_file = open("error.txt", "a", encoding="utf-8")
        error_file.write("種類:{} 内容{}\n".format(type(e), e))
        error_file.close()