Esempio n. 1
0
def process_single_line(commands: list):
    """單行查詢
    Args:
        commands: 包含查詢內容的列表
    """
    user_guide = TemplateSendMessage(
        alt_text='''電腦版無法顯示按紐,按鈕功能只是舉例,實際使用上請自行替換
                查群規: 貓 群規
                查名字: 貓 小貓貓
                查遊戲維基網址: 貓 光炮
                查遊戲內物品資料: 貓 光炮 21''',
        template=ButtonsTemplate(
            text='簡單功能介紹',
            actions=[
                MessageAction(label='查群規', text='貓 群規'),
                MessageAction(label='查名字', text='貓 小貓貓'),
                MessageAction(label='查遊戲內物品資料', text='貓 光炮 21'),
                MessageAction(label='查一段等級之間經驗',
                              text='貓 計算經驗\n光炮 1 0 21\n守衛 3 20 21')
            ]
        )
    )

    if len(commands) == 1:
        if commands[0] == '群規':
            return database.get_rules()
        if commands[0] == '執法者':
            return database.group_data['admin']
        if commands[0] == '使用說明':
            return user_guide
        try:
            name = database.correct(commands[0])
        except ValueError:
            name = commands[0]
        return generate_url(name)

    if commands[0] == '群規':
        try:
            return database.get_rules(int(commands[1]))
        except ValueError as error:
            print(error)
        return ''

    if commands[1] == '圖片':
        try:
            name = database.correct(commands[0])
        except ValueError:
            pass
        if database.item_data[name]['type'] != 'node':
            return database.get_picture(name, 0)

    try:
        name = database.correct(commands[0])
        level = int(commands[1])
        database.verify_input(name, level, level)
    except ValueError as error:
        pass
    else:
        return database.item_data[name]['data'][level]['data_string']
    return ''
Esempio n. 2
0
 def on_enter_Rebound(self, event):
     #message = TextSendMessage(text='Enter player number')
     #line_bot_api.reply_message(event.reply_token, message)
     message = TemplateSendMessage(alt_text='Confirm template',
                                   template=ConfirmTemplate(
                                       text='選擇籃板種類',
                                       actions=[
                                           MessageAction(label='進攻籃板',
                                                         text='orebound'),
                                           MessageAction(label='防守籃板',
                                                         text='drebound'),
                                       ]))
     line_bot_api.reply_message(event.reply_token, message)
Esempio n. 3
0
 def on_enter_freept(self, event):
     #message = TextSendMessage(text='Enter player number')
     #line_bot_api.reply_message(event.reply_token, message)
     message = TemplateSendMessage(alt_text='Confirm template',
                                   template=ConfirmTemplate(
                                       text='選擇是否命中',
                                       actions=[
                                           MessageAction(label='命中',
                                                         text='freeptmade'),
                                           MessageAction(label='未命中',
                                                         text='freeptmiss'),
                                       ]))
     line_bot_api.reply_message(event.reply_token, message)
Esempio n. 4
0
 def on_enter_enter_player(self, event):
     #message = TextSendMessage(text='Enter player number')
     #line_bot_api.reply_message(event.reply_token, message)
     message = TemplateSendMessage(alt_text='Buttons template',
                                   template=ButtonsTemplate(
                                       title='安安你好',
                                       text='Please select',
                                       actions=[
                                           MessageAction(label='增加球員',
                                                         text='add_player'),
                                           MessageAction(label='開始比賽',
                                                         text='game'),
                                       ]))
     line_bot_api.reply_message(event.reply_token, message)
Esempio n. 5
0
def handle_message(event):
    REPLY_TOKEN = event.reply_token
    USER_ID = PUSH_REPLY_ID = event.source.user_id
    if event.source.type == 'room':
        PUSH_REPLY_ID = event.source.room_id
    elif event.source.type == 'group':
        PUSH_REPLY_ID = event.source.group_id
    LINE_USER = LineProfile.objects.get(line_id=USER_ID)

    txt = event.message.text.strip()
    if txt == 'プロフィール':
        reply = TemplateSendMessage(
            alt_text='プロフィール',
            template=ButtonsTemplate(
                thumbnail_image_url=LINE_USER.line_icon_url,
                title=LINE_USER.line_name,
                text='hello world!',
                image_aspect_ratio='square',
                actions=[
                    MessageAction(label='ok', text='success'),
                    URIAction(
                        label='login',
                        uri='https://calliope-sample-portfolio.herokuapp.com/')
                ],
            ),
        )
    else:
        reply = [TextSendMessage(text=txt * 2)]

    line_bot_api.reply_message(REPLY_TOKEN, reply)
Esempio n. 6
0
 def on_enter_statistic(self, event):
     #message = TextSendMessage(text='Enter player number')
     #line_bot_api.reply_message(event.reply_token, message)
     message = TemplateSendMessage(alt_text='Buttons template',
                                   template=ButtonsTemplate(
                                       title='安安你好',
                                       text='Please select',
                                       actions=[
                                           MessageAction(label='兩分球出手',
                                                         text='twopt'),
                                           MessageAction(label='三分球出手',
                                                         text='threept'),
                                           MessageAction(label='罰球出手',
                                                         text='freept'),
                                           MessageAction(label='籃板球',
                                                         text='rebound'),
                                       ]))
     line_bot_api.reply_message(event.reply_token, message)
