Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/01/2020 in all areas

  1. 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)
    1 point
  2. Hello Helioids! Just found this service and started poking around. I'm glad HelioHost exists! Determining without command line access which python packages are available was a bit tricky. I'm documenting a solution here so it will show up for others in search. The following script is tested as working on server Johnny, under Python 3.6. Upload it to, for example, /home/USERNAME/public_html/cgi-bin/SCRIPTNAME.py. Don't forget to make it executable (chmod 755 SCRIPTNAME.py). Sending a request to that file from your browser, for example by visiting YOURSUBDOMAIN.heliohost.org/cgi-bin/SCRIPTNAME.py, will return installed module details wrapped in html that should be good enough for your browser to parse. Hope someone else finds this helpful! #!/usr/bin/python3.6 import sys import pip version = sys.version modules = pip.get_installed_distributions() print("Content-type: text/html\n\n", "Python ", version, "<br><br>") for mod in sorted(modules, key=lambda mod: mod.key): try: deets = next(pip.commands.show.search_packages_info([mod.key])) print(deets["name"], "<br>") print(deets["version"], "<br>") print(deets["summary"], "<br>") print(deets["author"], "<br>") print(deets["author-email"], "<br>") print(deets["home-page"], "<br><br>") except: print("<p>", mod.key, "</p>")
    1 point
×
×
  • Create New...