mirror of
https://gitlab.com/simple-stock-bots/simple-discord-stock-bot.git
synced 2025-08-02 11:31:26 +00:00
rename files to fit convention
This commit is contained in:
47
bot.py
Normal file
47
bot.py
Normal file
@@ -0,0 +1,47 @@
|
||||
# Work with Python 3.6
|
||||
import discord
|
||||
import re
|
||||
import urllib.request
|
||||
import json
|
||||
import tickerInfo as ti
|
||||
|
||||
TOKEN = "Discord Token"
|
||||
TICKER_REGEX = "[$]([a-zA-Z]{1,4})"
|
||||
|
||||
client = discord.Client()
|
||||
|
||||
|
||||
@client.event
|
||||
async def on_message(message):
|
||||
"""
|
||||
This runs every time a message is detected.
|
||||
"""
|
||||
|
||||
# Check that message wasnt the bot.
|
||||
if message.author == client.user:
|
||||
return
|
||||
|
||||
tickers = re.findall(TICKER_REGEX, message.content)
|
||||
if tickers is not []:
|
||||
print(tickers)
|
||||
await client.send_typing(message.channel)
|
||||
await client.send_message(message.channel, ti.tickerMessage(tickers))
|
||||
return
|
||||
|
||||
# print(message.author.id)
|
||||
|
||||
# if message.content.startswith("!hello"):
|
||||
# print(dir(message.author))
|
||||
# msg = "Hello {0.author.mention}".format(message)
|
||||
# await client.send_message(message.channel, msg)
|
||||
|
||||
|
||||
@client.event
|
||||
async def on_ready():
|
||||
print("Logged in as")
|
||||
print(client.user.name)
|
||||
print(client.user.id)
|
||||
print("------")
|
||||
|
||||
|
||||
client.run(TOKEN)
|
Reference in New Issue
Block a user