29 lines
761 B
Python
29 lines
761 B
Python
import queue
|
|
import importlib
|
|
import asyncio
|
|
discordThread = importlib.import_module("discord-thread")
|
|
token = ""
|
|
with open("token.txt") as f:
|
|
token = f.read()
|
|
discordThread.run(token)
|
|
|
|
def main():
|
|
try:
|
|
while True:
|
|
try:
|
|
output = discordThread.outQueue.get(True,1)
|
|
if output[0] == "message":
|
|
message = output[1]
|
|
if message.author.id == discordThread.thread.client.user.id:
|
|
if message.content == "/hello":
|
|
future = asyncio.run_coroutine_threadsafe(
|
|
message.channel.send("hello world"),
|
|
discordThread.thread.loop)
|
|
|
|
print(str(output))
|
|
except queue.Empty:
|
|
pass
|
|
except KeyboardInterrupt:
|
|
future = asyncio.run_coroutine_threadsafe(discordThread.thread.stop(),discordThread.thread.loop)
|
|
|
|
main() |