Add files via upload
This commit is contained in:
parent
d0f8639e0c
commit
fc5d67a855
97
1.2.5/bot.py
Normal file
97
1.2.5/bot.py
Normal file
@ -0,0 +1,97 @@
|
||||
import discord
|
||||
import time
|
||||
import datetime
|
||||
import configparser
|
||||
import random
|
||||
from discord.ext import tasks, commands
|
||||
intents = discord.Intents.all()
|
||||
client = discord.Client(intents=intents)
|
||||
avgtimelst = []
|
||||
print("discord.py version")
|
||||
print(discord.__version__)
|
||||
|
||||
|
||||
#loading config files
|
||||
botconf = configparser.ConfigParser()
|
||||
botconf.read("config/bot.conf")
|
||||
triggerbotconf = configparser.ConfigParser()
|
||||
triggerbotconf.read("config/triggerbot.conf")
|
||||
quotebotconf = configparser.ConfigParser()
|
||||
quotebotconf.read("config/quotebot.conf")
|
||||
|
||||
|
||||
#bot info
|
||||
@client.event
|
||||
async def on_ready():
|
||||
print('We have logged in as {0.user}'.format(client))
|
||||
if not dailyquote.is_running():
|
||||
dailyquote.start()
|
||||
|
||||
|
||||
#main event
|
||||
@client.event
|
||||
async def on_message(message):
|
||||
#defining variables
|
||||
msg = str(message.content)
|
||||
channel = str(message.channel.id)
|
||||
author = str(message.author)
|
||||
|
||||
|
||||
#reply to bots
|
||||
if message.author.bot and botconf["config"]["replytobot"] == "false":
|
||||
return
|
||||
|
||||
|
||||
#start event timer
|
||||
print("\n start client.event")
|
||||
start = time.time()
|
||||
|
||||
|
||||
#triggerbot
|
||||
if triggerbotconf["config"]["enabled"] == "true":
|
||||
x = 0
|
||||
found = "false"
|
||||
triggersstr = (triggerbotconf["config"]["triggers"])
|
||||
triggers = triggersstr.split(",")
|
||||
while x < len(triggers) and found == "false":
|
||||
if triggers[x] not in msg:
|
||||
x = x+1
|
||||
elif triggers[x] in msg:
|
||||
found = "true"
|
||||
replys = triggerbotconf["replys"][triggers[x]].split(",")
|
||||
rand = random.randint(0,len(replys))-1
|
||||
await message.channel.send(replys[rand])
|
||||
else:
|
||||
print("something happened")
|
||||
|
||||
|
||||
#daily quote
|
||||
if channel == quotebotconf["config"]["quotequeue"] and quotebotconf["config"]["enabled"] == "true":
|
||||
file = open("data/quotes.var","a")
|
||||
file.write(msg)
|
||||
file.write(":")
|
||||
file.close()
|
||||
|
||||
|
||||
#end function timer
|
||||
end = time.time()
|
||||
reventime = str(round((end - start),3))
|
||||
avgtimelst.append(float(reventime))
|
||||
avgtime = str(sum(avgtimelst) / len(avgtimelst))
|
||||
print("\n end client.event \n time: " + str(reventime) + "\n average time: " + avgtime)
|
||||
|
||||
|
||||
@tasks.loop(seconds=5,reconnect=True)
|
||||
async def dailyquote():
|
||||
if quotebotconf["config"]["enabled"] == "true":
|
||||
file = open("data/quotes.var","r+")
|
||||
list = file.read().split(":")
|
||||
rand = random.randint(0, (len(list)-1))
|
||||
print(rand)
|
||||
channel = client.get_channel(int(quotebotconf["config"]["dailyquote"]))
|
||||
await channel.send(list[rand])
|
||||
list.remove(rand)
|
||||
file.write(list)
|
||||
|
||||
|
||||
client.run(botconf["config"]["token"])
|
||||
7
1.2.5/config/bot.conf
Normal file
7
1.2.5/config/bot.conf
Normal file
@ -0,0 +1,7 @@
|
||||
[config]
|
||||
token = OTg2NDA4MjM3Njg5NjMwNzYx.Gn3sV3.af4MeWrAct-e6FyN6oDWt-QaOfOHuYBY97Vw7k
|
||||
replytobot = false
|
||||
|
||||
[modules]
|
||||
triggerbot = "true"
|
||||
quotebot = "true"
|
||||
4
1.2.5/config/quotebot.conf
Normal file
4
1.2.5/config/quotebot.conf
Normal file
@ -0,0 +1,4 @@
|
||||
[config]
|
||||
enabled = true
|
||||
quotequeue = 1010042640508669982
|
||||
dailyquote = 1004178748205187086
|
||||
8
1.2.5/config/triggerbot.conf
Normal file
8
1.2.5/config/triggerbot.conf
Normal file
@ -0,0 +1,8 @@
|
||||
[config]
|
||||
enabled = true
|
||||
blacklist = 1234567890,0987654321 #blacklisted channels
|
||||
triggers = hello,howdy
|
||||
[replys]
|
||||
hello = hello,hi
|
||||
howdy = howdy
|
||||
|
||||
1
1.2.5/data/quotes.var
Normal file
1
1.2.5/data/quotes.var
Normal file
@ -0,0 +1 @@
|
||||
joe mama -ian:joe mama -eric:avergae man -peter:hello:a:a:a:a:a:a:a:a:a:hello:hello:
|
||||
10
1.2.5/test
Normal file
10
1.2.5/test
Normal file
@ -0,0 +1,10 @@
|
||||
import schedule
|
||||
import time
|
||||
def test():
|
||||
print("deez")
|
||||
schedule.every(1).minutes.do(test)
|
||||
while 1 == 1:
|
||||
print("joe")
|
||||
time.sleep(5)
|
||||
schedule.run_pending()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user