yeee
This commit is contained in:
parent
1865506172
commit
b7c0ae49ce
1
TOKEN
1
TOKEN
@ -0,0 +1 @@
|
|||||||
|
OTg2NDA4MjM3Njg5NjMwNzYx.GfV6cT.3AywcQ7RIApTk4EAQP5nUayAoGPQxAEt79NKB8
|
||||||
69
bot.py
69
bot.py
@ -1,26 +1,46 @@
|
|||||||
#imports
|
#imports
|
||||||
import discord
|
import discord
|
||||||
|
import shelve
|
||||||
import random
|
import random
|
||||||
import configparser
|
import configparser
|
||||||
import backports.zoneinfo as zoneinfo
|
import backports.zoneinfo as zoneinfo
|
||||||
import datetime
|
import datetime
|
||||||
from datetime import time
|
|
||||||
from discord.ext import tasks, commands
|
from discord.ext import tasks, commands
|
||||||
|
|
||||||
|
|
||||||
#glob vars
|
|
||||||
quotetime = datetime.time(hour=12,tzinfo=zoneinfo.ZoneInfo("MST"))
|
quotetime = datetime.time(hour=12,tzinfo=zoneinfo.ZoneInfo("MST"))
|
||||||
|
server = "global"
|
||||||
|
avgtimelst = []
|
||||||
|
|
||||||
|
token = open("TOKEN","r").read()
|
||||||
|
intents = discord.Intents.all()
|
||||||
|
bot = commands.Bot(intents=intents,command_prefix=".")
|
||||||
|
|
||||||
|
|
||||||
#loading config files
|
#loading config files
|
||||||
botconf = configparser.ConfigParser()
|
def config(value,db="config",serverid=server,mode="r"):
|
||||||
botconf.read("config/bot.conf")
|
global = {
|
||||||
triggerbotconf = configparser.ConfigParser()
|
"replytobot":"false",
|
||||||
triggerbotconf.read("config/triggerbot.conf")
|
"triggerbotenabled":"true",
|
||||||
quotebotconf = configparser.ConfigParser()
|
"quotebotenabled":"true",
|
||||||
quotebotconf.read("config/quotebot.conf")
|
"triggerbottriggers":["hello","hi","howdy"],
|
||||||
|
"quotequeue":"1010042640508669982",
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
data = shelve.open("bot.shlf",writeback=True)
|
||||||
|
if mode == "r":
|
||||||
|
try:
|
||||||
|
return data[db][serverid][value]
|
||||||
|
except:
|
||||||
|
return global[value]
|
||||||
|
elif mode == "w":
|
||||||
|
data[db][serverid] = value
|
||||||
|
return("success")
|
||||||
|
else:
|
||||||
|
print("error")
|
||||||
|
data.close()
|
||||||
|
|
||||||
#bot info
|
#bot info
|
||||||
@bot.event
|
@bot.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
@ -43,31 +63,31 @@ async def on_message(message):
|
|||||||
#defining variables
|
#defining variables
|
||||||
msg = str(message.content)
|
msg = str(message.content)
|
||||||
channel = str(message.channel.id)
|
channel = str(message.channel.id)
|
||||||
|
server = message.guild.id
|
||||||
author = str(message.author)
|
author = str(message.author)
|
||||||
|
|
||||||
|
|
||||||
#reply to bots
|
#reply to bots
|
||||||
if message.author.bot and botconf["config"]["replytobot"] == "false":
|
if message.author.bot and config("replytobot") == "false":
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
#start event timer
|
#start event timer
|
||||||
print("\n start client.event")
|
print("\n start client.event")
|
||||||
start = time.time()
|
start = datetime.datetime.now()
|
||||||
|
|
||||||
|
|
||||||
#triggerbot
|
#triggerbot
|
||||||
if triggerbotconf["config"]["enabled"] == "true":
|
if config("triggerbotenabled") == "true":
|
||||||
x = 0
|
x = 0
|
||||||
found = "false"
|
found = "false"
|
||||||
triggersstr = (triggerbotconf["config"]["triggers"])
|
triggers = config("triggerbottriggers",db="data")
|
||||||
triggers = triggersstr.split(",")
|
|
||||||
while x < len(triggers) and found == "false":
|
while x < len(triggers) and found == "false":
|
||||||
if triggers[x] not in msg:
|
if triggers[x] not in msg:
|
||||||
x = x+1
|
x = x+1
|
||||||
elif triggers[x] in msg:
|
elif triggers[x] in msg:
|
||||||
found = "true"
|
found = "true"
|
||||||
replys = triggerbotconf["replys"][triggers[x]].split(",")
|
replys = config(triggerbotreplys,db=data)
|
||||||
rand = random.randint(0,len(replys))-1
|
rand = random.randint(0,len(replys))-1
|
||||||
await message.channel.send(replys[rand])
|
await message.channel.send(replys[rand])
|
||||||
else:
|
else:
|
||||||
@ -75,7 +95,7 @@ async def on_message(message):
|
|||||||
|
|
||||||
|
|
||||||
#daily quote
|
#daily quote
|
||||||
if channel == quotebotconf["config"]["quotequeue"] and quotebotconf["config"]["enabled"] == "true":
|
if channel == config("quotequeue") and config("quotebotenabled") == "true":
|
||||||
file = open("data/quotes.var","a")
|
file = open("data/quotes.var","a")
|
||||||
file.write(msg)
|
file.write(msg)
|
||||||
file.write(":")
|
file.write(":")
|
||||||
@ -86,18 +106,17 @@ async def on_message(message):
|
|||||||
|
|
||||||
|
|
||||||
#end function timer
|
#end function timer
|
||||||
global avgtimelst
|
end = datetime.datetime.now()
|
||||||
avgtimelst = []
|
eventime = (end - start)
|
||||||
end = time.time()
|
microseconds = eventime.microseconds
|
||||||
reventime = str(round((end - start),3))
|
avgtimelst.append(microseconds)
|
||||||
avgtimelst.append(float(reventime))
|
avgtime = sum(avgtimelst) / len(avgtimelst)
|
||||||
avgtime = str(sum(avgtimelst) / len(avgtimelst))
|
print("\n end client.event \n microseconds: " + str(microseconds) + "\n average time: " + str(avgtime))
|
||||||
print("\n end client.event \n time: " + str(reventime) + "\n average time: " + avgtime)
|
|
||||||
|
|
||||||
|
|
||||||
@tasks.loop(time=quotetime,reconnect=True)
|
@tasks.loop(time=quotetime,reconnect=True)
|
||||||
async def dailyquote():
|
async def dailyquote():
|
||||||
if quotebotconf["config"]["enabled"] == "true":
|
if config("quotebotenabled") == "true":
|
||||||
file = open("data/quotes.var","r+")
|
file = open("data/quotes.var","r+")
|
||||||
list = file.read().split(":")
|
list = file.read().split(":")
|
||||||
rand = random.randint(0, (len(list)-1))
|
rand = random.randint(0, (len(list)-1))
|
||||||
@ -108,6 +127,4 @@ async def dailyquote():
|
|||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
|
|
||||||
intents = discord.Intents.all()
|
bot.run(token)
|
||||||
bot = commands.Bot(intents=intents,command_prefix=".")
|
|
||||||
bot.run(botconf["config"]["token"])
|
|
||||||
|
|||||||
@ -6,4 +6,4 @@ August 24, 2022:A 1 billion port network switch would be longer than the contine
|
|||||||
August 31, 2022:asprin tree -person 2022:i just ran over all the rally car witnesses -peter 2022
|
August 31, 2022:asprin tree -person 2022:i just ran over all the rally car witnesses -peter 2022
|
||||||
September 13, 2022:i know my fridge isnt racist because the mold includes every color -reddit 2022
|
September 13, 2022:i know my fridge isnt racist because the mold includes every color -reddit 2022
|
||||||
September 16, 2022:no shirt no shoes no service never said anything about pants -reddit 2022:free and open horse -trail sign 2022:give em a bludgeoning with the thinkpad -person 2022
|
September 16, 2022:no shirt no shoes no service never said anything about pants -reddit 2022:free and open horse -trail sign 2022:give em a bludgeoning with the thinkpad -person 2022
|
||||||
October 4, 2022:ich bin i just kicked your ass -tf2 solder 2007:create a problem and sell a solution -apple 2022:goddamnit we have the potato salad -ian 2022:i could pull it out to show you but then i wouldnt be having a fun time -ian 2022:
|
October 4, 2022:ich bin i just kicked your ass -tf2 solder 2007:create a problem and sell a solution -apple 2022:goddamnit we have the potato salad -ian 2022:i could pull it out to show you but then i wouldnt be having a fun time -ian 2022:e:e:e:e:e:e:e:e:e:e:e:e:e:e:e:ee:e:e:e:e:e:e:e:e:e:e:e:e:e:e:ee:eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee:
|
||||||
Loading…
Reference in New Issue
Block a user