Skip to content

Commit

Permalink
r2
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali Zemani committed Aug 28, 2024
1 parent 5a68929 commit 36e3f67
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
20 changes: 10 additions & 10 deletions src/bot/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ export const handleReplyAction = async (
conversation
);
await ctx.reply(REPLAY_TO_MESSAGE);
// await logger.saveLog("new_replay_success", {});
await logger.saveLog("new_replay_success", {});
} else {
await ctx.reply(NoConversationFoundMessage);
// await logger.saveLog("new_replay_failed", {});
await logger.saveLog("new_replay_failed", {});
}
} catch (error) {
await ctx.reply(JSON.stringify(error));
// await logger.saveLog("new_replay_unknown", error);
await logger.saveLog("new_replay_unknown", error);
}
await ctx.answerCallbackQuery();
};
Expand Down Expand Up @@ -147,13 +147,13 @@ export const handleBlockAction = async (
reply_markup: replyKeyboard,
}
);
// await logger.saveLog("user_block_success", {});
await logger.saveLog("user_block_success", {});
} else {
await ctx.reply(HuhMessage);
// await logger.saveLog("user_block_failed", {});
await logger.saveLog("user_block_failed", {});
}
} catch (error) {
// await logger.saveLog("user_block_unknown", error);
await logger.saveLog("user_block_unknown", error);
}
await ctx.answerCallbackQuery();
};
Expand Down Expand Up @@ -204,17 +204,17 @@ export const handleUnblockAction = async (
reply_markup: replyKeyboard,
}
);
// await logger.saveLog("user_unblock_success", {});
await logger.saveLog("user_unblock_success", {});
} else {
await ctx.reply(HuhMessage);
// await logger.saveLog("user_unblock_failed1", {});
await logger.saveLog("user_unblock_failed1", {});
}
} else {
await ctx.reply(HuhMessage);
// await logger.saveLog("user_unblock_failed2", {});
await logger.saveLog("user_unblock_failed2", {});
}
} catch (error) {
// await logger.saveLog("user_unblock_unknown", error);
await logger.saveLog("user_unblock_unknown", error);
}

await ctx.answerCallbackQuery();
Expand Down
20 changes: 10 additions & 10 deletions src/bot/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const handleStartCommand = async (
userId: currentUserId,
userName: ctx.from?.first_name!,
});
// await logger.saveLog("new_user_success", {});
await logger.saveLog("new_user_success", {});
}

// Send welcome message with the user's unique bot link
Expand Down Expand Up @@ -104,18 +104,18 @@ export const handleStartCommand = async (
await ctx.reply(
StartConversationMessage.replace("USER_NAME", otherUser.userName)
);
// await logger.saveLog("new_conversation_success", {});
await logger.saveLog("new_conversation_success", {});
} else {
// No user found with the provided UUID
// await logger.saveLog("new_conversation_failed", {});
await logger.saveLog("new_conversation_failed", {});
await ctx.reply(NoUserFoundMessage);
}
} else {
// Handle unexpected cases
await ctx.reply(HuhMessage, {
reply_markup: mainMenu,
});
// await logger.saveLog("start_command_unknown", {});
await logger.saveLog("start_command_unknown", {});
}
};

Expand Down Expand Up @@ -216,7 +216,7 @@ export const handleMessage = async (
await ctx.reply(HuhMessage, {
reply_markup: mainMenu,
});
// await logger.saveLog("current_conversation_failed", {});
await logger.saveLog("current_conversation_failed", {});

return;
}
Expand Down Expand Up @@ -329,7 +329,7 @@ export const handleMessage = async (
}

await ctx.reply(MESSAGE_SENT_MESSAGE);
// await logger.saveLog("new_conversation_success", {});
await logger.saveLog("new_conversation_success", {});

const conversationId = getConversationId(ticketId, APP_SECURE_KEY);
const conversationData = await encryptedPayload(
Expand All @@ -347,7 +347,7 @@ export const handleMessage = async (
await ctx.reply(HuhMessage + JSON.stringify(error), {
reply_markup: mainMenu,
});
// await logger.saveLog("new_conversation_unknown", error);
await logger.saveLog("new_conversation_unknown", error);
}
};

Expand Down Expand Up @@ -378,17 +378,17 @@ export const handleDeleteUserCommand = async (
await userIdToUUID.delete(currentUserId.toString());

// Log the delete user action
// await logger.saveLog("delete_user_success", {});
await logger.saveLog("delete_user_success", {});

await ctx.reply(DELETE_USER_COMMAND_MESSAGE, {
reply_markup: mainMenu,
});
} else {
// await logger.saveLog("delete_user_failed", {});
await logger.saveLog("delete_user_failed", {});
await ctx.reply(NoUserFoundMessage);
}
} catch (error) {
await ctx.reply(JSON.stringify(error));
// await logger.saveLog("delete_user_unknown", error);
await logger.saveLog("delete_user_unknown", error);
}
};
4 changes: 4 additions & 0 deletions wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ workers_dev = true
kv_namespaces = [
{ binding = "anonymous_kv", id = "414fb07aae8b4b5d9fac86a0cad1720e" },
]

r2_buckets = [
{ binding = "r2_bucket", bucket_name = "nekonymous"}
]
[placement]
mode = "smart"

Expand Down

0 comments on commit 36e3f67

Please sign in to comment.