-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
92 lines (67 loc) · 2.97 KB
/
main.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
#!/usr/bin/env python3
# Copyright (C) 2020-2021 Joshua Peisach <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
import datetime
import logging
import discord
from discord.utils import get
import memes
# Bot
client = discord.Client()
prefix = "uc!"
token = open('./token.txt').read()
# Our Ubuntu Cinnamon Orange Embed Colour
ubuntucinnamon = (221, 104, 42)
# Time, for logging and such
time = datetime.datetime.now()
current_time = time.strftime("%H:%M:%S")
# For our Memes, a list of commands that will trigger memes.
# Obviously this is subject to change here.
memecmds = ['uc!simonsfault']
@client.event
async def on_connect():
print('[' + current_time + '] Bot online with a username of [username] and operating in [server number] servers.')
async def log_message(msg):
# Reinitialize these variables or the time will be the same as the start time
logtime = datetime.datetime.now()
current_logtime = logtime.strftime("%H:%M:%S")
print("[" + current_logtime + "] #" + msg.channel.name + " " + msg.author.name + ": " + msg.content)
channel = client.get_channel(734439066681999449)
await channel.send(
"[" + current_logtime + "] #" + msg.channel.name + " " + msg.author.name + ": " + msg.content)
logging.basicConfig(filename='./logs.txt', level=logging.INFO)
logging.info("[" + current_logtime + "] #" + msg.channel.name + " " + msg.author.name + ": " + msg.content)
@client.event
async def on_message(msg):
if msg.author == client.user:
return
await log_message(msg)
if not msg.content.startswith(prefix):
return
msg.content.lower()
pingid = "<@!" + str(msg.author.id) + ">"
if msg.content == "uc!ping":
await msg.channel.send(pingid + ", :ping_pong: Pong! {0} ms".format(round(client.latency, 1)))
if msg.content == "uc!notifications":
notificationsrole = get(msg.author.guild.roles, name="Notifications")
await msg.author.add_roles(notificationsrole)
await msg.channel.send(":white_check_mark: " + "<@!" + pingid + ">, Sucessfully added Notifications role!")
if msg.content in memecmds:
await memes.on_meme_message(msg)
print('[' + current_time + '] Beginning startup of Discord Bot.')
print('[' + current_time + '] Starting Discord Client Connection.')
client.run(token)