Esempio n. 7
0
 def on_enter_success_player(self, event):
     message = TemplateSendMessage(alt_text='Buttons template',
                                   template=ButtonsTemplate(
                                       text='Success',
                                       actions=[
                                           MessageAction(label='check',
                                                         text='check'),
                                       ]))
     line_bot_api.reply_message(event.reply_token, message)
Esempio n. 8
0
 def on_enter_freeptmiss(self, event):
     now = 0
     for i in range(len(player_num)):
         if player_num[i].number == CurrentPlayer[len(CurrentPlayer) -
                                                  1].number:
             player_num[i].free_miss += 1
             now = i
     print("Number %d miss free %d times" %
           (CurrentPlayer[len(CurrentPlayer) - 1].number,
            player_num[now].free_miss))
     message = TemplateSendMessage(
         alt_text='Buttons template',
         template=ButtonsTemplate(
             text="No.%d miss %d 1pt" %
             (CurrentPlayer[len(CurrentPlayer) - 1].number,
              player_num[now].free_miss),
             actions=[
                 MessageAction(label='check', text='check'),
             ]))
     line_bot_api.reply_message(event.reply_token, message)
Esempio n. 9
0
 def on_enter_DRebound(self, event):
     now = 0
     for i in range(len(player_num)):
         if player_num[i].number == CurrentPlayer[len(CurrentPlayer) -
                                                  1].number:
             player_num[i].DRebound += 1
             print(player_num[i].DRebound)
             now = i
     print("Number %d made one %d times" %
           (CurrentPlayer[len(CurrentPlayer) - 1].number,
            player_num[now].DRebound))
     message = TemplateSendMessage(
         alt_text='Buttons template',
         template=ButtonsTemplate(
             text="No.%d made %d DReb" %
             (CurrentPlayer[len(CurrentPlayer) - 1].number,
              player_num[now].DRebound),
             actions=[
                 MessageAction(label='check', text='check'),
             ]))
     line_bot_api.reply_message(event.reply_token, message)
Esempio n. 10
0
def yooka_template(event):
    a = event.message.text
    b = a.lower()
    if (b == "test"):
        line_bot_api.reply_message(event.reply_token, TextSendMessage(text=a))
    elif (b == "image carousel"):
        line_bot_api.reply_message(
            event.reply_token,
            TemplateSendMessage(
                alt_text='Image carousel template',
                template=ImageCarouselTemplate(columns=[
                    ImageCarouselColumn(image_url='https://example.com/'
                                        'item1.jpg',
                                        action=PostbackAction(
                                            label='postback1',
                                            data='action=buy&itemid=1')),
                    ImageCarouselColumn(image_url='https://example.com'
                                        '/item2.jpg',
                                        action=MessageAction(
                                            label='message2',
                                            text='message text2')),
                    ImageCarouselColumn(image_url='https://example.com/'
                                        'item3.jpg',
                                        action=URIAction(
                                            label='uri1',
                                            uri='https://example.com/1'))
                ])))
    elif (b == "lokasi unsada"):
        line_bot_api.reply_message(
            event.reply_token,
            LocationSendMessage(title='Universitas Darma Persada',
                                address='Jakarta Timur',
                                latitude=35.65910807942215,
                                longitude=139.70372892916203))
    elif (b == "konfirmasi"):
        line_bot_api.reply_message(
            event.reply_token,
            TemplateSendMessage(alt_text='Confirm template',
                                template=ConfirmTemplate(
                                    text='Are you sure?',
                                    actions=[
                                        PostbackAction(
                                            label='postback',
                                            text='postback text',
                                            data='action=buy&itemid=1'),
                                        MessageAction(label='message',
                                                      text='message text')
                                    ])))
    elif (b == "carousel"):
        line_bot_api.reply_message(
            event.reply_token,
            TemplateSendMessage(
                alt_text='Carousel template',
                template=CarouselTemplate(columns=[
                    CarouselColumn(
                        thumbnail_image_url='https://example.com/item1.jpg',
                        title='this is menu1',
                        text='description1',
                        actions=[
                            PostbackAction(label='postback1',
                                           text='postback text1',
                                           data='action=buy&itemid=1'),
                            MessageAction(label='message1',
                                          text='message text1'),
                            URIAction(label='uri1', uri='http://example.com/1')
                        ]),
                    CarouselColumn(
                        thumbnail_image_url='https://example.com/item2.jpg',
                        title='this is menu2',
                        text='description2',
                        actions=[
                            PostbackAction(label='postback2',
                                           text='postback text2',
                                           data='action=buy&itemid=2'),
                            MessageAction(label='message2',
                                          text='message text2'),
                            URIAction(label='uri2', uri='http://example.com/2')
                        ])
                ])))
    elif (b == "siapa kamu"):
        line_bot_api.reply_message(event.reply_token,
                                   TextSendMessage(text="Yooka"))
    elif (b == "question"):
        line_bot_api.reply_message(event.reply_token,
                                   TextSendMessage(text="answer"))
    else:
        line_bot_api.reply_message(
            event.reply_token,
            TextSendMessage(
                text=
                "Wah, keliatannya aku kurang paham. Coba cek Quick Menu dibawah."
            ))