-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmork.py
210 lines (172 loc) · 8.46 KB
/
mork.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
import random
import discord
import gpt_2_simple as gpt2
from discord.ext import commands
import decbot
import decbot.audio as audio
import decbot.config as config
import music
from decbot.bot.error import NoVoice, BadVoice
sess = gpt2.start_tf_sess()
gpt2.load_gpt2(sess)
offtopic = ["off-topic", "l8-night-vibe-check", "dontworrybhealthy",
"bpsfm-control"]
words = ["explosion", "detonation", "bomb", "liquid engine", "rocket engine",
"combustion", "explode"]
missile = """The missile knows where it is at all times. It knows this because it knows where it isn't. By subtracting where it is from where it isn't, or where it isn't from where it is (whichever is greater), it obtains a difference, or deviation. The guidance subsystem uses deviations to generate corrective commands to drive the missile from a position where it is to a position where it isn't, and arriving at a position where it wasn't, it now is. Consequently, the position where it is, is now the position that it wasn't, and it follows that the position that it was, is now the position that it isn't.
In the event that the position that it is in is not the position that it wasn't, the system has acquired a variation, the variation being the difference between where the missile is, and where it wasn't. If variation is considered to be a significant factor, it too may be corrected by the GEA. However, the missile must also know where it was.
The missile guidance computer scenario works as follows. Because a variation has modified some of the information the missile has obtained, it is not sure just where it is. However, it is sure where it isn't, within reason, and it knows where it was. It now subtracts where it should be from where it wasn't, or vice-versa, and by differentiating this from the algebraic sum of where it shouldn't be, and where it was, it is able to obtain the deviation and its variation, which is called error."""
class Mork(commands.Cog):
def __init__(self, bot):
self.bot = bot
self._last_member = None
self.voice = None
self.mixer = audio.Mixer()
self.music = music.Music()
def is_joined(self, member):
if not member.voice:
raise NoVoice('"{}" is not in a voice channel.'.format(member.nick))
return self.voice and self.voice.channel.id == member.voice.channel.id
async def join(self, member):
# Joining the already joined channel is a NOP.
if self.is_joined(member):
return
channel = member.voice.channel
try:
if self.voice.is_playing():
raise BadVoice('Bot is active in "{}".'.format(channel.name))
# If the bot is waiting in a valid voice channel, the voice client
# can be moved to the new channel rather than connecting anew.
await self.voice.move_to(channel)
except AttributeError:
# The voice client must be `None` or invalid; create a new one.
self.voice = await channel.connect()
async def invoke(self, text):
req = audio.Request(text)
audio.tts.convert(req)
self.mixer.enqueue(req)
req.cleanup()
if not self.voice.is_playing():
self.voice.play(self.mixer)
@commands.Cog.listener()
async def on_ready(self):
self.send_message = self.bot.get_cog('Text').send_message
if discord.opus.is_loaded():
return
path = config.get('opus')
if path:
discord.opus.load_opus(path)
if not discord.opus.is_loaded():
raise RuntimeError('Could not load libopus.')
@commands.Cog.listener()
async def on_member_join(self, member):
channel = member.guild.system_channel
if channel is not None:
await channel.send('Welcome {0.mention}.'.format(member))
@commands.Cog.listener()
async def on_message(self, message):
if message.author != self.bot.user:
if "autorouter" in message.content.lower():
await message.channel.send(
"never trust the autorouter, you are far better than the one good autorouter that's half a million dollars")
if any(substring in message.content.lower() for substring in words):
await message.channel.send(
"your friendly local three letter agency is watching")
@commands.command()
async def hello(self, ctx, *, member: discord.Member = None):
"""Says hello"""
member = member or ctx.author
if self._last_member is None or self._last_member.id != member.id:
await ctx.send(f'Hello {member.nick}')
self._last_member = member
@commands.command()
async def missile(self, ctx, *, text=None):
"""Mork will tell you about the missile or something else"""
if text:
await ctx.channel.send(missile.replace("missile", text))
else:
await ctx.channel.send(missile)
@commands.command()
async def ask(self, ctx, *, text=None):
"""Mork will answer your questions"""
length = random.randint(5, 100)
if text:
data = gpt2.generate(sess, length=length, prefix=text,
return_as_list=True)[0]
else:
data = gpt2.generate(sess, length=length, return_as_list=True)[0]
await ctx.channel.send(data)
if ctx.author.voice:
await self.join(ctx.author)
await self.invoke(data)
print("something")
@commands.command()
async def say(self, ctx, *, text: str):
""" synthesize the given text in your voice channel """
await self.join(ctx.author)
await self.invoke(text)
@commands.command()
async def quiet(self, ctx):
""" immediately stop playing any actively synthesized text """
# If the bot is not in the user's channel, silently NOP.
if not self.is_joined(ctx.author):
return
if not self.voice.is_playing():
raise BadVoice('Bot is not active.')
self.voice.stop()
@commands.command()
async def bye(self, ctx):
""" disconnect the bot from your voice channel """
# If the bot is not in the user's channel, silently NOP.
if not self.is_joined(ctx.author):
return
if self.voice.is_playing():
raise BadVoice('Bot cannot leave while speaking.')
await self.voice.disconnect()
self.voice = None
@commands.command()
async def F(self, ctx):
"""F"""
if ctx.author.voice:
await self.join(ctx.author)
await self.invoke("""[pr<600,18>][pr<200,18>][pr<1800,23>_>pr<600,18>][pr<300,23>][pr<1800,27>]
[pr<600,18>][pr<300,23>][pr<1200,27>][pr<600,18>][pr<300,23>][pr<1200,27>][pr<600,18>][pr<300,23>][pr<1800,27>]
[pr<600,23>][pr<300,27>][pr<1800,30>][pr<900,27>][pr<900,23>][pr<1800,18>]
[pr<600,18>][pr<200,18>][pr<1800,23>]""")
@commands.command(aliases=["woopsie"])
async def oopsie(self, ctx):
"""Oopsie woopsie pt1"""
if ctx.author.voice:
await self.join(ctx.author)
await self.invoke(
"""[d<1,50>]OOPSIE WOOPSIE!! [d<1,100>]Uwu We make a fucky wucky!! [d<1,150>]A wittle fucko boingo! [d<1,200>]The code monkeys at our headquarters are working VEWY HAWD to fix this!""")
@commands.group(aliases=["sing"])
async def play(self, ctx):
if ctx.invoked_subcommand is None:
await ctx.send('Invalid command passed...')
@play.command()
async def random(self, ctx, *, category=None):
"""Plays a random song. Category is optional, can be christmas, country, gospel, rock"""
await self.join(ctx.author)
song = self.music.random(category.upper())
await self.invoke(song)
await ctx.send(f"Now playing: {song.name}")
@play.command()
async def song(self, ctx, *, song):
"""Plays a song"""
await self.join(ctx.author)
song_data = self.music.play(song)
await self.invoke(song_data)
@play.command()
async def list(self, ctx):
"""Lists all songs"""
await ctx.send(
"https://gist.github.com/nmk456/a4c5b1aac419f4fd3f84491923473f1c")
with open("token.txt", 'r') as f:
token = f.readlines()[0]
client = commands.Bot(command_prefix="mork ", case_insensitive=True)
# client.add_cog(decbot.bot.Voice(client))
client.add_cog(decbot.bot.Text(client))
client.add_cog(decbot.bot.Util(client))
client.add_cog(Mork(client))
client.run(token)