mirror of
https://github.com/MrDetonia/Maki.git
synced 2024-11-22 03:44:18 -05:00
v0.19.0 added quiet mode
This commit is contained in:
parent
f944fad7ea
commit
c59eaf0a01
14
bot.py
14
bot.py
@ -31,7 +31,7 @@ from secret import token, lfmkey
|
|||||||
# CONFIGURATION
|
# CONFIGURATION
|
||||||
|
|
||||||
# bot version
|
# bot version
|
||||||
version = "v0.18.1"
|
version = "v0.19.0"
|
||||||
|
|
||||||
# text shown by .help command
|
# text shown by .help command
|
||||||
helptext = """I am a Discord bot written in Python
|
helptext = """I am a Discord bot written in Python
|
||||||
@ -64,6 +64,9 @@ if os.path.isfile('hist.json'):
|
|||||||
with open('hist.json', 'r') as fp:
|
with open('hist.json', 'r') as fp:
|
||||||
history = json.load(fp)
|
history = json.load(fp)
|
||||||
|
|
||||||
|
# quiet modes
|
||||||
|
quiet = {}
|
||||||
|
|
||||||
# this instance of the Discord client
|
# this instance of the Discord client
|
||||||
client = discord.Client()
|
client = discord.Client()
|
||||||
|
|
||||||
@ -337,6 +340,13 @@ def on_message(message):
|
|||||||
# send response
|
# send response
|
||||||
response = out.decode('utf-8').strip()
|
response = out.decode('utf-8').strip()
|
||||||
|
|
||||||
|
elif message.content.startswith('.quiet'):
|
||||||
|
quiet[message.server.id] = 1
|
||||||
|
|
||||||
|
elif message.content.startswith('.loud'):
|
||||||
|
if message.server.id in quiet:
|
||||||
|
quiet.pop(message.server.id, None)
|
||||||
|
|
||||||
# Stuff that happens when message is not a bot command:
|
# Stuff that happens when message is not a bot command:
|
||||||
else:
|
else:
|
||||||
# log each message against users
|
# log each message against users
|
||||||
@ -363,7 +373,7 @@ def on_message(message):
|
|||||||
yield from client.add_reaction(message, '\N{PERSON WITH FOLDED HANDS}')
|
yield from client.add_reaction(message, '\N{PERSON WITH FOLDED HANDS}')
|
||||||
|
|
||||||
# send response to channel if needed:
|
# send response to channel if needed:
|
||||||
if response is not '':
|
if response is not '' and message.server.id not in quiet:
|
||||||
for attempt in range(5):
|
for attempt in range(5):
|
||||||
try:
|
try:
|
||||||
yield from client.send_message(message.channel, response)
|
yield from client.send_message(message.channel, response)
|
||||||
|
Loading…
Reference in New Issue
Block a user