-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiscord_server.py
33 lines (26 loc) · 908 Bytes
/
discord_server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python3
import discord
import random
from ws_client import Client
token = open('token.priv','r').readline()
bot_client = discord.Client()
@bot_client.event
async def on_ready():
print('Logged in as')
print(bot_client.user.name)
print(bot_client.user.id)
print('------')
@bot_client.event
async def on_message(message):
if message.author == bot_client.user: return
# book command
if message.content.startswith('!book'):
print ("Called by " + message.author)
await bot_client.send_message(message.channel, 'The daily book today is:')
web_scrapping_client = Client()
web_scrapping_client.run()
await bot_client.send_file(message.channel, 'book_cover.jpg')
book_info = open("book_info.txt", "r")
for line in book_info:
await bot_client.send_message(message.channel, line)
bot_client.run(token)