mirror of
https://gitlab.com/oloturia/damastodon.git
synced 2024-11-16 00:20:46 +01:00
Debugged version
This commit is contained in:
parent
5c7fc6f961
commit
0420b93a0f
1 changed files with 18 additions and 8 deletions
|
@ -31,35 +31,45 @@ def check_message(notification):
|
|||
mastodon.status_post("Hello @"+account+" \nchallenge an user by writing to me\nCHALL <USERNAME>\nEx. \"CHALL @someone@mastdn.inst.wxyz\"\nThe challenger takes WHITE and begins the match.\nFor movements and jumps, write the coords separated by spaces.\nEx. \"A4 B5\" (normal movement) or \"A4 C6 D8\" (double jump)\nQUIT ends the match.\nCommands are NOT case sensitive..",visibility="direct")
|
||||
return
|
||||
if not os.path.exists(save_position+account):
|
||||
try:
|
||||
challenged = notification["status"]["mentions"][1]["acct"]
|
||||
except:
|
||||
mastodon.status_post("Hello @"+account+" \n your request is not valid")
|
||||
return
|
||||
if content[:5].lower() == "chall":
|
||||
file_save_white = [sv for sv in saves if account in sv]
|
||||
file_save_black = [sv for sv in saves if content[:6] in sv]
|
||||
file_save_black = [sv for sv in saves if challenged in sv]
|
||||
if len(file_save_white) > 0:
|
||||
mastodon.status_post("Hello @"+account+" \n you're already playing a match")
|
||||
return
|
||||
elif len(file_save_black):
|
||||
mastodon.status_post("Hello @"+content[7:]+" \n is already playing a match")
|
||||
mastodon.status_post("Hello @"+account+" \n the user you challenged is already playing a match")
|
||||
return
|
||||
else:
|
||||
open(save_position+account,"w").close()
|
||||
ident = mastodon.status_post("Hello @"+content[7:]+" \n@"+account+" challenged you to a match of draughts! Answer \n@"+account+" OK\n to accept the chellenge or \n@"+account+" NO\n to cancel.",visibility="direct")
|
||||
ident = mastodon.status_post("Hello @"+challenged+" \n@"+account+" challenged you to a match of draughts! Answer \n@"+account+" OK\n to accept the chellenge or \n@"+account+" NO\n to cancel.",visibility="direct")
|
||||
return
|
||||
elif content.split(" ")[1].lower() == "ok":
|
||||
os.symlink(content.split(" ")[0][1:],save_position+account)
|
||||
try:
|
||||
challenger = notification["status"]["mentions"][1]["acct"]
|
||||
except:
|
||||
mastodon.status_post("Hello @"+account+" \n your request is not valid")
|
||||
return
|
||||
os.symlink(save_position+challenger,save_position+account)
|
||||
board = dama.init_board()
|
||||
with open(account,"wb") as f:
|
||||
with open(save_position+account,"wb") as f:
|
||||
pickle.dump("@"+account,f)
|
||||
pickle.dump(content.split(" ")[0],f)
|
||||
pickle.dump("@"+challenger,f)
|
||||
pickle.dump(False,f)
|
||||
pickle.dump(board,f)
|
||||
mastodon.status_post("◾: @"+account+" ◽: "+content.split(" ")[0]+" turn ◽\n"+dama.draw_checkerboard(board,space="🟥 ",white_norm="◽ ",white_knight="⚪ ",black_norm="◾ ",black_knight="⚫ ",empty="🟦 ",frstrow="0🇦 🇧 🇨 🇩 🇪 🇫 🇬 🇭 \n"),visibility="direct")
|
||||
mastodon.status_post("◾: @"+account+" ◽: @"+challenger+" turn ◽\n"+dama.draw_checkerboard(board,space="🟥 ",white_norm="◽ ",white_knight="⚪ ",black_norm="◾ ",black_knight="⚫ ",empty="🟦 ",frstrow="0🇦 🇧 🇨 🇩 🇪 🇫 🇬 🇭 \n"),visibility="direct")
|
||||
return
|
||||
elif content.split(" ")[1].lower() == "no":
|
||||
os.remove(save_position+content.split(" ")[0][1:])
|
||||
mastodon.status_post(account+" you cancelled the challenge from "+content.split(" ")[0],visibility="direct")
|
||||
return
|
||||
else:
|
||||
mastodon.status_post("Hello @"+account+" \nI can't understand your commend or you're not in a match.\nWrite HELP to see the list of available commands.",visibility="direct")
|
||||
mastodon.status_post("Hello @"+account+" \nI can't understand your command or you're not in a match.\nWrite HELP to see the list of available commands.",visibility="direct")
|
||||
return
|
||||
else:
|
||||
with open(save_position+account,"rb") as f:
|
||||
|
|
Loading…
Reference in a new issue