This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from dmitrydnl/v0.5
V0.5
- Loading branch information
Showing
66 changed files
with
1,029 additions
and
372 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
{ | ||
"welcomeMessage": "Hi, good to see you!", | ||
"mainCommands": "Registration: /reg\nAuthorization: /auth\nInformation about me: /info\nClose chat in any time: /e or /exit", | ||
"information": "This is open source bot for stashing in Telegram Messenger.\nThe code you can find here: https://github.com/dmitrydnl/StashBot", | ||
"registrationWarning": "If you have already registered you will lose all your old data!\nAre you sure? /yes or /no", | ||
"registrationReady": "Input your password or /cancel", | ||
"successRegistration": "Success!\nNow you can auth with password", | ||
"passwordEmpty": "Input password", | ||
"passwordMinLength": "Password min length 12!", | ||
"passwordMaxLength": "Password max length 25!", | ||
"passwordCharacters": "Password can contain only letters, numbers and special characters!", | ||
"authorisationReady": "Input your password or /back", | ||
"successAuthorisation": "Success!", | ||
"failAuthorisation": "WRONG", | ||
"login": "Input message to save it in stash.\nGet messages in stash: /stash\nLogout: /logout", | ||
"logout": "You're logged out" | ||
"MainCommands": "🐾 /SignIn or /SignUp \n\n📘About: /Info\n🛑 Close immediately: /exit", | ||
"Information": "This is open source bot for stashing in Telegram Messenger.\nThe code you can find here: https://github.com/dmitrydnl/StashBot", | ||
"RegistrationWarning": "⚠️ If you have already registered, you'll have lost your data!\nAre you sure? /yes or /no", | ||
"RegistrationReady": "Type password or /cancel", | ||
"PasswordEmpty": "Type password", | ||
"PasswordMinLength": "⚠️ Min password length = 12!", | ||
"PasswordMaxLength": "⚠️ Max password length = 25!", | ||
"PasswordCharacters": "⚠️ Password can contain only letters, numbers and special characters!", | ||
"AuthorisationReady": "Type password or /back", | ||
"Success": "✅ SUCCESS ", | ||
"FailAuthorisation": "❌ WRONG", | ||
"Login": "🛸 Send message to save it.\nGet messages: /Stash\nLogout: /logout", | ||
"Logout": "👀 You've logged out", | ||
"EmptyStash": "🕳 Stash is empty", | ||
"FullStashError": "💯 Stash is full\nDelete your message!" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"chatSessionsClearInterval": 10, | ||
"chatSessionLiveTime": 60, | ||
"stashMessageLimit": 100, | ||
"accountDatabaseType": "sqlite", | ||
"stashDatabaseType": "sqlite" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System.IO; | ||
using Newtonsoft.Json; | ||
|
||
namespace StashBot.BotSettings | ||
{ | ||
internal static class StashSettings | ||
{ | ||
private const string BOT_SETTINGS_FILE_NAME = "BotSettings.json"; | ||
|
||
private static bool isSetUp; | ||
private static int stashMessageLimit; | ||
|
||
internal static int StashMessageLimit | ||
{ | ||
get | ||
{ | ||
SetUpSettings(); | ||
return stashMessageLimit; | ||
} | ||
} | ||
|
||
private static void SetUpSettings() | ||
{ | ||
if (isSetUp) | ||
{ | ||
return; | ||
} | ||
|
||
string text = File.ReadAllText(BOT_SETTINGS_FILE_NAME); | ||
dynamic jsonObject = JsonConvert.DeserializeObject<dynamic>(text); | ||
stashMessageLimit = (int)jsonObject.stashMessageLimit; | ||
isSetUp = true; | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/StashBot/app/CallbackQueryHandler/DeleteMessageHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using StashBot.Module; | ||
using StashBot.Module.Database; | ||
using StashBot.Module.Message; | ||
|
||
namespace StashBot.CallbackQueryHandler | ||
{ | ||
internal class DeleteMessageHandler : ICallbackQueryHandler | ||
{ | ||
private const int MIN_PARAMETERS_COUNT = 3; | ||
|
||
public void Handle(string[] queryArray, int messageId) | ||
{ | ||
IDatabaseManager databaseManager = ModulesManager.GetDatabaseManager(); | ||
IMessageManager messageManager = ModulesManager.GetMessageManager(); | ||
|
||
if (queryArray.Length < MIN_PARAMETERS_COUNT) | ||
{ | ||
return; | ||
} | ||
|
||
bool isChatIdParsed = long.TryParse(queryArray[1], out long chatId); | ||
bool isDatabaseMessageIdParsed = long.TryParse(queryArray[2], out long databaseMessageId); | ||
if (!isChatIdParsed || !isDatabaseMessageIdParsed) | ||
{ | ||
return; | ||
} | ||
|
||
databaseManager.DeleteStashMessage(chatId, databaseMessageId); | ||
messageManager.DeleteMessage(chatId, messageId); | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/StashBot/app/CallbackQueryHandler/ICallbackQueryHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace StashBot.CallbackQueryHandler | ||
{ | ||
internal interface ICallbackQueryHandler | ||
{ | ||
void Handle(string[] queryArray, int messageId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
namespace StashBot.Module.Database | ||
{ | ||
internal interface IUser | ||
public interface IUser | ||
{ | ||
long ChatId | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.