Jump to content

sb7064

Members
  • Posts

    2
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by sb7064

  1. I tried but It not works too.

     


     

    My python bot in cgi-bin occurs internal server error but i can't figure out what is wrong.
    I set permission as 755, and uploaded all lib files at same folder.
    It works on my pc and online python IDE(lepi) but not on here.
     
    *this code also causes same error

    #!/usr/bin/python3.7
    print("test")
    

    CGI is different from running python scripts on the command line, because you have to output a header. Without a content-type header your script will always give a 500 error. Try this code:

    #!/usr/bin/python3.7
    
    print("Content-Type: text/html\n\n")
    print("HelioHost rules!")
    
  2. My python bot in cgi-bin occurs internal server error but i can't figure out what is wrong.

    I set permission as 755, and uploaded all lib files at same folder.

    It works on my pc and online python IDE(lepi) but not on here.

     

    *this code also causes same error

    #!/usr/bin/python3.7
    print("test")
    

    This is my bot code

    #!/usr/bin/python3.7
    import asyncio
    import discord
    import time
    from parse import *
    
    client = discord.Client()
    remCount = 0
    remHList = []
    remMList = []
    remTList = []
    channelList = []
    isRemindRunning = 0
    
    # 생성된 토큰을 입력해준다.
    token = DISCORD_TOKEN
    
    # 봇이 구동되었을 때 보여지는 코드
    @client.event
    async def on_ready():
        print("다음으로 로그인합니다")
        print(client.user.name)
        print(client.user.id)
        print("================")
        await remind()
    
    # 봇이 특정 메세지를 받고 인식하는 코드
    @client.event
    async def on_message(message):
        # 메세지를 보낸 사람이 봇일 경우 무시한다
        if message.author.bot:
            return None
    
        if message.content.startswith('!알림'):
            global remCount
            global isRemindRunning
            print(message.content)
            text = parse("!알림 {}:{} {}",message.content)
            print(text)
            channel = message.channel
            hour = (int(text[0])-9)%24
            remHList.append(hour)
            remMList.append(int(text[1]))
            remTList.append(text[2])
            channelList.append(channel)
            remCount = remCount+1
            now = time.localtime()
            await channel.send('Reminds '+text[2]+' at '+text[0]+':'+text[1])
    
        elif message.content.startswith('!예약'):
            print(message.content)
            text = parse("!예약 {}:{} {}",message.content)
            print(text)
            channel = message.channel
            hour = (int(text[0])-9)%24
            remHList.append(hour)
            remMList.append(int(text[1]))
            remTList.append(text[2])
            channelList.append(channel)
            remCount = remCount+1
            await channel.send('Reminds '+text[2]+' at '+text[0]+':'+text[1])
            return
    
        elif message.content.startswith('!remind'):
            print(message.content)
            text = parse("!remind {}:{} {}",message.content)
            print(text)
            channel = message.channel
            hour = (int(text[0])-9)%24
            remHList.append(hour)
            remMList.append(int(text[1]))
            remTList.append(text[2])
            channelList.append(channel)
            remCount = remCount+1
            await channel.send('Reminds '+text[2]+' at '+text[0]+':'+text[1])
            return
    
        elif message.content.startswith('!목록'):
            if remCount == 0:
                await message.channel.send('Reminder list is empty')
                return
            text = ""
            for i in range(0,remCount):
                text = text+str(i+1)+':  '+ remTList[i]+' at '+str((remHList[i]+9)%24)+':'+str(remMList[i])+'\n'
            await message.channel.send(text)
    
        elif message.content.startswith('!list'):
            if remCount == 0:
                await message.channel.send('Reminder list is empty')
                return
            text = ""
            for i in range(0,remCount):
                text = text+str(i+1)+':  '+ remTList[i]+' at '+str((remHList[i]+9)%24)+':'+str(remMList[i])+'\n'
            await message.channel.send(text)
    
        elif message.content.startswith('!clear'):
            for i in range(0,remCount):
                remHList.pop(i)
                remMList.pop(i)
                remTList.pop(i)
                channelList.pop(i)
            remCount = 0
            await message.channel.send('All Reminders deleted.')
    
        elif message.content.startswith('!초기화'):
            for i in range(0,remCount):
                remHList.pop(i)
                remMList.pop(i)
                remTList.pop(i)
                channelList.pop(i)
            remCount = 0
            await message.channel.send('모든 리마인더 삭제 완료')
            
    @client.event
    async def remind():
        global remCount
        global isRemindRunning
        while True:
            await asyncio.sleep(10)
            now = time.localtime()
            print('Checking Reminders at '+str(now.tm_hour)+':'+str(now.tm_min)+':'+str(now.tm_sec))
            for i in range(0,remCount):   
                if now.tm_hour==remHList[i] and now.tm_min==remMList[i]:
                    await channelList[i].send(remTList[i],tts=True)
                    print('Sent reminder '+remTList[i])
                    remHList.pop(i)
                    remMList.pop(i)
                    remTList.pop(i)
                    channelList.pop(i)
                    remCount = remCount-1
                    break         
        
    
    client.run(token)
    
    • Like 1
×
×
  • Create New...