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 discord
|
||||||
import os
|
import os
|
||||||
from discord.ext import tasks
|
from discord.ext import tasks
|
||||||
@@ -42,59 +44,67 @@ async def on_ready():
|
|||||||
|
|
||||||
@tasks.loop(seconds=5)
|
@tasks.loop(seconds=5)
|
||||||
async def task_loop():
|
async def task_loop():
|
||||||
await bot.change_presence(
|
try:
|
||||||
activity=discord.Activity(
|
# print(str(datetime.datetime.now()) + ": Loop running.")
|
||||||
type=discord.ActivityType.watching,
|
await bot.change_presence(
|
||||||
name=str(len(bot.tracked_games)) + " Servers.",
|
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
|
|
||||||
)
|
)
|
||||||
game.to_json()
|
)
|
||||||
|
for game in bot.tracked_games:
|
||||||
# handle uploaded turns
|
channel = bot.get_channel(game.channelId)
|
||||||
turns = game.get_new_turns()
|
if channel is None:
|
||||||
if turns != {}:
|
continue
|
||||||
for key in turns:
|
# handle turn ticks
|
||||||
value = turns[key]
|
new_turn = game.get_turn()
|
||||||
if value == "Turn played":
|
if new_turn != game.turn and new_turn.isdigit():
|
||||||
await channel.send(
|
game.update_turn()
|
||||||
'Game **"'
|
pingstr = ""
|
||||||
+ game.name
|
if game.members:
|
||||||
+ '"**: '
|
pingstr += "-# "
|
||||||
+ key
|
for member in game.members:
|
||||||
+ " has played their turn."
|
pingstr += "<@" + str(member) + "> "
|
||||||
)
|
await channel.send(
|
||||||
if value == "Eliminated":
|
'Game **"'
|
||||||
await channel.send(
|
+ game.name
|
||||||
'Game **"' + game.name + '"**: ' + key + " has been eliminated."
|
+ '"** has advanced to turn '
|
||||||
)
|
+ game.turn
|
||||||
if value == "Turn unfinished":
|
+ " \n"
|
||||||
await channel.send(
|
+ pingstr
|
||||||
'Game **"'
|
)
|
||||||
+ game.name
|
|
||||||
+ '"**: '
|
|
||||||
+ key
|
|
||||||
+ " has marked their turn as unfinished."
|
|
||||||
)
|
|
||||||
game.update_players()
|
|
||||||
game.to_json()
|
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