Compare commits
3 Commits
11e531fef2
...
webbeta
| Author | SHA1 | Date | |
|---|---|---|---|
| 448fc8aebe | |||
| 7dab0ed143 | |||
| a13748b833 |
118
main.py
118
main.py
@@ -1,3 +1,5 @@
|
||||
from datetime import time
|
||||
import datetime
|
||||
import discord
|
||||
import os
|
||||
from discord.ext import tasks
|
||||
@@ -42,59 +44,67 @@ async def on_ready():
|
||||
|
||||
@tasks.loop(seconds=5)
|
||||
async def task_loop():
|
||||
await bot.change_presence(
|
||||
activity=discord.Activity(
|
||||
type=discord.ActivityType.watching,
|
||||
name=str(len(bot.tracked_games)) + " Servers.",
|
||||
)
|
||||
)
|
||||
for game in bot.tracked_games:
|
||||
channel = bot.get_channel(game.channelId)
|
||||
if channel is None:
|
||||
continue
|
||||
# handle turn ticks
|
||||
new_turn = game.get_turn()
|
||||
if new_turn != game.turn and new_turn.isdigit():
|
||||
game.update_turn()
|
||||
pingstr = ""
|
||||
if game.members:
|
||||
pingstr += "-# "
|
||||
for member in game.members:
|
||||
pingstr += "<@" + str(member) + "> "
|
||||
await channel.send(
|
||||
'Game **"'
|
||||
+ game.name
|
||||
+ '"** has advanced to turn '
|
||||
+ game.turn
|
||||
+ " \n"
|
||||
+ pingstr
|
||||
try:
|
||||
# print(str(datetime.datetime.now()) + ": Loop running.")
|
||||
await bot.change_presence(
|
||||
activity=discord.Activity(
|
||||
type=discord.ActivityType.watching,
|
||||
name=str(len(bot.tracked_games)) + " Servers.",
|
||||
)
|
||||
game.to_json()
|
||||
|
||||
# handle uploaded turns
|
||||
turns = game.get_new_turns()
|
||||
if turns != {}:
|
||||
for key in turns:
|
||||
value = turns[key]
|
||||
if value == "Turn played":
|
||||
await channel.send(
|
||||
'Game **"'
|
||||
+ game.name
|
||||
+ '"**: '
|
||||
+ key
|
||||
+ " has played their turn."
|
||||
)
|
||||
if value == "Eliminated":
|
||||
await channel.send(
|
||||
'Game **"' + game.name + '"**: ' + key + " has been eliminated."
|
||||
)
|
||||
if value == "Turn unfinished":
|
||||
await channel.send(
|
||||
'Game **"'
|
||||
+ game.name
|
||||
+ '"**: '
|
||||
+ key
|
||||
+ " has marked their turn as unfinished."
|
||||
)
|
||||
game.update_players()
|
||||
)
|
||||
for game in bot.tracked_games:
|
||||
channel = bot.get_channel(game.channelId)
|
||||
if channel is None:
|
||||
continue
|
||||
# handle turn ticks
|
||||
new_turn = game.get_turn()
|
||||
if new_turn != game.turn and new_turn.isdigit():
|
||||
game.update_turn()
|
||||
pingstr = ""
|
||||
if game.members:
|
||||
pingstr += "-# "
|
||||
for member in game.members:
|
||||
pingstr += "<@" + str(member) + "> "
|
||||
await channel.send(
|
||||
'Game **"'
|
||||
+ game.name
|
||||
+ '"** has advanced to turn '
|
||||
+ game.turn
|
||||
+ " \n"
|
||||
+ pingstr
|
||||
)
|
||||
game.to_json()
|
||||
|
||||
# handle uploaded turns
|
||||
turns = game.get_new_turns()
|
||||
if turns != {}:
|
||||
for key in turns:
|
||||
value = turns[key]
|
||||
if value == "Turn played":
|
||||
await channel.send(
|
||||
'Game **"'
|
||||
+ game.name
|
||||
+ '"**: '
|
||||
+ key
|
||||
+ " has played their turn."
|
||||
)
|
||||
if value == "Eliminated":
|
||||
await channel.send(
|
||||
'Game **"'
|
||||
+ game.name
|
||||
+ '"**: '
|
||||
+ key
|
||||
+ " has been eliminated."
|
||||
)
|
||||
if value == "Turn unfinished":
|
||||
await channel.send(
|
||||
'Game **"'
|
||||
+ game.name
|
||||
+ '"**: '
|
||||
+ key
|
||||
+ " has marked their turn as unfinished."
|
||||
)
|
||||
game.update_players()
|
||||
game.to_json()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
Reference in New Issue
Block a user