initial version of colcall bot
- basic student information for preferred names - simple discord bot - coldcall library to maintain records and choose folks
This commit is contained in:
43
coldcallbot.py
Normal file
43
coldcallbot.py
Normal file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from coldcall import ColdCall
|
||||
import re
|
||||
import discord
|
||||
|
||||
## create the coldcall object
|
||||
cc = ColdCall()
|
||||
|
||||
class ColdCallBot (discord.Client):
|
||||
async def on_ready(self):
|
||||
print(f'Logged on as {self.user}! Ready for class!')
|
||||
|
||||
async def on_message(self, message):
|
||||
if message.author == self.user:
|
||||
return
|
||||
|
||||
if message.content.startswith('$next'):
|
||||
classroom = discord.utils.get(message.guild.voice_channels, name='Classroom Voice')
|
||||
|
||||
present_students = []
|
||||
for member in classroom.members:
|
||||
if 'Students' in [r.name for r in member.roles]:
|
||||
present_students.append(re.sub(r'^(.*)\#.*$', r'\1', member.name))
|
||||
|
||||
# print who is online
|
||||
print(f'currently online: {",".join(present_students)}')
|
||||
|
||||
if len(present_students) < 1:
|
||||
msg_text = "I don't see any students currently in the Classroom Voice channel!"
|
||||
else:
|
||||
msg_text = cc.coldcall(present_students)
|
||||
|
||||
await message.channel.send(msg_text)
|
||||
|
||||
# this is necessary to get information about who is online
|
||||
intents = discord.Intents.default()
|
||||
intents.members = True
|
||||
intents.presences = True
|
||||
|
||||
ccb = ColdCallBot(intents=intents)
|
||||
ccb.run('CHANGEME')
|
||||
|
||||
Reference in New Issue
Block a user