ban league
This commit is contained in:
parent
367e5a5772
commit
ec7ef7a55f
36
ticker.py
36
ticker.py
|
@ -56,6 +56,7 @@ async def ticker_update():
|
|||
if not voice_client.is_connected():
|
||||
voice_client = await target_voice_channel.connect()
|
||||
|
||||
# we are not already in the correct channel
|
||||
if not target_voice_channel.id == voice_client.channel.id:
|
||||
await voice_client.move_to(target_voice_channel.id)
|
||||
|
||||
|
@ -75,15 +76,34 @@ async def ticker_update():
|
|||
async def on_ready():
|
||||
print(client.user.name)
|
||||
|
||||
# add afk message
|
||||
@client.event
|
||||
async def on_voice_state_update(member, before, after):
|
||||
# only run on moves
|
||||
if before.channel and after.channel:
|
||||
# moves to the afk channel
|
||||
if after.channel.id == member.guild.afk_channel.id:
|
||||
filename = to_tts(member.display_name + "はretard dimensionに移動しました")
|
||||
await ticker_queue.put((filename, before.channel))
|
||||
print("ticker event has been added to queue")
|
||||
file_name = to_tts(member.display_name + "はretard dimensionに移動しました")
|
||||
await add_event(file_name, voice_channel)
|
||||
|
||||
# ban league
|
||||
@client.event
|
||||
async def on_member_update(before, after):
|
||||
if after.activity.type == discord.ActivityType.playing:
|
||||
voice_channel = (after.voice.channel if after.voice.channel else None) if after.voice else None
|
||||
|
||||
# this entire block implies that after is a game, so it definitely has a name
|
||||
# before might not be a game, and might not have a name.
|
||||
before_name = None
|
||||
if before.activity.type == discord.ActivityType.playing:
|
||||
before_name = before.activity.name
|
||||
|
||||
# if a player starts playing league
|
||||
if after.activity.name != before_name:
|
||||
if after.activity.name == "League of Legends":
|
||||
print("someone has started playing league uwu")
|
||||
file_name = to_tts("Stop playing League, " + after.display_name, lang = 'en')
|
||||
await add_event(file_name, voice_channel)
|
||||
|
||||
client.loop.create_task(ticker_update())
|
||||
|
||||
|
@ -97,15 +117,17 @@ def get_best_channel(guild_id):
|
|||
top_channel = sorted(guild.voice_channels, key = lambda chan: len(chan.members), reverse = True)[0]
|
||||
return matt_voice if matt_voice else top_channel
|
||||
|
||||
async def ticker():
|
||||
async def add_event(file_name, voice_channel):
|
||||
print("ticker event has been added to queue")
|
||||
await ticker_queue.put((file_name, voice_channel))
|
||||
|
||||
async def ticker():
|
||||
file_name = to_tts("The current JPY exchange rate is " + str(c.get_rate('USD', 'JPY')) + " yen to a dollar")
|
||||
await ticker_queue.put((file_name, get_best_channel(SEGUIS)))
|
||||
await add_event(file_name, voice_channel)
|
||||
|
||||
async def flatten():
|
||||
print("ticker event has been added to queue")
|
||||
file_name = to_tts("Matt, it is time for your 4 PM dick flattening")
|
||||
await ticker_queue.put((file_name, get_best_channel(SEGUIS)))
|
||||
await add_event(file_name, voice_channel)
|
||||
|
||||
s = AsyncIOScheduler(event_loop = client.loop)
|
||||
s.add_job(ticker, CronTrigger(hour = '0-19,21-23'))
|
||||
|
|
Loading…
Reference in New Issue