-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxdbot.py
157 lines (128 loc) · 3.72 KB
/
xdbot.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
import discord
from discord.ext import commands
from discord.utils import get
from random import seed
from random import randint
import datetime
bot = commands.Bot(command_prefix='~')
bot.remove_command('help')
def getToken():
tokenFile = open('TOKEN.txt','r')
tokentxt = tokenFile.read()
return tokentxt
@bot.event
async def on_ready():
print('logged in as '+str(bot.user))
#help command
@bot.command(name = "help")
async def help(ctx):
await ctx.channel.send(
'''> this bot is purely to prank those mfs who use xD way too often
> command prefix : '~'
> commands:
> test : test out specific responses
> stop : kill the bot
> ascii : convert text to ascii art''')
#testing command
@bot.command(name = "test")
async def test(ctx, arg):
i = int(arg)
await ctx.channel.send(xdRandom(i))
#programmed consent
@bot.command(name = "stop")
async def stop(ctx):
if await ctx.bot.is_owner(ctx.author):
print("close command detected, killing self :(")
await bot.close()
else:
await ctx.channel.send(death())
#ascii
@bot.command(name = "ascii")
async def ascii(ctx, arg):
print(f"converting {arg} to ascii")
try:
await ctx.channel.send(asciify(arg))
print("converted")
except Exception as e:
print(e)
@bot.command(name = "roleme")
async def roleme(ctx):
server = ctx.guild
await server.create_role(name="Bitchboy",colour=discord.Colour(0x00FFFF))
user = ctx.message.author
role = discord.utils.get(ctx.guild.roles, name = "Bitchboy")
await user.add_roles(role)
@bot.event
async def on_message(ctx):
if ctx.author != bot.user:
words = ctx.content.lower()
wordlist = words.split(' ')
if "xd" in wordlist:
await ctx.channel.send(xdRandom())
elif antiHax(words) == 1:
await ctx.channel.send(xdRandom())
elif antiHax(words) == 2:
emoji = '<:XD:699673121287962654>'
await ctx.add_reaction(emoji)
await bot.process_commands(ctx)
#random output generator
def xdRandom(i = 0):
if(i==0):
time = datetime.datetime.now()
mic = time.microsecond
seed(mic)
i = randint(1,13)
print(f'random number generated is {i}')
if(i>=1 and i<=9):
xd = open('xd_text/XD1.txt')
xd = xd.read()
xd = xd.split('\n')
return xd[i]
else:
xd = open(f"xd_text/XD{i-8}.txt")
xd = xd.read()
return xd
#antihax
def antiHax(words):
if words.find('x') != -1:
i = words.find('x')
if words[i:].find('d') != -1:
j = words[i:].find('d') + i
for ch in words[i+1:j]:
if ch.isalpha():
return 2
return 1 #wont be executed if ch.isalpha() returns false
else:
return 0
else:
return 0
#ascii converter
def asciify(phrase):
phrase = phrase.lower()
str = ""
art = open("ascii/ascii.txt",'r')
arttxt = art.read().split("$")
i = 0
while(i<10):
for ch in phrase:
if ch.isalpha():
artchar = arttxt[ord(ch)-97]
else:
artchar = arttxt[26]
artline = artchar.split("\n")
str = str + artline[i]
str = str + "\n"
i = i + 1
str = str + "\n"
str = "```" + str + "```"
return str
#death threats
def death():
time = datetime.datetime.now()
mic = time.microsecond
seed(mic)
i = randint(0,9)
death = open("death/death.txt",'r')
death = death.read().split('\n')
return death[i]
bot.run (getToken())