Compare commits

...
249 Commits
Author SHA1 Message Date
Florian Zevedei 355c601e17 Merge pull request #32 from MajMcCloud/development
Updating to 5.2
2022-11-23 13:15:35 +01:00
FlorianDahn 75a70c6ed4 Updating AsyncFormUpdates example 2022-11-23 13:14:17 +01:00
FlorianDahn 8b2d70e016 Update SystemCommandsBot.csproj 2022-11-23 13:12:26 +01:00
FlorianDahn ace936e2e8 Adding images to .github 2022-11-23 13:09:57 +01:00
FlorianDahn 2650144b19 Update README.md 2022-11-23 13:08:22 +01:00
FlorianDahnandAlexey dded0ae49e Update Testproject
Co-Authored-By: Alexey <110727638+ZavaruKitsu@users.noreply.github.com>
2022-10-09 17:15:06 +02:00
FlorianDahnandAlexey f39b1d11be Integration of changes
Integrate some changes and cleanups

Co-Authored-By: Alexey <110727638+ZavaruKitsu@users.noreply.github.com>
2022-10-09 17:12:52 +02:00
FlorianDahn 91002c8271 Fix of example descriptions 2022-10-05 16:29:12 +02:00
Florian Zevedei 561312eb87 Merge pull request #28 from ZavaruKitsu/development-readme
docs: better README.md
2022-10-05 16:21:58 +02:00
Florian Zevedei ff21c86ce9 Merge pull request #27 from ZavaruKitsu/development
Accepted! Thanks as always!
2022-09-22 01:18:07 +02:00
ZavaruKitsu 5f9ffb7ae4 docs: fix link 2022-09-22 00:43:02 +03:00
ZavaruKitsu 920284d77d docs: fix anchor 2022-09-22 00:40:39 +03:00
ZavaruKitsu 8ea8e5aa2d docs: make README.md match each one 2022-09-22 00:39:02 +03:00
ZavaruKitsu 7f383a8a83 docs: merge from master/README.md 2022-09-22 00:35:30 +03:00
ZavaruKitsu 0e3cb79a2f docs: fix links to examples 2022-09-22 00:33:07 +03:00
ZavaruKitsu a125addd2e docs: fix anchors 2022-09-22 00:30:14 +03:00
ZavaruKitsu 869d16fa02 docs: better README.md
refactor: move images to the .github folder
2022-09-22 00:30:14 +03:00
ZavaruKitsu 21cdbf4db6 deps: update Telegram.Bot and other libs 2022-09-21 22:49:14 +03:00
FlorianDahn 16371b8c7a #26 Fix error on using InvokeMessageLoop
- Fixes the error on using the default InvokeMessageLoop with Deviceid
2022-09-01 13:49:26 +02:00
Florian Zevedei 601ce32072 Merge pull request #25 from ZavaruKitsu/development
feat: add DI form factory
2022-08-29 18:04:59 +02:00
ZavaruKitsu b2d4c4c3f8 feat: add DI form factory 2022-08-19 15:54:36 +03:00
FlorianDahn 75600d5e7f Update README.md 2022-07-02 14:25:16 +02:00
FlorianDahn df7880fcf3 Make OnMessageSent async as well 2022-07-02 14:07:25 +02:00
FlorianDahn e814046d29 Adding extension folder 2022-07-02 14:06:27 +02:00
FlorianDahn 0ebce16490 Remove unnecessary null checks 2022-07-02 14:05:57 +02:00
FlorianDahn 863b2d0414 Update TelegramBotBase.Extensions.Serializer.Database.MSSQL.csproj 2022-06-30 17:10:48 +02:00
FlorianDahn 436566adeb Update README.md 2022-06-30 16:26:39 +02:00
FlorianDahn 4054fa3e85 Adding new SQL Database serializer 2022-06-30 16:22:53 +02:00
FlorianDahn e8279892e4 Update TelegramBotBase.nuspec
Update Newtonsoft.Json package version
2022-06-27 14:30:23 +02:00
Florian Dahn b32347ff4f Merge pull request #20 from MajMcCloud/dependabot/nuget/Examples/SystemCommandsBot/Newtonsoft.Json-13.0.1
Bump Newtonsoft.Json from 12.0.3 to 13.0.1 in /Examples/SystemCommandsBot
2022-06-23 22:11:38 +02:00
dependabot[bot] b2ffacea2a Bump Newtonsoft.Json in /Examples/SystemCommandsBot
Bumps [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) from 12.0.3 to 13.0.1.
- [Release notes](https://github.com/JamesNK/Newtonsoft.Json/releases)
- [Commits](https://github.com/JamesNK/Newtonsoft.Json/compare/12.0.3...13.0.1)

---
updated-dependencies:
- dependency-name: Newtonsoft.Json
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-23 20:11:23 +00:00
Florian Dahn 0d0c2471b2 Merge pull request #22 from MajMcCloud/dependabot/nuget/TelegramBotBase.Test/Newtonsoft.Json-13.0.1
Bump Newtonsoft.Json from 12.0.2 to 13.0.1 in /TelegramBotBase.Test
2022-06-23 22:11:21 +02:00
dependabot[bot] f5054c75d5 Bump Newtonsoft.Json from 12.0.2 to 13.0.1 in /TelegramBotBase.Test
Bumps [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) from 12.0.2 to 13.0.1.
- [Release notes](https://github.com/JamesNK/Newtonsoft.Json/releases)
- [Commits](https://github.com/JamesNK/Newtonsoft.Json/compare/12.0.2...13.0.1)

---
updated-dependencies:
- dependency-name: Newtonsoft.Json
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-23 20:11:07 +00:00
Florian Dahn 7a85b2fc31 Merge pull request #21 from MajMcCloud/dependabot/nuget/Examples/AsyncFormUpdates/Newtonsoft.Json-13.0.1
Bump Newtonsoft.Json from 11.0.2 to 13.0.1 in /Examples/AsyncFormUpdates
2022-06-23 22:10:23 +02:00
dependabot[bot] 348909f3ff Bump Newtonsoft.Json from 11.0.2 to 13.0.1 in /Examples/AsyncFormUpdates
Bumps [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) from 11.0.2 to 13.0.1.
- [Release notes](https://github.com/JamesNK/Newtonsoft.Json/releases)
- [Commits](https://github.com/JamesNK/Newtonsoft.Json/compare/11.0.2...13.0.1)

---
updated-dependencies:
- dependency-name: Newtonsoft.Json
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-23 01:00:16 +00:00
FlorianDahn 78b3fbebc8 MessageLoop updates
- moving MessageLoop folders from Subfolder Factories one level up
- changing namespace and botbuilder methods to change
- adding FullMessageLoop which allows to get all updates (like MinimalMessageLoop but with all methods)
2022-06-06 20:16:33 +02:00
Florian Dahn 2a3d8c1b30 Update README.md 2022-05-17 02:29:43 +02:00
FlorianDahn d99bb79849 Shrinking methods to Lambda functions 2022-05-16 14:34:05 +02:00
FlorianDahn 3386db0f66 Updating Test project
- adding "myid" command to get own device id
2022-05-15 23:23:29 +02:00
FlorianDahn 6aac7d887a Update Nuget reference for Polling module to latest version 2022-05-15 23:20:40 +02:00
FlorianDahn 707ffd492f Upgrading BotCommands to new BotCommandScope format
- adding IsKnownBotCommand method to BotBase
- updated UploadBotCommand method to new format
- adding new Commandformat to BotBaseBuilder
- adding AddChatCommand and ClearChatCommand for custom Chat commands
- integrating new checks into FormBaseMessageLoop
2022-05-15 23:20:16 +02:00
FlorianDahn 2c567419ec Update MessageClient.cs
- increasing parameters for Get/SetCommand methods
- adding DeleteBotCommands methods
2022-05-15 23:17:01 +02:00
FlorianDahn e81f535f75 New methods for SendingVideo
- adding SendVideo by byte array
- adding SendLocalVideo to send videofile from disk
2022-05-15 15:42:53 +02:00
FlorianDahn 72a1fa3c99 Replacing Client in ResultBase and subclasses
- replace Client with Device to allow more access
- making Client in DeviceSession public to allow access from outside
2022-05-15 15:41:24 +02:00
FlorianDahn d08cbe8b0e Bugfix with MessageResult leads to having not access to MessageClient 2022-04-16 15:36:55 +02:00
FlorianDahn e2ac7975a5 Updating example projects to .NET 6 and latest framework. 2022-03-19 04:22:07 +01:00
FlorianDahn d7a5c149b1 Replacing BotCommands with BotCommandsScope 2022-02-08 18:07:59 +01:00
FlorianDahn 8fa952e68b Update .gitignore 2022-02-08 17:08:11 +01:00
FlorianDahn a0b87887f7 Merge branch 'development' of https://github.com/MajMcCloud/TelegramBotFramework into development 2022-02-08 17:01:40 +01:00
FlorianDahn f1c626a7ba Integrate new Message Loop 2022-02-08 16:56:35 +01:00
Florian Dahn 46cf9b9f2e Merge pull request #19 from MajMcCloud/master
Update development branch.
2022-02-08 16:35:45 +01:00
Florian Dahn 3340ef7b76 Update README.md 2022-01-10 13:59:26 +01:00
Florian Dahn 211424569b Merge pull request #18 from MajMcCloud/New-Version-v5
New version v5
2022-01-10 13:58:50 +01:00
FlorianDahn 8303b0c87f Adding private constructor
- Adding private constructor
- some spacing for regions
2022-01-06 16:54:50 +01:00
FlorianDahn 19856ab044 Update Solution File 2022-01-06 15:56:16 +01:00
FlorianDahn 5453add956 Renaming TelegramBotBaseTest -> TelegramBotBase.Test 2022-01-06 15:53:41 +01:00
FlorianDahn ff3c22566a Comment Cleanup 2022-01-05 18:40:44 +01:00
FlorianDahn 50fd5255c8 Adding SourceLink to Image Extension 2022-01-05 18:39:35 +01:00
FlorianDahn 4f85677deb Comment Cleanup 2022-01-05 18:39:06 +01:00
FlorianDahn 7d2703138c Readme fix to "generics" like in earlier versions. 2022-01-05 18:31:30 +01:00
FlorianDahn d0d93a07c0 Adding QuickStart to readme. 2022-01-05 18:30:25 +01:00
FlorianDahn f03e67f345 Adding QuickStart Option for BotBaseBuilder 2022-01-05 18:26:10 +01:00
FlorianDahn 18bb6584f4 Adding OnlyStart BotBaseBuilder command option 2022-01-05 18:25:33 +01:00
FlorianDahn d5a89a4ed8 Adding regions to BotBaseBuilder 2022-01-05 18:25:04 +01:00
FlorianDahn 09d7164385 Update README.md 2022-01-05 14:22:21 +01:00
FlorianDahn 2b914f6f58 Changing CustomMessageLoop parameter 2022-01-05 01:17:44 +02:00
FlorianDahn b65ec13d8b Simplifying BotBuilder BotCommands
- Simplifying BotBuilder BotCommands
- updating test project
2022-01-05 01:16:22 +02:00
FlorianDahn ca1c382924 Removing old commented stuff 2022-01-04 23:44:43 +02:00
FlorianDahn 584bb76e0f Adding comments 2022-01-04 23:42:13 +02:00
FlorianDahn c5fa153d54 Replace KickChatMemberAsync/KickUser 2022-01-04 23:40:33 +02:00
FlorianDahn c6106f17ec Removing .Net 4.7.2 and adding .Net Standard 2.0 instead of 2.1
- removing .Net 4.7.2 compilation target
- changing .Net Standard from 2.1 to 2.0 for backwards compatibility
2021-12-25 17:52:17 +01:00
FlorianDahn 4f97e2a919 Changing debugtype to portable to allow snupkg file to be attached. 2021-12-25 17:47:11 +01:00
FlorianDahn 21c6b2fde5 removing .NET 472 compilation target from test project 2021-12-25 17:34:47 +01:00
FlorianDahn caf9b3cc8e Change version of polling library to 1.0.1 2021-12-25 17:34:20 +01:00
FlorianDahn 27e45b397d Changing debugtype to portable to allow snupkg file to be attached.
- removing double Releae config in project settings
- change debugtype to portable to allow correct snupkg package upload
2021-12-25 17:32:21 +01:00
FlorianDahn b8bdc756d4 Rename file to class name 2021-12-25 16:13:31 +01:00
FlorianDahn e5d8e403a0 Update readme with new BotBaseBuilder 2021-12-25 16:12:26 +01:00
FlorianDahn 2c58f86524 Adding localization selection step to BotBaseBuilder
- Adding localization step
- Updating test project
2021-12-25 16:10:32 +01:00
Florian Dahn 4bd43de0fe Update README.md 2021-12-22 15:40:14 +01:00
Florian Dahn 871d25b95b Create README.md 2021-12-22 15:38:46 +01:00
Florian Dahn b508a7e3ce Update README.md 2021-12-20 14:16:28 +01:00
Florian Dahn 0ebba5e204 Update README.md 2021-12-20 14:15:52 +01:00
FlorianDahn 1cc0a2bdf7 Ignore Callback queries with original image attached to message, no SentData event 2021-12-19 14:55:23 +01:00
FlorianDahn fc33da0496 Fixing empty message field 2021-12-17 15:15:58 +01:00
FlorianDahn 35045f3aeb Removing Newtonsoft Dependency 2021-12-16 15:08:56 +01:00
FlorianDahn 3b8b24593f Dependency Update
- downgrade NetStandard from 2.1 to 2.0 to allow .NetFramework usage from 4.6.1 to 4.8
- remove .Net Framework 4.7.2 compilation target
- replacing conditioned compilation for .Net Framework with .Net Standard
- removing System.Net.Http dependency (was only necessary for .Net Framework)
2021-12-16 14:57:28 +01:00
FlorianDahn 03565aba98 Replacing Nuget packages with project references 2021-12-06 02:41:55 +01:00
FlorianDahn bbc436d1d6 Merge branch 'New-Version-v5' of https://github.com/MajMcCloud/TelegramBotFramework into New-Version-v5 2021-12-06 02:37:01 +01:00
FlorianDahn 4026f9ba4e Update for easier serialization during BotBaseBuilder 2021-12-06 02:36:59 +01:00
Florian Dahn fb38d32e9e Update README.md 2021-11-29 15:57:49 +01:00
FlorianDahn 077bd1384f Removing System.ComponentModel dependency 2021-11-28 23:58:23 +01:00
FlorianDahn e28663138b Integrating Images Project 2021-11-28 23:20:56 +01:00
FlorianDahn 65ec7f1c2b Update TelegramBotBase.csproj 2021-11-26 17:59:58 +01:00
FlorianDahn 1fc581b959 V17 - Testproject Update 2021-11-26 17:58:49 +01:00
FlorianDahn 31e52887ba V17 - Big Update
- Adding a message loop interface to build custom message loops
- extracting default message loop from BotBase into seperate class
- updates to BotBaseBuilder for integration of custom message loops
- updating all result classes for using the new Update object of V17
- improving MessageResult and UpdateResult classes
- BotBase has been prepared for cleanup (a lot of comments)
- Comment cleanup at the next build
- updating Readme
2021-11-26 17:57:49 +01:00
FlorianDahn e9c25ea9e4 New ConfirmAction method 2021-11-26 17:49:33 +01:00
FlorianDahn 2aee486370 V17 - Replacing default enum values 2021-11-26 17:49:17 +01:00
FlorianDahn c1a0b12a94 Replace Configure with CustomCommands 2021-11-26 17:47:42 +01:00
FlorianDahn 2bd4634624 V17 - Remove default selection for enums 2021-11-26 17:45:24 +01:00
FlorianDahn 0bc77ca79c Update README.md 2021-11-26 17:43:38 +01:00
FlorianDahn d0edf8531c Replacing Configure method in BBB with CustomCommands 2021-11-22 22:07:55 +01:00
FlorianDahn b001d5e9c4 Adding LambdaStartFormFactory 2021-10-17 18:38:35 +02:00
FlorianDahn e1d5051288 Update README.md 2021-10-17 18:31:28 +02:00
FlorianDahn d00c5e1799 Updating BotBaseBuilder with more functionality 2021-10-17 18:21:05 +02:00
FlorianDahn c4a31e987b Replacing BotBase instance with BotBaseBuilder 2021-10-17 18:07:53 +02:00
Florian Dahn eafb81bf7b Merge pull request #17 from MajMcCloud/master
PR for master changes branch
2021-10-17 17:35:13 +02:00
FlorianDahn 1dff9d5ffe Update IAPIKeySelectionStage.cs 2021-10-17 17:33:49 +02:00
FlorianDahn 755f5a245b Renaming 2021-10-17 17:27:06 +02:00
FlorianDahn a22ede0f4f Changing BotBase behaviour to fluent api
- removing unecessary constructors from BotBase
- removing generics from BotBase
- removing generics from SessionBase
- adding StartFormFactory interface
- adding DefaultStartFormFactory
- adding multiple methods to BotBaseBuilder
2021-10-17 17:25:17 +02:00
FlorianDahn 8e29652148 Fixing possible Deadlock in AutoCleanForm 2021-10-17 15:39:31 +02:00
Florian Dahn 5bb316d874 Merge pull request #15 from victorrar/f/update-readme
Fix documentation inaccuracy

Thanks !
2021-10-04 21:35:59 +02:00
Victor d2ae08771e Fix documentation inaccuracy 2021-10-04 21:55:41 +03:00
Florian Dahn 9162c0894c Merge pull request #14 from MajMcCloud/development
AutoCleanForm FIX
2021-10-01 18:36:24 +02:00
FlorianDahn e0ec133209 AutoCleanForm FIX
- adding MessageDeleted event to AutoCleanForm for catching messages getting deleted outside of AutoCleanForm
- added OnMessageDelete invoke to DeleteMessage in DeviceSession
2021-10-01 18:35:05 +02:00
Florian Dahn 7004ee5963 Merge pull request #13 from MajMcCloud/development
Development
2021-08-13 15:33:12 +03:00
FlorianDahn ef8ca3c988 Adding basic example for different types of ConfirmAction 2021-08-01 13:50:18 +03:00
FlorianDahn f021f12486 Update Localization.cs
- change to abstract so it can't be used accidentally
2021-07-27 17:00:16 +02:00
FlorianDahn d06e1eaa52 Update README.md 2021-07-26 15:52:59 +02:00
FlorianDahn 23969881c1 Update README.md 2021-07-26 15:44:06 +02:00
FlorianDahn 9fa3df2889 Update README.md 2021-07-26 15:42:04 +02:00
FlorianDahn 6ed91224eb Update README.md 2021-07-26 15:39:47 +02:00
FlorianDahn aabc7f04b7 Adding documentation about NavigationController 2021-07-26 15:38:47 +02:00
FlorianDahn 71433c0e4e MAJOR CHANGE for ButtonGrids, Dynamic data sources, etc
- introducing a dynamic data source class (IDataSource)
- introducing a ButtonRow class for better managability
- replacing that List<ButtonBase> with ButtonRow object
- introducing ButtonFormDataSource with special methods for ButtonGrid controls
- updating ButtonGrid and refactoring of the Load/Action methods
- updating CheckButtonList and refactoring of the Load/Action methods
- updating TaggedButtonGrid and refactoring of the Load/Action methods
- adding example to the Test project
2021-07-26 15:10:10 +02:00
FlorianDahn 894d0799c8 Localizations updated
- moved German Localization to its seperate file
- cleaned up Localization class
2021-07-26 14:55:29 +02:00
FlorianDahn 6c2543630d Adding .NET 4.7.2 back into with conditional compilation
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives
2021-07-26 13:32:32 +02:00
FlorianDahn 84d18f6f45 Small readability improvements 2021-07-26 01:26:33 +02:00
FlorianDahn 5f49e25458 Adding CheckAll and UncheckAllTags methods 2021-07-26 01:23:31 +02:00
FlorianDahn f28c9b1e22 Add DeleteReplyMessage property 2021-07-26 01:22:58 +02:00
FlorianDahn 0db0c00cd0 Update example project 2021-07-25 22:25:29 +02:00
FlorianDahn 2158f53cde Fixing ReplyKeyboard flicker on TaggedButtonGrid
- fixing ReplyKeyboard flicker
- updating message handling on existing messages
2021-07-25 17:44:43 +02:00
FlorianDahn fd7d72b986 Update NavigationController.cs 2021-07-25 16:40:09 +02:00
FlorianDahn 47a5b502b9 Updating package targetFramework to .NET 5 2021-07-25 16:38:53 +02:00
FlorianDahn ce4c7b6f1c Update TelegramBotBase.csproj 2021-07-25 16:36:43 +02:00
FlorianDahn 5bae650edc Updating compilation targets
- Removing .NET 4.7.2 and  and replacing it with .NET 5
2021-07-25 16:35:15 +02:00
FlorianDahn 9eae63dae6 Updating Testproject
- adding example for NavigationController
- readability improvement in Menu
2021-07-25 16:34:29 +02:00
FlorianDahn 6f005114bc Update NavigationController.cs
- Adding PopToRootAsync method
- small comment change
2021-07-25 16:33:05 +02:00
Florian Dahn 00440a50e8 Merge pull request #11 from MajMcCloud/master
Move Master changes to development branch
2021-07-25 05:07:31 +03:00
FlorianDahn ae9dd17ae3 Adding NavigationController for better and optional Push/Pop navigation 2021-07-25 01:54:16 +02:00
FlorianDahn be2660239a Creating DeviceSession and other stuff slight earlier in the LoadSessionStates methods 2021-07-25 01:53:55 +02:00
Florian Dahn e88114049e Merge pull request #8 from Xilosof/feat/QuickDeletionOfMsgs
Thanks for the added change. I will approve it now.
2021-07-25 02:10:30 +03:00
Xilosof 177c198916 Added event call 2021-07-23 16:47:42 +03:00
FlorianDahn 1f7a9900c4 Updating TelegramBotBaseTest project
- adding new simple AddStartCommand, AddHelpCommand and AddSettingsCommand to Program.cs to make it easier
2021-07-17 18:36:56 +02:00
Florian Dahn d6051ce607 Merge pull request #10 from MajMcCloud/development
Updating to TelegramBotFramework 16.0.2
2021-07-17 19:35:17 +03:00
FlorianDahn 5613e84bc3 Updating to TelegramBotFramework 16.0.2
ATTENTION: UserIds will no longer be "int", instead it has to be of the long datatype
- updating DeviceSession methods for new datatype
- updating LinkReplaceTest class example
- adding .NET 5 as target framework
2021-07-17 18:34:27 +02:00
Florian Dahn d52fd41467 Merge pull request #9 from MajMcCloud/development
Development
2021-07-14 23:11:32 +03:00
Florian Dahn 8df6e4ce55 Merge pull request #7 from NTDV/master
CalendarPicker fixes
2021-07-14 22:35:13 +03:00
Xilosof 9012ec76b1 feat(AutoCleanForm): change deletion of msgs
- made faster deletion of old messages;
- added server error handling
2021-07-13 22:48:01 +03:00
Danich Volk 36fb40b6bd CalendarPicker:
+ Added days, monthes and years range check
+ Added language selection
* Fixed default language (it is English now)
2021-07-13 21:18:55 +03:00
FlorianDahn 47aa8c2aaa Extracting custom field conversion for use in other places 2021-06-07 01:35:02 +02:00
FlorianDahn 1709631965 adding GetObject and SaveObject methods for custom session serialization
- adding GetObject and SaveObject methods for custom session serialization
2021-06-07 01:33:57 +02:00
FlorianDahn 264a998052 Update FormBase.cs
- making more basic methods virtual for easiert overriding
- adding existing control check to AddControl method
2021-06-07 01:33:19 +02:00
FlorianDahn a00aaacbfb Update ButtonGrid.cs
- adding DeleteReplyMessage property for seperating now deleting the message from the user and the message (buttons) send by the control
2021-06-07 01:31:41 +02:00
Florian Dahn bd908db867 Merge pull request #4 from MajMcCloud/development
A lot of updates and fixes
2021-05-16 15:09:09 +02:00
FlorianDahn e2c485aede Adding some conversion checks for JSON State serialization 2021-04-25 15:51:19 +02:00
FlorianDahn c8936d0748 Adding more details to PromptDialog
- replacing the default EventArgs within the Completed event with a more detailed one
- adding new PromptDialogCompletedEventArgs class for easier details access
2021-03-29 23:51:39 +02:00
FlorianDahn 92f12735c8 Adding more details on ConfirmDialog
- adding a Tag property for optional use in ArrayPromptDialog and ConfirmDialog
- adding it to the ButtonClickedEventArgs
2021-03-29 23:50:42 +02:00
Florian Dahn 8142b626b2 Merge pull request #3 from Xilosof/bug/ApiRequestException-handling
Fix handling ApiRequestException when sending a request.
2021-03-14 20:34:07 +01:00
Xilosof 5dcbe04a73 Added initialization of MaxNumberOfRetries setting 2021-03-14 22:03:13 +03:00
Xilosof e742ded371 Change exception handling when sending a request.
1) Now RetryAfter  is multiplied by 1000, because request contains value in second instead milliseconds. (see https://core.telegram.org/bots/api#responseparameters)
2) Now calls occur in a loop, but a limited number of times. This also ensures that exceptions are caught during a repeated request.
2021-03-14 22:00:51 +03:00
Xilosof 706b0f522a Add static propert MaxNumberOfRetries.
This is necessary so that the DeviceSession instance can get this setting. There is no direct access to the settings in BotBase at the moment.
This property will be set when calling the Start method for the bot and is the same for all bots in the same application.
2021-03-14 21:55:07 +03:00
Xilosof 61e3652edf Add MaxNumberOfRetries setting.
Indicates the maximum number of times a request that received error 429 will be sent again after a timeout until it receives code 200 or an error code not equal to 429.
2021-03-14 21:43:07 +03:00
FlorianDahn c484edd427 Update README.md 2021-03-14 16:52:19 +01:00
FlorianDahn 181902336c Adding ChannelCreated messagetype to GroupForm 2021-03-14 16:51:25 +01:00
FlorianDahn dc364b5fd3 Fix for Cleanup method
- there was an collection changed exception which blocked the method from working
2021-03-04 15:17:06 +01:00
FlorianDahn 1fd4752c0e Slash fix 2021-03-02 15:25:35 +01:00
FlorianDahn d84be50243 Adding AutoCleanForm Fix for TaggedButtonGrid 2021-03-02 15:19:28 +01:00
FlorianDahn 1caa71cd25 Update to fix some bad behaviour with combination of AutoCleanForm 2021-03-01 22:53:32 +01:00
FlorianDahn e81e5f1854 Bot command extensions for default commands 2021-03-01 22:53:03 +01:00
FlorianDahn 399e056a8f Deleting messages update
- new constant for how much message deletions per second
- updating AutoCleanForm "Cleanup" process to use constant and using MessageDeleted eventhandler
2021-03-01 22:52:45 +01:00
FlorianDahn 26c4f479fa New internal MessageDeleted event handler for better control and form use. 2021-03-01 22:50:42 +01:00
FlorianDahn 72d94df907 FIX: new message loop will now correctly manage events and form switches 2021-03-01 22:14:36 +01:00
FlorianDahn 31e0683699 FIX: for using ButtonGrid within AutoCleanForm can cause to no message 2021-03-01 22:13:40 +01:00
FlorianDahn 676be49a62 Update MultiToggleButtons.cs 2021-03-01 01:54:49 +01:00
FlorianDahn 5b67f334ff MultiToggleButton minor updates
- updating localization
- adding AllowEmptySelection property
- updating test project
2021-03-01 01:48:17 +01:00
FlorianDahn 6a556af070 New control: MultiToggleButton
- new control for having multiple simple toggle options
2021-03-01 01:36:07 +01:00
FlorianDahn 4910a04923 Update README.md 2021-02-28 18:25:12 +01:00
FlorianDahn 10f4e1b745 New example project for async form updates 2021-02-28 18:23:21 +01:00
FlorianDahn 42b624c28f Fix for MessageType use when no Message is available 2021-02-28 18:22:08 +01:00
FlorianDahn 75013d51bd Remove old comments 2021-02-28 17:47:52 +01:00
FlorianDahn 7f3bcfe418 Speed/Performance optimization for AutoCleanForm 2021-02-28 17:46:49 +01:00
FlorianDahn f5e26924d8 Adding InvokeMessageLoop method
- For asyncronous form updates adding InvokeMessageLoop
2021-02-28 17:45:28 +01:00
FlorianDahn 884aa60fac Joining both message loops for easier maintainability 2021-02-28 17:44:35 +01:00
FlorianDahn adc18891e0 Update MessageResult.cs 2021-02-28 17:40:02 +01:00
FlorianDahn 07eb4bef75 Adding new controls to Readme 2021-02-28 15:44:05 +01:00
FlorianDahn dfe64b22ab New control: CheckedButtonList
- new control for having a checked listview with paging possible
- new CheckedChangedEventArgs class
- adding Test for CheckedButtonList
- refactoring MultiView Test
2021-02-28 15:35:49 +01:00
FlorianDahn 15a8b8897f Updates and improvements
- refactoring of ButtonGrid control for more readability
- refactoring of TaggedButtonGrid control for more readability
- adding Index parameter to ButtenClickedEventArgs
- adding FindRowByButton method to ButtonForm to get the row index
-
2021-02-28 15:34:04 +01:00
FlorianDahn 91048b4f7c Async invoke fixes and ButtonGrid update
- removing unused imports
- adding null check for async handler invokes
- fixing PageCount calculation on ButtonGrid
2021-02-27 20:51:47 +01:00
FlorianDahn 426bb078af Adding DebuggerDisplay attribute 2021-02-27 15:18:23 +01:00
FlorianDahn 63deb978a4 PageCount Fix for ButtonGrid
- replace constant 3 with LayoutRows property
2021-02-27 15:17:21 +01:00
FlorianDahn 1a2b5818aa New Control: TaggedButtonGrid
- tag your list with some strings and filter it right away
- adding Test to test project
- adding a new localization

PS: it is an improved copy of the normal ButtonGrid
2021-02-20 01:53:49 +01:00
FlorianDahn fc44b7d38c New Control: MultiView
- adding basic paging options
- adding GetOrigin method to find control or form who has sent a message
- adding Test for MultiView
2021-02-20 01:51:01 +01:00
FlorianDahn dc8cb81284 Adding Init method to controls 2021-02-20 01:39:37 +01:00
FlorianDahn 0202fc29a8 Merge branch 'master' of https://github.com/MajMcCloud/TelegramBotFramework 2021-02-19 15:03:33 +01:00
FlorianDahn 7e51126fd3 Fix for double sessions in sessionstate 2021-02-19 15:03:28 +01:00
Florian Dahn 67e82acf20 Update FUNDING.yml 2021-02-02 15:59:03 +01:00
Florian Dahn c32fc2c3da Update FUNDING.yml 2021-02-02 15:57:02 +01:00
Florian Dahn 4351fc7c68 Create FUNDING.yml 2021-02-02 15:56:27 +01:00
FlorianDahn 80d43ac369 Update DeviceSession.cs 2021-01-15 19:36:13 +01:00
FlorianDahn 376ba68e8e MAJOR CHANGE: Refactoring namespace for controls
Chaning namespace for controls depending on their use area to:

Controls.Hybrid
Controls.Inline
Controls.Reply

Updating example project as well.
2021-01-15 19:33:44 +01:00
FlorianDahn 6b404545df Update MessageResult.cs
- adding more parameters to ConfirmAction method
2021-01-15 16:53:45 +01:00
FlorianDahn a524fef0d5 Update DeviceSession.cs
Workaround: Unknown API differences
2020-12-23 03:09:47 +01:00
FlorianDahn 73ba36ea2b Optimization of API calls within DeviceSession
- replacing all API calls with new method "API" to cover APIRequestExceptions
- adding IDeviceSession interface for future use
- adding "API" method without result
2020-12-22 21:55:47 +01:00
FlorianDahn 46160b54ae Update DataResult.cs
- adding DownloadRawDocument & DownloadRawTextDocument functions
2020-12-22 15:40:18 +01:00
FlorianDahn 87690a3630 Update DeviceSession.cs
Adding a feature for making future API calls.
2020-12-22 15:37:05 +01:00
FlorianDahn 975a942993 Update ButtonGrid.cs
Small refactoring for ButtonGrid
2020-12-06 22:43:39 +01:00
FlorianDahn 4336ff1681 Session Updates 2020-12-04 17:19:11 +01:00
Florian Dahn 567a9f937f Update README.md 2020-11-23 13:51:25 +01:00
FlorianDahn 95b4ff77c5 Update README.md 2020-11-23 13:48:13 +01:00
FlorianDahn ba82c11d66 Update README.md 2020-11-23 13:46:28 +01:00
FlorianDahn c2e33da277 Adding SaveSessionState to SessionBase
Feature request: https://github.com/MajMcCloud/TelegramBotFramework/issues/2
2020-11-22 23:15:31 +01:00
FlorianDahn 259fa54236 Update ModalDialog.cs
- Adding await keyword
2020-11-03 23:52:35 +01:00
FlorianDahn f790a16e85 Merge branch 'master' of https://github.com/MajMcCloud/TelegramBotFramework 2020-11-03 20:38:40 +01:00
FlorianDahn 97fea333f7 Update ConfirmDialog.cs
- adding additional checks to ConfirmDialog
- adding AutoCloseOnClick property, to close this modal form after button click
2020-11-03 20:38:36 +01:00
FlorianDahn e1b31b0b9a Update PromptDialog.cs
- adding additional checks to promptdialog
2020-11-03 20:38:07 +01:00
Florian Dahn 7aca5a648f Update README.md 2020-10-31 16:22:47 +01:00
FlorianDahn f24c309f63 Update DeviceSession.cs
- adding ParseMode to Edit functions
- adding a Send method which the parameter of the DeviceId
2020-10-22 22:14:40 +02:00
FlorianDahn ba9fd8062c Update PromptDialog.cs
- added ReceivedMessage for further use
2020-10-20 19:11:04 +02:00
FlorianDahn b37c31f2bd Update BotBase.cs
- Bugfix, Unhandled actions has been producing a loop
2020-10-20 19:10:30 +02:00
FlorianDahn 2c34a178ee Update DeviceSession.cs
- adding caption parameter
2020-10-12 23:16:42 +02:00
FlorianDahn 2f030f3c12 Updates to ButtonGrid
- adding IsNavigationBarVisible property to ButtonGrid
- adding SubHeadLayout row for column "descriptions" like a table design
- uses FilterDuplicate with ByRow enabled to keep the full row on matches
2020-10-05 14:24:34 +02:00
FlorianDahn a364562fd3 Update ButtonForm.cs
- Modifying FilterDuplicate to allow full row filter or not
This will keep only the matches, or the full row where it matches.
2020-10-05 14:22:47 +02:00
FlorianDahn 8ef8733a2b Update DeviceSession.cs
- Adding the name parameter to SendPhoto methods
- Adding caption parameter to SendVideo methods
2020-10-05 14:21:57 +02:00
FlorianDahn 049b2081ec Update SessionBase.cs
Use of Fallback form has been missed in Session loading. Added now.
2020-09-15 23:46:30 +02:00
FlorianDahn 48b76a84be Update SessionBase.cs
- improving handling for Sessions loading with no default constructors available.
2020-09-15 16:42:40 +02:00
FlorianDahn 31c8231b2d Adding NavigationBarVisibility property to hide/show navigation buttons auto/never/always 2020-09-15 16:38:36 +02:00
FlorianDahn e9504f3b36 Update ButtonForm.cs
- adding method for adding one single button row
- fix for ToList method if no buttons are available
2020-09-15 16:36:54 +02:00
FlorianDahn 8592f4279d Update ButtonGrid.cs
Fix "Page 1 of 0" when no rows are existing.
2020-09-08 15:32:04 +02:00
FlorianDahn 2457773a12 Merge branch 'master' of https://github.com/MajMcCloud/TelegramBotFramework 2020-09-05 02:08:28 +02:00
FlorianDahn 46e65faf31 Adding Enum deserialization
Fixing issue in SessionBase where it does not correctly deserialize Enum's
2020-09-05 02:08:19 +02:00
FlorianDahn 193a4811bf Simplifiy AutoCleanForm
Improving serialization by replacing the message with just the ID
2020-09-05 02:07:48 +02:00
Florian Dahn 08a0de8087 Update README.md 2020-09-01 19:00:11 +02:00
FlorianDahn 82469cff70 - Adding not about search feature 2020-08-30 20:48:44 +02:00
Florian Dahn 81eafe1219 Merge pull request #1 from JTOne123/master
[PR] The proj files have been updated to enable SourceLink
2020-08-09 17:25:00 +02:00
FlorianDahn 183e89c36f Adding paging/search example 2020-08-09 17:22:19 +02:00
FlorianDahn ad6cf9539c Adding filter functionality to ButtonGrid
Adding filter functionality
2020-08-09 17:00:04 +02:00
FlorianDahn 46576eb819 Update ButtonForm.cs
adding method to create a ButtonForm duplicate and filter the single buttons, used for ButtonGrid
2020-08-09 16:59:25 +02:00
FlorianDahn cf9e2285f1 Adding DynamicButton for Button with dynamic Text updates
For use, call the ButtonGrid.Updated() method
2020-07-25 15:11:15 +02:00
FlorianDahn ecfacdadbb Update AssemblyInfo.cs 2020-07-25 15:09:01 +02:00
FlorianDahn c00c2e8d8f Update DeviceSession.cs
- adding Unban method
2020-07-25 15:08:55 +02:00
FlorianDahn bfd905d590 Update TelegramBotBase.csproj 2020-07-25 15:08:41 +02:00
FlorianDahn 7b1bf75dde Update ToggleButton
- adding ChangedString variable for custom message
2020-07-25 15:08:22 +02:00
FlorianDahn 7a7a65c3a7 Update FormBase.cs
- adding RemoveAllControls method
2020-07-25 15:07:36 +02:00
Pavlo Datsiuk 8a42a861cf [COMMIT] The proj files have been updated to enable SourceLink [TelegramBotBase.csproj] 2020-06-25 15:54:40 +03:00
FlorianDahn 47876681e0 IgnoreState and SaveState addings for better session serialization
- adding IgnoreState to all ModalDialogs to prevent them get saved.
- adding SaveState to AutoCleanForm to keep state
- change OldMessages property of AutoCleanForm to public
2020-05-07 23:49:08 +02:00
FlorianDahn 9314b4c0e5 Update ButtonGrid.cs
- Fix for async event timings, button click got sometimes fired after Render event
2020-05-06 20:56:38 +02:00
FlorianDahn 01c19b9900 Update README.md 2020-05-04 15:33:50 +02:00
FlorianDahn 0af587d27f Updating readme and test project 2020-05-04 15:33:21 +02:00
FlorianDahn 97b9176c3a Updating packages 2020-05-04 15:22:33 +02:00
FlorianDahn dfa479d409 Fix in StateMachines 2020-05-04 15:18:48 +02:00
174 changed files with 9751 additions and 2137 deletions
+2
View File
@@ -0,0 +1,2 @@
github: #[MajMcCloud]
custom: ["https://paypal.me/majmccloud", dahn.partners]

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

Before

Width:  |  Height:  |  Size: 784 KiB

After

Width:  |  Height:  |  Size: 784 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Before

Width:  |  Height:  |  Size: 307 KiB

After

Width:  |  Height:  |  Size: 307 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 328 KiB

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 756 KiB

Before

Width:  |  Height:  |  Size: 185 KiB

After

Width:  |  Height:  |  Size: 185 KiB

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

+5
View File
@@ -252,3 +252,8 @@ TelegramBotBase/Archive
/TelegramBotBase/TelegramBotBase.1.5.2.zip /TelegramBotBase/TelegramBotBase.1.5.2.zip
/TelegramBotBase/cpush.ps1 /TelegramBotBase/cpush.ps1
/TelegramBotBase/cpack.ps1 /TelegramBotBase/cpack.ps1
*.ps1
*.exe
*.snupkg
*.zip
*.nuspec
+378
View File
@@ -0,0 +1,378 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.VisualBasic.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-10.0.6.0" newVersion="10.0.6.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Win32.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Win32.Registry" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="netstandard" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Collections" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.11.0" newVersion="4.0.11.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Collections.Concurrent" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.11.0" newVersion="4.0.11.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Collections.NonGeneric" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Collections.Specialized" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.ComponentModel" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.ComponentModel.Annotations" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.2.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.ComponentModel.EventBasedAsync" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.11.0" newVersion="4.0.11.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.ComponentModel.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.ComponentModel.TypeConverter" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Console" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Data.Common" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Diagnostics.Contracts" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Diagnostics.Debug" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.11.0" newVersion="4.0.11.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Diagnostics.FileVersionInfo" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Diagnostics.Process" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Diagnostics.StackTrace" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.4.0" newVersion="4.0.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Diagnostics.TextWriterTraceListener" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Diagnostics.TraceSource" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Diagnostics.Tracing" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Drawing.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.3.0" newVersion="4.1.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IO.Compression.ZipFile" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IO.FileSystem" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IO.FileSystem.DriveInfo" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IO.FileSystem.Watcher" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IO.IsolatedStorage" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IO.MemoryMappedFiles" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IO.Pipes" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Linq" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Linq.Expressions" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Linq.Parallel" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Linq.Queryable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.NameResolution" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.NetworkInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Ping" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.11.0" newVersion="4.0.11.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Requests" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.11.0" newVersion="4.0.11.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Security" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.ServicePoint" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Sockets" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.WebHeaderCollection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.WebSockets" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.WebSockets.Client" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.ObjectModel" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.11.0" newVersion="4.0.11.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Reflection.Emit.ILGeneration" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Reflection.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Resources.ResourceManager" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Resources.Writer" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.VisualC" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.Extensions" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.InteropServices" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.Numerics" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.Serialization.Formatters" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.Serialization.Json" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.Serialization.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.3.0" newVersion="4.1.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.Serialization.Xml" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.3.0" newVersion="4.1.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Security.AccessControl" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Security.Claims" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Security.Cryptography.Algorithms" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.2.0" newVersion="4.2.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Security.Cryptography.Csp" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Security.Cryptography.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Security.Cryptography.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Security.Cryptography.X509Certificates" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Security.Principal" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Security.Principal.Windows" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Text.Encoding.Extensions" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.11.0" newVersion="4.0.11.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Text.Encodings.Web" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Text.RegularExpressions" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.11.0" newVersion="4.0.11.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Overlapped" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Parallel" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Thread" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.ThreadPool" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.12.0" newVersion="4.0.12.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Transactions.Local" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Xml.ReaderWriter" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Xml.XDocument" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.11.0" newVersion="4.0.11.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Xml.XmlSerializer" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.11.0" newVersion="4.0.11.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Xml.XPath" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Xml.XPath.XDocument" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{673A56F5-6110-4AED-A68D-562FD6ED3EA6}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>AsyncFormUpdates</RootNamespace>
<AssemblyName>AsyncFormUpdates</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="Telegram.Bot, Version=17.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Telegram.Bot.17.0.0\lib\netstandard2.0\Telegram.Bot.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="forms\AsyncFormEdit.cs" />
<Compile Include="forms\AsyncFormUpdate.cs" />
<Compile Include="forms\Start.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\TelegramBotBase\TelegramBotBase.csproj">
<Project>{0bd16fb9-7ed4-4ccb-83eb-5cee538e1b6c}</Project>
<Name>TelegramBotBase</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="System.Net.Requests" Version="4.3.0" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
<PackageReference Include="Telegram.Bot" Version="18.0.0" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
+51
View File
@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using TelegramBotBase.Builder;
namespace AsyncFormUpdates
{
class Program
{
static TelegramBotBase.BotBase bot = null;
static void Main(string[] args)
{
String apiKey = "APIKey";
bot = BotBaseBuilder.Create()
.QuickStart<forms.Start>(apiKey)
.Build();
bot.Start();
var timer = new Timer(5000);
timer.Elapsed += Timer_Elapsed;
timer.Start();
Console.ReadLine();
timer.Stop();
bot.Stop();
}
private static async void Timer_Elapsed(object sender, ElapsedEventArgs e)
{
foreach(var s in bot.Sessions.SessionList)
{
//Only for AsyncUpdateForm
if (s.Value.ActiveForm.GetType() != typeof(forms.AsyncFormUpdate) && s.Value.ActiveForm.GetType() != typeof(forms.AsyncFormEdit))
continue;
await bot.InvokeMessageLoop(s.Key);
}
}
}
}
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die einer Assembly zugeordnet sind.
[assembly: AssemblyTitle("AsyncFormUpdates")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AsyncFormUpdates")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
[assembly: ComVisible(false)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("673a56f5-6110-4aed-a68d-562fd6ed3ea6")]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TelegramBotBase.Attributes;
using TelegramBotBase.Base;
using TelegramBotBase.Form;
namespace AsyncFormUpdates.forms
{
public class AsyncFormEdit : FormBase
{
[SaveState]
int counter = 0;
int MessageId = 0;
public override async Task Load(MessageResult message)
{
counter++;
}
public override async Task Action(MessageResult message)
{
await message.ConfirmAction("");
switch (message.RawData ?? "")
{
case "back":
var st = new Start();
await NavigateTo(st);
break;
}
}
public override async Task Render(MessageResult message)
{
var bf = new ButtonForm();
bf.AddButtonRow("Back", "back");
if (MessageId != 0)
{
await Device.Edit(MessageId, $"Your current count is at: {counter}", bf);
}
else
{
var m = await Device.Send($"Your current count is at: {counter}", bf, disableNotification: true);
MessageId = m.MessageId;
}
}
}
}
@@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TelegramBotBase.Attributes;
using TelegramBotBase.Base;
using TelegramBotBase.Form;
namespace AsyncFormUpdates.forms
{
public class AsyncFormUpdate : AutoCleanForm
{
[SaveState]
int counter = 0;
public override async Task Load(MessageResult message)
{
counter++;
}
public override async Task Action(MessageResult message)
{
await message.ConfirmAction("");
switch (message.RawData ?? "")
{
case "back":
var st = new Start();
await NavigateTo(st);
break;
}
}
public override async Task Render(MessageResult message)
{
var bf = new ButtonForm();
bf.AddButtonRow("Back", "back");
await Device.Send($"Your current count is at: {counter}", bf, disableNotification: true);
}
}
}
+52
View File
@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TelegramBotBase.Base;
using TelegramBotBase.Form;
namespace AsyncFormUpdates.forms
{
public class Start : AutoCleanForm
{
public override async Task Action(MessageResult message)
{
await message.ConfirmAction("");
switch (message.RawData ?? "")
{
case "async":
var afe = new AsyncFormEdit();
await NavigateTo(afe);
break;
case "async_del":
var afu = new AsyncFormUpdate();
await NavigateTo(afu);
break;
}
}
public override async Task Render(MessageResult message)
{
var bf = new ButtonForm();
bf.AddButtonRow("Open Async Form with AutoCleanupForm", "async_del");
bf.AddButtonRow("Open Async Form with Edit", "async");
await Device.Send("Choose your option", bf);
}
}
}
@@ -0,0 +1,12 @@
using Microsoft.EntityFrameworkCore;
namespace EFCoreBot.Database;
public class BotDbContext : DbContext
{
public BotDbContext(DbContextOptions options) : base(options)
{
}
public DbSet<User> Users { get; set; }
}
+7
View File
@@ -0,0 +1,7 @@
namespace EFCoreBot.Database;
public class User
{
public long Id { get; set; }
public string LastMessage { get; set; }
}
+19
View File
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>disable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.9" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\TelegramBotBase\TelegramBotBase.csproj" />
</ItemGroup>
</Project>
+23
View File
@@ -0,0 +1,23 @@
using EFCoreBot;
using EFCoreBot.Database;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using TelegramBotBase.Builder;
var serviceCollection = new ServiceCollection()
.AddDbContext<BotDbContext>(x => x.UseInMemoryDatabase("TelegramBotBase"));
var serviceProvider = serviceCollection.BuildServiceProvider();
var bot = BotBaseBuilder.Create()
.WithAPIKey(Environment.GetEnvironmentVariable("API_KEY") ?? throw new Exception("API_KEY is not set"))
.DefaultMessageLoop()
.WithServiceProvider<StartForm>(serviceProvider)
.NoProxy()
.NoCommands()
.NoSerialization()
.DefaultLanguage()
.Build();
bot.Start();
await Task.Delay(-1);
+36
View File
@@ -0,0 +1,36 @@
using EFCoreBot.Database;
using TelegramBotBase.Base;
using TelegramBotBase.Form;
namespace EFCoreBot;
public class StartForm : FormBase
{
private readonly BotDbContext _dbContext;
public StartForm(BotDbContext dbContext)
{
_dbContext = dbContext;
}
public override async Task Load(MessageResult message)
{
var user = await _dbContext.Users.FindAsync(Device.DeviceId);
if (user is null)
{
user = new User
{
Id = Device.DeviceId,
LastMessage = "<unknown>"
};
_dbContext.Users.Add(user);
await _dbContext.SaveChangesAsync();
}
await Device.Send($"Your last message's text was: `{user.LastMessage}`");
user.LastMessage = string.IsNullOrWhiteSpace(message.MessageText) ? "<unknown>" : message.MessageText;
await _dbContext.SaveChangesAsync();
}
}
+2 -2
View File
@@ -2,11 +2,11 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>net6.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="TelegramBotBase" Version="3.0.0" /> <PackageReference Include="TelegramBotBase" Version="5.0.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>
+4 -1
View File
@@ -1,4 +1,5 @@
using System; using System;
using TelegramBotBase.Builder;
namespace JoinHiderBot namespace JoinHiderBot
{ {
@@ -9,7 +10,9 @@ namespace JoinHiderBot
String apiKey = ""; String apiKey = "";
var bot = new TelegramBotBase.BotBase<forms.Start>(apiKey); var bot = BotBaseBuilder.Create()
.QuickStart<forms.Start>(apiKey)
.Build();
bot.Start(); bot.Start();
+4 -1
View File
@@ -1,4 +1,5 @@
using System; using System;
using TelegramBotBase.Builder;
namespace SystemCommandsBot namespace SystemCommandsBot
{ {
@@ -19,7 +20,9 @@ namespace SystemCommandsBot
return; return;
} }
var bot = new TelegramBotBase.BotBase<forms.StartForm>(BotConfig.ApiKey); var bot = BotBaseBuilder.Create()
.QuickStart<forms.StartForm>(BotConfig.ApiKey)
.Build();
bot.Start(); bot.Start();
@@ -2,12 +2,12 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>net6.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="TelegramBotBase" Version="3.0.0" /> <PackageReference Include="TelegramBotBase" Version="5.0.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>
+414 -459
View File
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,61 @@
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Threading.Tasks;
using Telegram.Bot.Types.InputFiles;
using Telegram.Bot.Types;
using TelegramBotBase.Sessions;
using TelegramBotBase.Form;
namespace TelegramBotBase.Extensions.Images
{
public static class ImageExtensions
{
public static Stream ToStream(this Image image, ImageFormat format)
{
var stream = new System.IO.MemoryStream();
image.Save(stream, format);
stream.Position = 0;
return stream;
}
/// <summary>
/// Sends an image
/// </summary>
/// <param name="image"></param>
/// <param name="name"></param>
/// <param name="buttons"></param>
/// <param name="replyTo"></param>
/// <param name="disableNotification"></param>
/// <returns></returns>
public static async Task<Message> SendPhoto(this DeviceSession session, Image image, String name, String caption, ButtonForm buttons = null, int replyTo = 0, bool disableNotification = false)
{
using (var fileStream = ToStream(image, ImageFormat.Png))
{
InputOnlineFile fts = new InputOnlineFile(fileStream, name);
return await session.SendPhoto(fts, caption: caption, buttons, replyTo, disableNotification);
}
}
/// <summary>
/// Sends an image
/// </summary>
/// <param name="image"></param>
/// <param name="name"></param>
/// <param name="buttons"></param>
/// <param name="replyTo"></param>
/// <param name="disableNotification"></param>
/// <returns></returns>
public static async Task<Message> SendPhoto(this DeviceSession session, Bitmap image, String name, String caption, ButtonForm buttons = null, int replyTo = 0, bool disableNotification = false)
{
using (var fileStream = ToStream(image, ImageFormat.Png))
{
InputOnlineFile fts = new InputOnlineFile(fileStream, name);
return await session.SendPhoto(fts, caption: caption, buttons, replyTo, disableNotification);
}
}
}
}
@@ -0,0 +1,8 @@
# TelegramBotBase.Extensions.Images
[![NuGet version (TelegramBotBase)](https://img.shields.io/nuget/v/TelegramBotBase.Extensions.Images.svg?style=flat-square)](https://www.nuget.org/packages/TelegramBotBase.Extensions.Images/)
[![Telegram chat](https://img.shields.io/badge/Support_Chat-Telegram-blue.svg?style=flat-square)](https://www.t.me/tgbotbase)
[![License](https://img.shields.io/github/license/MajMcCloud/telegrambotframework.svg?style=flat-square&maxAge=2592000&label=License)](https://raw.githubusercontent.com/MajMcCloud/TelegramBotFramework/master/LICENCE.md)
[![Package Downloads](https://img.shields.io/nuget/dt/TelegramBotBase.Extensions.Images.svg?style=flat-square&label=Package%20Downloads)](https://www.nuget.org/packages/TelegramBotBase.Extensions.Images)
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net5;netcoreapp3.1;net6</TargetFrameworks>
<RepositoryUrl>https://github.com/MajMcCloud/TelegramBotFramework</RepositoryUrl>
<PackageProjectUrl>https://github.com/MajMcCloud/TelegramBotFramework</PackageProjectUrl>
<Copyright>MIT</Copyright>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TelegramBotBase\TelegramBotBase.csproj" />
</ItemGroup>
</Project>
@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TelegramBotBase.Builder;
using TelegramBotBase.Builder.Interfaces;
namespace TelegramBotBase.Extensions.Serializer.Database.MSSQL
{
public static class BotBaseBuilderExtensions
{
/// <summary>
/// Uses an Microsoft SQL Server Database to save and restore sessions.
/// </summary>
/// <param name="builder"></param>
/// <param name="ConnectionString"></param>
/// <param name="tablePrefix"></param>
/// <param name="fallbackForm"></param>
/// <returns></returns>
public static ILanguageSelectionStage UseSQLDatabase(this ISessionSerializationStage builder, String ConnectionString, Type fallbackForm = null, String tablePrefix = "tgb_")
{
var serializer = new MSSQLSerializer(ConnectionString, tablePrefix, fallbackForm);
builder.UseSerialization(serializer);
return builder as BotBaseBuilder;
}
/// <summary>
/// Uses an Microsoft SQL Server Database to save and restore sessions.
/// </summary>
/// <param name="builder"></param>
/// <param name="HostOrIP"></param>
/// <param name="UserId"></param>
/// <param name="Password"></param>
/// <param name="DatabaseName"></param>
/// <param name="tablePrefix"></param>
/// <param name="fallbackForm"></param>
/// <returns></returns>
public static ILanguageSelectionStage UseSQLDatabase(this ISessionSerializationStage builder, String HostOrIP, String DatabaseName, String UserId, String Password, Type fallbackForm = null, String tablePrefix = "tgb_")
{
var connectionString = $"Server={HostOrIP}; Database={DatabaseName}; User Id={UserId}; Password={Password}; TrustServerCertificate=true;";
var serializer = new MSSQLSerializer(connectionString, tablePrefix, fallbackForm);
builder.UseSerialization(serializer);
return builder as BotBaseBuilder;
}
/// <summary>
/// Uses an Microsoft SQL Server Database with Windows Authentication to save and restore sessions.
/// </summary>
/// <param name="builder"></param>
/// <param name="HostOrIP"></param>
/// <param name="DatabaseName"></param>
/// <param name="tablePrefix"></param>
/// <param name="fallbackForm"></param>
/// <returns></returns>
public static ILanguageSelectionStage UseSQLDatabase(this ISessionSerializationStage builder, String HostOrIP, String DatabaseName, bool IntegratedSecurity = true, Type fallbackForm = null, String tablePrefix = "tgb_")
{
if (!IntegratedSecurity)
throw new ArgumentOutOfRangeException();
var connectionString = $"Server={HostOrIP}; Database={DatabaseName}; Integrated Security=true; TrustServerCertificate=true;";
var serializer = new MSSQLSerializer(connectionString, tablePrefix, fallbackForm);
builder.UseSerialization(serializer);
return builder as BotBaseBuilder;
}
}
}
@@ -0,0 +1,186 @@
using TelegramBotBase.Interfaces;
using TelegramBotBase.Builder.Interfaces;
using System;
using TelegramBotBase.Base;
using TelegramBotBase.Args;
using TelegramBotBase.Form;
using Microsoft.Data.SqlClient;
using System.Data;
namespace TelegramBotBase.Extensions.Serializer.Database.MSSQL
{
public class MSSQLSerializer : IStateMachine
{
public Type FallbackStateForm { get; set; }
public string ConnectionString { get; }
public String TablePrefix { get; set; }
/// <summary>
/// Will initialize the state machine.
/// </summary>
/// <param name="file">Path of the file and name where to save the session details.</param>
/// <param name="fallbackStateForm">Type of Form which will be saved instead of Form which has <seealso cref="Attributes.IgnoreState"/> attribute declared. Needs to be subclass of <seealso cref="Form.FormBase"/>.</param>
/// <param name="overwrite">Declares of the file could be overwritten.</param>
public MSSQLSerializer(String ConnectionString, String tablePrefix = "tgb_", Type fallbackStateForm = null)
{
if (ConnectionString is null)
{
throw new ArgumentNullException(nameof(ConnectionString));
}
this.ConnectionString = ConnectionString;
this.TablePrefix = tablePrefix;
this.FallbackStateForm = fallbackStateForm;
if (this.FallbackStateForm != null && !this.FallbackStateForm.IsSubclassOf(typeof(FormBase)))
{
throw new ArgumentException("FallbackStateForm is not a subclass of FormBase");
}
}
public StateContainer LoadFormStates()
{
var sc = new StateContainer();
using (var connection = new SqlConnection(ConnectionString))
{
connection.Open();
var command = connection.CreateCommand();
command.CommandText = "SELECT deviceId, deviceTitle, FormUri, QualifiedName FROM " + TablePrefix + "devices_sessions";
var dataTable = new DataTable();
using (var dataAdapter = new SqlDataAdapter(command))
{
dataAdapter.Fill(dataTable);
foreach (DataRow r in dataTable.Rows)
{
var se = new StateEntry()
{
DeviceId = (long)r["deviceId"],
ChatTitle = r["deviceTitle"].ToString(),
FormUri = r["FormUri"].ToString(),
QualifiedName = r["QualifiedName"].ToString()
};
sc.States.Add(se);
if (se.DeviceId > 0)
{
sc.ChatIds.Add(se.DeviceId);
}
else
{
sc.GroupIds.Add(se.DeviceId);
}
var data_command = connection.CreateCommand();
data_command.CommandText = "SELECT [key], value, type FROM " + TablePrefix + "devices_sessions_data WHERE deviceId = @deviceId";
data_command.Parameters.Add(new SqlParameter("@deviceId", r["deviceId"]));
var data_table = new DataTable();
using (var dataAdapter2 = new SqlDataAdapter(data_command))
{
dataAdapter2.Fill(data_table);
foreach (DataRow r2 in data_table.Rows)
{
var key = r2["key"].ToString();
var type = Type.GetType(r2["type"].ToString());
var value = Newtonsoft.Json.JsonConvert.DeserializeObject(r2["value"].ToString(), type);
se.Values.Add(key, value);
}
}
}
}
connection.Close();
}
return sc;
}
public void SaveFormStates(SaveStatesEventArgs e)
{
var container = e.States;
using (var connection = new SqlConnection(ConnectionString))
{
connection.Open();
//Cleanup old Session data
var clear_command = connection.CreateCommand();
clear_command.CommandText = $"DELETE FROM {TablePrefix}devices_sessions_data";
clear_command.ExecuteNonQuery();
clear_command.CommandText = $"DELETE FROM {TablePrefix}devices_sessions";
clear_command.ExecuteNonQuery();
//Prepare new session commands
var session_command = connection.CreateCommand();
var data_command = connection.CreateCommand();
session_command.CommandText = "INSERT INTO " + TablePrefix + "devices_sessions (deviceId, deviceTitle, FormUri, QualifiedName) VALUES (@deviceId, @deviceTitle, @FormUri, @QualifiedName)";
session_command.Parameters.Add(new SqlParameter("@deviceId", ""));
session_command.Parameters.Add(new SqlParameter("@deviceTitle", ""));
session_command.Parameters.Add(new SqlParameter("@FormUri", ""));
session_command.Parameters.Add(new SqlParameter("@QualifiedName", ""));
data_command.CommandText = "INSERT INTO " + TablePrefix + "devices_sessions_data (deviceId, [key], value, type) VALUES (@deviceId, @key, @value, @type)";
data_command.Parameters.Add(new SqlParameter("@deviceId", ""));
data_command.Parameters.Add(new SqlParameter("@key", ""));
data_command.Parameters.Add(new SqlParameter("@value", ""));
data_command.Parameters.Add(new SqlParameter("@type", ""));
//Store session data in database
foreach (var state in container.States)
{
session_command.Parameters["@deviceId"].Value = state.DeviceId;
session_command.Parameters["@deviceTitle"].Value = state.ChatTitle ?? "";
session_command.Parameters["@FormUri"].Value = state.FormUri;
session_command.Parameters["@QualifiedName"].Value = state.QualifiedName;
session_command.ExecuteNonQuery();
foreach (var data in state.Values)
{
data_command.Parameters["@deviceId"].Value = state.DeviceId;
data_command.Parameters["@key"].Value = data.Key;
var type = data.Value.GetType();
if (type.IsPrimitive || type.Equals(typeof(string)))
{
data_command.Parameters["@value"].Value = data.Value;
}
else
{
data_command.Parameters["@value"].Value = Newtonsoft.Json.JsonConvert.SerializeObject(data.Value);
}
data_command.Parameters["@type"].Value = type.AssemblyQualifiedName;
data_command.ExecuteNonQuery();
}
}
connection.Close();
}
}
}
}
@@ -0,0 +1,28 @@
# TelegramBotBase.Extensions.Serializer.Database.MSSQL
[![NuGet version (TelegramBotBase)](https://img.shields.io/nuget/v/TelegramBotBase.Extensions.Serializer.Database.MSSQL.svg?style=flat-square)](https://www.nuget.org/packages/TelegramBotBase.Extensions.Serializer.Database.MSSQL/)
[![Telegram chat](https://img.shields.io/badge/Support_Chat-Telegram-blue.svg?style=flat-square)](https://www.t.me/tgbotbase)
[![License](https://img.shields.io/github/license/MajMcCloud/telegrambotframework.svg?style=flat-square&maxAge=2592000&label=License)](https://raw.githubusercontent.com/MajMcCloud/TelegramBotFramework/master/LICENCE.md)
[![Package Downloads](https://img.shields.io/nuget/dt/TelegramBotBase.Extensions.Serializer.Database.MSSQL.svg?style=flat-square&label=Package%20Downloads)](https://www.nuget.org/packages/TelegramBotBase.Extensions.Serializer.Database.MSSQL)
## How to use
```csharp
using TelegramBotBase.Extensions.Serializer.Database.MSSQL;
var bot = BotBaseBuilder
.Create()
.WithAPIKey(APIKey)
.DefaultMessageLoop()
.WithStartForm<Start>()
.NoProxy()
.OnlyStart()
.UseSQLDatabase("localhost", "telegram_bot")
.UseEnglish()
.Build();
bot.Start();
```
@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net5;netcoreapp3.1;net6</TargetFrameworks>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<RepositoryUrl>https://github.com/MajMcCloud/TelegramBotFramework</RepositoryUrl>
<PackageProjectUrl>https://github.com/MajMcCloud/TelegramBotFramework</PackageProjectUrl>
<Copyright>MIT</Copyright>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<AssemblyVersion>1.0.1</AssemblyVersion>
<FileVersion>1.0.1</FileVersion>
<Version>1.0.1</Version>
<Description>A session serializer for Microsoft SQL Server.
</Description>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.0.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TelegramBotBase\TelegramBotBase.csproj" />
</ItemGroup>
</Project>
@@ -0,0 +1,37 @@
USE [telegram_bot]
GO
/****** Object: Table [dbo].[tgb_devices_sessions] Script Date: 30.06.2022 16:22:09 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[tgb_devices_sessions](
[deviceId] [bigint] NOT NULL,
[deviceTitle] [nvarchar](512) NOT NULL,
[FormUri] [nvarchar](512) NOT NULL,
[QualifiedName] [nvarchar](512) NOT NULL,
CONSTRAINT [PK_tgb_devices_sessions_1] PRIMARY KEY CLUSTERED
(
[deviceId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[tgb_devices_sessions_data] Script Date: 30.06.2022 16:22:09 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[tgb_devices_sessions_data](
[Id] [uniqueidentifier] NOT NULL,
[deviceId] [bigint] NOT NULL,
[key] [nvarchar](512) NOT NULL,
[value] [nvarchar](max) NOT NULL,
[type] [nvarchar](512) NOT NULL,
CONSTRAINT [PK_tgb_devices_session_data] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
ALTER TABLE [dbo].[tgb_devices_sessions_data] ADD CONSTRAINT [DF_tgb_devices_session_data_Id] DEFAULT (newid()) FOR [Id]
GO
+118
View File
@@ -0,0 +1,118 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Telegram.Bot.Types;
using TelegramBotBase;
using TelegramBotBase.Form;
using TelegramBotBaseTest.Tests;
using TelegramBotBase.Commands;
using TelegramBotBase.Builder;
namespace TelegramBotBaseTest
{
class Program
{
static async void Main(string[] args)
{
String APIKey = "";
var bb = BotBaseBuilder
.Create()
.WithAPIKey(APIKey)
.DefaultMessageLoop()
.WithStartForm<Start>()
.NoProxy()
.CustomCommands(a =>
{
a.Start("Starts the bot");
a.Add("myid", "Returns my Device ID");
a.Help("Should show you some help");
a.Settings("Should show you some settings");
a.Add("form1", "Opens test form 1");
a.Add("form2", "Opens test form 2");
a.Add("params", "Returns all send parameters as a message.");
})
.NoSerialization()
.UseEnglish()
.Build();
bb.BotCommand += Bb_BotCommand;
//Update Bot commands to botfather
await bb.UploadBotCommands();
bb.SetSetting(TelegramBotBase.Enums.eSettings.LogAllMessages, true);
bb.Message += (s, en) =>
{
Console.WriteLine(en.DeviceId + " " + en.Message.MessageText + " " + (en.Message.RawData ?? ""));
};
bb.Start();
Console.WriteLine("Telegram Bot started...");
Console.WriteLine("Press q to quit application.");
Console.ReadLine();
bb.Stop();
}
private static async Task Bb_BotCommand(object sender, TelegramBotBase.Args.BotCommandEventArgs en)
{
switch (en.Command)
{
case "/start":
var start = new Menu();
await en.Device.ActiveForm.NavigateTo(start);
break;
case "/form1":
var form1 = new TestForm();
await en.Device.ActiveForm.NavigateTo(form1);
break;
case "/form2":
var form2 = new TestForm2();
await en.Device.ActiveForm.NavigateTo(form2);
break;
case "/myid":
await en.Device.Send($"Your Device ID is: {en.DeviceId}");
en.Handled = true;
break;
case "/params":
String m = en.Parameters.DefaultIfEmpty("").Aggregate((a, b) => a + " and " + b);
await en.Device.Send("Your parameters are: " + m, replyTo: en.Device.LastMessageId);
en.Handled = true;
break;
}
}
}
}
@@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp3.0;net461</TargetFrameworks> <TargetFrameworks>netcoreapp3.1;net5;net6</TargetFrameworks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Configurations>Debug;Release</Configurations> <Configurations>Debug;Release</Configurations>
</PropertyGroup> </PropertyGroup>
@@ -27,6 +27,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\TelegramBotBase.Extensions.Images\TelegramBotBase.Extensions.Images.csproj" />
<ProjectReference Include="..\TelegramBotBase\TelegramBotBase.csproj" /> <ProjectReference Include="..\TelegramBotBase\TelegramBotBase.csproj" />
</ItemGroup> </ItemGroup>
@@ -5,6 +5,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using TelegramBotBase.Args; using TelegramBotBase.Args;
using TelegramBotBase.Controls; using TelegramBotBase.Controls;
using TelegramBotBase.Controls.Hybrid;
using TelegramBotBase.Form; using TelegramBotBase.Form;
namespace TelegramBotBaseTest.Tests.Controls namespace TelegramBotBaseTest.Tests.Controls
@@ -44,7 +45,7 @@ namespace TelegramBotBaseTest.Tests.Controls
} }
private async void Bg_ButtonClicked(object sender, ButtonClickedEventArgs e) private async Task Bg_ButtonClicked(object sender, ButtonClickedEventArgs e)
{ {
if (e.Button == null) if (e.Button == null)
return; return;
@@ -0,0 +1,74 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TelegramBotBase.Args;
using TelegramBotBase.Controls;
using TelegramBotBase.Controls.Hybrid;
using TelegramBotBase.Form;
namespace TelegramBotBaseTest.Tests.Controls
{
public class ButtonGridPagingForm : AutoCleanForm
{
ButtonGrid m_Buttons = null;
public ButtonGridPagingForm()
{
this.DeleteMode = TelegramBotBase.Enums.eDeleteMode.OnLeavingForm;
this.Init += ButtonGridForm_Init;
}
private async Task ButtonGridForm_Init(object sender, InitEventArgs e)
{
m_Buttons = new ButtonGrid();
m_Buttons.KeyboardType = TelegramBotBase.Enums.eKeyboardType.ReplyKeyboard;
m_Buttons.EnablePaging = true;
m_Buttons.EnableSearch = true;
m_Buttons.HeadLayoutButtonRow = new List<ButtonBase>() { new ButtonBase("Back", "back") };
var countries = CultureInfo.GetCultures(CultureTypes.SpecificCultures);
ButtonForm bf = new ButtonForm();
foreach (var c in countries)
{
bf.AddButtonRow(new ButtonBase(c.EnglishName, c.EnglishName));
}
m_Buttons.ButtonsForm = bf;
m_Buttons.ButtonClicked += Bg_ButtonClicked;
this.AddControl(m_Buttons);
}
private async Task Bg_ButtonClicked(object sender, ButtonClickedEventArgs e)
{
if (e.Button == null)
return;
if (e.Button.Value == "back")
{
var start = new Menu();
await this.NavigateTo(start);
}
else
{
await this.Device.Send($"Button clicked with Text: {e.Button.Text} and Value {e.Button.Value}");
}
}
}
}
@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TelegramBotBase.Args;
using TelegramBotBase.Controls;
using TelegramBotBase.Controls.Hybrid;
using TelegramBotBase.Form;
namespace TelegramBotBaseTest.Tests.Controls
{
public class ButtonGridTagForm : AutoCleanForm
{
TaggedButtonGrid m_Buttons = null;
public ButtonGridTagForm()
{
this.DeleteMode = TelegramBotBase.Enums.eDeleteMode.OnLeavingForm;
this.Init += ButtonGridTagForm_Init;
}
private async Task ButtonGridTagForm_Init(object sender, InitEventArgs e)
{
m_Buttons = new TaggedButtonGrid();
m_Buttons.KeyboardType = TelegramBotBase.Enums.eKeyboardType.ReplyKeyboard;
m_Buttons.EnablePaging = true;
m_Buttons.HeadLayoutButtonRow = new List<ButtonBase>() { new ButtonBase("Back", "back") };
var countries = CultureInfo.GetCultures(CultureTypes.SpecificCultures);
ButtonForm bf = new ButtonForm();
foreach (var c in countries)
{
bf.AddButtonRow(new TagButtonBase(c.EnglishName, c.EnglishName, c.Parent.EnglishName));
}
m_Buttons.Tags = countries.Select(a => a.Parent.EnglishName).Distinct().OrderBy(a => a).ToList();
m_Buttons.SelectedTags = countries.Select(a => a.Parent.EnglishName).Distinct().OrderBy(a => a).ToList();
m_Buttons.EnableCheckAllTools = true;
m_Buttons.DataSource = new TelegramBotBase.Datasources.ButtonFormDataSource(bf);
m_Buttons.ButtonClicked += Bg_ButtonClicked;
this.AddControl(m_Buttons);
}
private async Task Bg_ButtonClicked(object sender, ButtonClickedEventArgs e)
{
if (e.Button == null)
return;
switch (e.Button.Value)
{
case "back":
var start = new Menu();
await this.NavigateTo(start);
return;
}
await this.Device.Send($"Button clicked with Text: {e.Button.Text} and Value {e.Button.Value}");
}
}
}
@@ -8,6 +8,7 @@ using TelegramBotBase.Base;
using TelegramBotBase.Form; using TelegramBotBase.Form;
using TelegramBotBase.Controls; using TelegramBotBase.Controls;
using TelegramBotBase.Args; using TelegramBotBase.Args;
using TelegramBotBase.Controls.Inline;
namespace TelegramBotBaseTest.Tests.Controls namespace TelegramBotBaseTest.Tests.Controls
{ {
@@ -0,0 +1,92 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TelegramBotBase.Args;
using TelegramBotBase.Controls;
using TelegramBotBase.Controls.Hybrid;
using TelegramBotBase.Form;
namespace TelegramBotBaseTest.Tests.Controls
{
public class CheckedButtonListForm : AutoCleanForm
{
CheckedButtonList m_Buttons = null;
public CheckedButtonListForm()
{
this.DeleteMode = TelegramBotBase.Enums.eDeleteMode.OnLeavingForm;
this.Init += CheckedButtonListForm_Init;
}
private async Task CheckedButtonListForm_Init(object sender, InitEventArgs e)
{
m_Buttons = new CheckedButtonList();
m_Buttons.KeyboardType = TelegramBotBase.Enums.eKeyboardType.InlineKeyBoard;
m_Buttons.EnablePaging = true;
m_Buttons.HeadLayoutButtonRow = new List<ButtonBase>() { new ButtonBase("Back", "back"), new ButtonBase("Switch Keyboard", "switch") };
m_Buttons.SubHeadLayoutButtonRow = new List<ButtonBase>() { new ButtonBase("No checked items", "$") };
ButtonForm bf = new ButtonForm();
for (int i = 0; i < 30; i++)
{
bf.AddButtonRow($"{i + 1}. Item", i.ToString());
}
m_Buttons.DataSource = new TelegramBotBase.Datasources.ButtonFormDataSource(bf);
m_Buttons.ButtonClicked += Bg_ButtonClicked;
m_Buttons.CheckedChanged += M_Buttons_CheckedChanged;
this.AddControl(m_Buttons);
}
private async Task M_Buttons_CheckedChanged(object sender, CheckedChangedEventArgs e)
{
m_Buttons.SubHeadLayoutButtonRow = new List<ButtonBase>() { new ButtonBase($"{m_Buttons.CheckedItems.Count} checked items", "$") };
}
private async Task Bg_ButtonClicked(object sender, ButtonClickedEventArgs e)
{
if (e.Button == null)
return;
switch (e.Button.Value)
{
case "back":
var start = new Menu();
await NavigateTo(start);
break;
case "switch":
switch (m_Buttons.KeyboardType)
{
case TelegramBotBase.Enums.eKeyboardType.ReplyKeyboard:
m_Buttons.KeyboardType = TelegramBotBase.Enums.eKeyboardType.InlineKeyBoard;
break;
case TelegramBotBase.Enums.eKeyboardType.InlineKeyBoard:
m_Buttons.KeyboardType = TelegramBotBase.Enums.eKeyboardType.ReplyKeyboard;
break;
}
break;
default:
await Device.Send($"Button clicked with Text: {e.Button.Text} and Value {e.Button.Value}");
break;
}
}
}
}
@@ -8,6 +8,7 @@ using TelegramBotBase.Base;
using TelegramBotBase.Form; using TelegramBotBase.Form;
using TelegramBotBase.Controls; using TelegramBotBase.Controls;
using TelegramBotBase.Args; using TelegramBotBase.Args;
using TelegramBotBase.Controls.Inline;
namespace TelegramBotBaseTest.Tests.Controls namespace TelegramBotBaseTest.Tests.Controls
{ {
@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TelegramBotBase.Args;
using TelegramBotBase.Controls;
using TelegramBotBase.Controls.Inline;
using TelegramBotBase.Form;
namespace TelegramBotBaseTest.Tests.Controls
{
public class MultiToggleButtons : AutoCleanForm
{
public MultiToggleButtons()
{
this.DeleteMode = TelegramBotBase.Enums.eDeleteMode.OnLeavingForm;
this.Init += ToggleButtons_Init;
}
private async Task ToggleButtons_Init(object sender, InitEventArgs e)
{
var mtb = new MultiToggleButton();
mtb.Options = new List<ButtonBase>() { new ButtonBase("Option 1", "1"), new ButtonBase("Option 2", "2"), new ButtonBase("Option 3", "3") };
mtb.SelectedOption = mtb.Options.FirstOrDefault();
mtb.Toggled += Tb_Toggled;
this.AddControl(mtb);
mtb = new MultiToggleButton();
mtb.Options = new List<ButtonBase>() { new ButtonBase("Option 4", "4"), new ButtonBase("Option 5", "5"), new ButtonBase("Option 6", "6") };
mtb.SelectedOption = mtb.Options.FirstOrDefault();
mtb.AllowEmptySelection = false;
mtb.Toggled += Tb_Toggled;
this.AddControl(mtb);
}
private void Tb_Toggled(object sender, EventArgs e)
{
var tb = sender as MultiToggleButton;
if (tb.SelectedOption != null)
{
Console.WriteLine(tb.ID.ToString() + " was pressed, and toggled to " + tb.SelectedOption.Value);
return;
}
Console.WriteLine("Selection for " + tb.ID.ToString() + " has been removed.");
}
}
}
@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using TelegramBotBase.Base;
using TelegramBotBase.Controls.Hybrid;
using TelegramBotBase.Form;
namespace TelegramBotBaseTest.Tests.Controls
{
public class MultiViewForm : AutoCleanForm
{
Subclass.MultiViewTest mvt = null;
ButtonGrid bg = null;
public MultiViewForm()
{
this.DeleteMode = TelegramBotBase.Enums.eDeleteMode.OnLeavingForm;
this.Init += MultiViewForm_Init;
}
private async Task MultiViewForm_Init(object sender, TelegramBotBase.Args.InitEventArgs e)
{
mvt = new Subclass.MultiViewTest();
AddControl(mvt);
bg = new ButtonGrid();
bg.ButtonsForm = new ButtonForm();
bg.ButtonsForm.AddButtonRow("Back", "$back$");
bg.ButtonClicked += Bg_ButtonClicked;
bg.KeyboardType = TelegramBotBase.Enums.eKeyboardType.ReplyKeyboard;
AddControl(bg);
}
private async Task Bg_ButtonClicked(object sender, TelegramBotBase.Args.ButtonClickedEventArgs e)
{
switch(e.Button.Value)
{
case "$back$":
var mn = new Menu();
await NavigateTo(mn);
break;
}
}
}
}
@@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using TelegramBotBase.Args;
using TelegramBotBase.Base;
using TelegramBotBase.Form;
namespace TelegramBotBaseTest.Tests.Controls.Subclass
{
public class MultiViewTest : TelegramBotBase.Controls.Hybrid.MultiView
{
public override async Task Action(MessageResult result, string value = null)
{
switch (result.RawData)
{
case "back":
this.SelectedViewIndex--;
break;
case "next":
this.SelectedViewIndex++;
break;
}
}
public override async Task RenderView(RenderViewEventArgs e)
{
ButtonForm bf = new ButtonForm();
bf.AddButtonRow(new ButtonBase("Back", "back"), new ButtonBase("Next", "next"));
switch (e.CurrentView)
{
case 0:
case 1:
case 2:
await Device.Send($"Page {e.CurrentView + 1}", bf);
break;
default:
await Device.Send("Unknown Page", bf);
break;
}
}
}
}
@@ -5,6 +5,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using TelegramBotBase.Args; using TelegramBotBase.Args;
using TelegramBotBase.Controls; using TelegramBotBase.Controls;
using TelegramBotBase.Controls.Inline;
using TelegramBotBase.Form; using TelegramBotBase.Form;
namespace TelegramBotBaseTest.Tests.Controls namespace TelegramBotBaseTest.Tests.Controls
@@ -7,6 +7,7 @@ using TelegramBotBase.Form;
using TelegramBotBase.Controls; using TelegramBotBase.Controls;
using TelegramBotBase.Base; using TelegramBotBase.Base;
using TelegramBotBase.Args; using TelegramBotBase.Args;
using TelegramBotBase.Controls.Inline;
namespace TelegramBotBaseTest.Tests.Controls namespace TelegramBotBaseTest.Tests.Controls
{ {
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Telegram.Bot;
using Telegram.Bot.Types; using Telegram.Bot.Types;
using Telegram.Bot.Types.InputFiles; using Telegram.Bot.Types.InputFiles;
using Telegram.Bot.Types.ReplyMarkups; using Telegram.Bot.Types.ReplyMarkups;
@@ -0,0 +1,163 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using TelegramBotBase.Controls.Hybrid;
using TelegramBotBase.Datasources;
using TelegramBotBase.Form;
namespace TelegramBotBaseTest.Tests.Datasources
{
public class CustomDataSource : ButtonFormDataSource
{
public List<String> Countries = new List<string>() { "Country 1", "Country 2", "Country 3" };
public CustomDataSource()
{
loadData();
}
/// <summary>
/// This method has the example purpose of creating and loading some example data.
/// When using a database you do not need this kind of method.
/// </summary>
private void loadData()
{
//Exists data source? Read it
if (File.Exists(AppContext.BaseDirectory + "countries.json"))
{
try
{
var List = Newtonsoft.Json.JsonConvert.DeserializeObject<List<String>>(File.ReadAllText("countries.json"));
Countries = List;
}
catch
{
}
return;
}
//If not, create it
try
{
var countries = CultureInfo.GetCultures(CultureTypes.SpecificCultures).Select(a => a.DisplayName).ToList();
Countries = countries;
var tmp = Newtonsoft.Json.JsonConvert.SerializeObject(countries);
File.WriteAllText( AppContext.BaseDirectory + "countries.json", tmp);
}
catch
{
}
}
public override ButtonRow ItemAt(int index)
{
var item = Countries.ElementAt(index);
if (item == null)
return new ButtonRow();
return Render(item);
}
public override List<ButtonRow> ItemRange(int start, int count)
{
var items = Countries.Skip(start).Take(count);
List<ButtonRow> lst = new List<ButtonRow>();
foreach (var c in items)
{
lst.Add(Render(c));
}
return lst;
}
public override List<ButtonRow> AllItems()
{
List<ButtonRow> lst = new List<ButtonRow>();
foreach (var c in Countries)
{
lst.Add(Render(c));
}
return lst;
}
public override ButtonForm PickItems(int start, int count, string filter = null)
{
List<ButtonRow> rows = ItemRange(start, count);
ButtonForm lst = new ButtonForm();
foreach (var c in rows)
{
lst.AddButtonRow(c);
}
return lst;
}
public override ButtonForm PickAllItems(string filter = null)
{
List<ButtonRow> rows = AllItems();
ButtonForm bf = new ButtonForm();
bf.AddButtonRows(rows);
return bf;
}
public override int CalculateMax(string filter = null)
{
if (filter == null)
return Countries.Count;
return Countries.Where(a => a.IndexOf(filter, StringComparison.InvariantCultureIgnoreCase) != -1).Count();
}
public override ButtonRow Render(object data)
{
var s = data as String;
if (s == null)
return new ButtonRow(new ButtonBase("Empty", "zero"));
return new ButtonRow(new ButtonBase(s, s));
}
public override int Count
{
get
{
return Countries.Count;
}
}
public override int ColumnCount
{
get
{
return 1;
}
}
public override int RowCount
{
get
{
return this.Count;
}
}
}
}
@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using TelegramBotBase.Base;
using TelegramBotBase.Controls.Hybrid;
using TelegramBotBase.Form;
namespace TelegramBotBaseTest.Tests.Datasources
{
public class List : FormBase
{
ButtonGrid __buttons = null;
public List()
{
this.Init += List_Init;
}
private async Task List_Init(object sender, TelegramBotBase.Args.InitEventArgs e)
{
__buttons = new ButtonGrid();
__buttons.EnablePaging = true;
__buttons.EnableSearch = false;
__buttons.ButtonClicked += __buttons_ButtonClicked;
__buttons.KeyboardType = TelegramBotBase.Enums.eKeyboardType.ReplyKeyboard;
__buttons.DeleteReplyMessage = true;
__buttons.HeadLayoutButtonRow = new ButtonRow(new ButtonBase("Back", "back"));
var cds = new CustomDataSource();
__buttons.DataSource = cds;
AddControl(__buttons);
}
private async Task __buttons_ButtonClicked(object sender, TelegramBotBase.Args.ButtonClickedEventArgs e)
{
switch(e.Button.Value)
{
case "back":
var mn = new Menu();
await NavigateTo(mn);
break;
}
}
}
}
@@ -12,7 +12,7 @@ namespace TelegramBotBaseTest.Tests.Groups
public class LinkReplaceTest : TelegramBotBase.Form.GroupForm public class LinkReplaceTest : TelegramBotBase.Form.GroupForm
{ {
Dictionary<int, int> Counter { get; set; } = new Dictionary<int, int>(); Dictionary<long, int> Counter { get; set; } = new Dictionary<long, int>();
private const int Maximum = 3; private const int Maximum = 3;
@@ -5,6 +5,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using TelegramBotBase.Base; using TelegramBotBase.Base;
using TelegramBotBase.Form; using TelegramBotBase.Form;
using TelegramBotBaseTest.Tests.Controls;
namespace TelegramBotBaseTest.Tests namespace TelegramBotBaseTest.Tests
{ {
@@ -27,6 +28,7 @@ namespace TelegramBotBaseTest.Tests
} }
await Device.HideReplyKeyboard();
} }
public override async Task Action(MessageResult message) public override async Task Action(MessageResult message)
@@ -39,7 +41,9 @@ namespace TelegramBotBaseTest.Tests
if (call == null) if (call == null)
return; return;
switch(call.Value) message.Handled = true;
switch (call.Value)
{ {
case "text": case "text":
@@ -91,8 +95,6 @@ namespace TelegramBotBaseTest.Tests
case "data": case "data":
message.Handled = true;
var data = new DataForm(); var data = new DataForm();
await this.NavigateTo(data); await this.NavigateTo(data);
@@ -101,8 +103,6 @@ namespace TelegramBotBaseTest.Tests
case "calendar": case "calendar":
message.Handled = true;
var calendar = new Controls.CalendarPickerForm(); var calendar = new Controls.CalendarPickerForm();
await this.NavigateTo(calendar); await this.NavigateTo(calendar);
@@ -111,8 +111,6 @@ namespace TelegramBotBaseTest.Tests
case "month": case "month":
message.Handled = true;
var month = new Controls.MonthPickerForm(); var month = new Controls.MonthPickerForm();
await this.NavigateTo(month); await this.NavigateTo(month);
@@ -121,8 +119,6 @@ namespace TelegramBotBaseTest.Tests
case "treeview": case "treeview":
message.Handled = true;
var tree = new Controls.TreeViewForms(); var tree = new Controls.TreeViewForms();
await this.NavigateTo(tree); await this.NavigateTo(tree);
@@ -131,21 +127,90 @@ namespace TelegramBotBaseTest.Tests
case "togglebuttons": case "togglebuttons":
message.Handled = true;
var tb = new Controls.ToggleButtons(); var tb = new Controls.ToggleButtons();
await this.NavigateTo(tb); await this.NavigateTo(tb);
break; break;
case "buttongrid":
message.Handled = true; case "multitogglebuttons":
var mtb = new Controls.MultiToggleButtons();
await this.NavigateTo(mtb);
break;
case "buttongrid":
var bg = new Controls.ButtonGridForm(); var bg = new Controls.ButtonGridForm();
await this.NavigateTo(bg); await this.NavigateTo(bg);
break;
case "buttongridfilter":
var bg2 = new Controls.ButtonGridPagingForm();
await this.NavigateTo(bg2);
break;
case "buttongridtags":
var bg3 = new Controls.ButtonGridTagForm();
await this.NavigateTo(bg3);
break;
case "multiview":
var mvf = new MultiViewForm();
await NavigateTo(mvf);
break;
case "checkedbuttonlist":
var cbl = new CheckedButtonListForm();
await NavigateTo(cbl);
break;
case "navigationcontroller":
var nc = new Navigation.Start();
await NavigateTo(nc);
break;
case "dynamicbuttongrid":
var dg = new Datasources.List();
await NavigateTo(dg);
break;
case "notifications":
var not = new Notifications.Start();
await NavigateTo(not);
break;
default:
message.Handled = false;
break; break;
} }
@@ -173,8 +238,24 @@ namespace TelegramBotBaseTest.Tests
btn.AddButtonRow(new ButtonBase("#11 ToggleButtons", new CallbackData("a", "togglebuttons").Serialize())); btn.AddButtonRow(new ButtonBase("#11 ToggleButtons", new CallbackData("a", "togglebuttons").Serialize()));
btn.AddButtonRow(new ButtonBase("#11.2 MultiToggleButtons", new CallbackData("a", "multitogglebuttons").Serialize()));
btn.AddButtonRow(new ButtonBase("#12 ButtonGrid", new CallbackData("a", "buttongrid").Serialize())); btn.AddButtonRow(new ButtonBase("#12 ButtonGrid", new CallbackData("a", "buttongrid").Serialize()));
btn.AddButtonRow(new ButtonBase("#13 ButtonGrid Paging & Filter", new CallbackData("a", "buttongridfilter").Serialize()));
btn.AddButtonRow(new ButtonBase("#14 ButtonGrid Tags (Filter)", new CallbackData("a", "buttongridtags").Serialize()));
btn.AddButtonRow(new ButtonBase("#15 MultiView", new CallbackData("a", "multiview").Serialize()));
btn.AddButtonRow(new ButtonBase("#16 CheckedButtonList", new CallbackData("a", "checkedbuttonlist").Serialize()));
btn.AddButtonRow(new ButtonBase("#17 NavigationController (Push/Pop)", new CallbackData("a", "navigationcontroller").Serialize()));
btn.AddButtonRow(new ButtonBase("#18 Dynamic ButtonGrid (DataSources)", new CallbackData("a", "dynamicbuttongrid").Serialize()));
btn.AddButtonRow(new ButtonBase("#19 Notifications", new CallbackData("a", "notifications").Serialize()));
await this.Device.Send("Choose your test:", btn); await this.Device.Send("Choose your test:", btn);
} }
@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using TelegramBotBase.Form;
using TelegramBotBase.Form.Navigation;
namespace TelegramBotBaseTest.Tests.Navigation
{
class CustomController : NavigationController
{
public CustomController(FormBase form) : base(form)
{
}
public override Task PushAsync(FormBase form, params object[] args)
{
Console.WriteLine($"Pushes form (Count on stack {this.Index + 1})");
//Device.Send($"Pushes form (Count on stack {this.Index + 1})");
return base.PushAsync(form, args);
}
public override Task PopAsync()
{
Console.WriteLine($"Pops one form (Count on stack {this.Index + 1})");
//Device.Send($"Pops one form (Count on stack {this.Index + 1})");
return base.PopAsync();
}
public override Task PopToRootAsync()
{
Console.WriteLine($"Moved back to root (Count on stack {this.Index + 1})");
//Device.Send($"Moved back to root (Count on stack {this.Index + 1})");
return base.PopToRootAsync();
}
}
}
@@ -0,0 +1,88 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Telegram.Bot.Types;
using TelegramBotBase.Base;
using TelegramBotBase.Form;
namespace TelegramBotBaseTest.Tests.Navigation
{
public class Form1 : FormBase
{
Message msg = null;
public Form1()
{
this.Closed += Form1_Closed;
}
private async Task Form1_Closed(object sender, EventArgs e)
{
if (msg == null)
return;
await Device.DeleteMessage(msg);
}
public override async Task Action(MessageResult message)
{
if (message.Handled)
return;
await message.ConfirmAction();
switch (message.RawData)
{
case "next":
message.Handled = true;
var f1 = new Form1();
await NavigationController.PushAsync(f1);
break;
case "previous":
message.Handled = true;
//Pop's the current form and move the previous one. The root form will be the Start class.
await NavigationController.PopAsync();
break;
case "root":
message.Handled = true;
await NavigationController.PopToRootAsync();
break;
}
}
public override async Task Render(MessageResult message)
{
if (msg != null)
return;
var bf = new ButtonForm();
bf.AddButtonRow("Next page", "next");
bf.AddButtonRow("Previous page", "previous");
bf.AddButtonRow("Back to root", "root");
msg = await Device.Send($"Choose your options (Count on stack {NavigationController.Index + 1})", bf);
}
}
}
@@ -0,0 +1,91 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Telegram.Bot.Types;
using TelegramBotBase.Base;
using TelegramBotBase.Form;
using TelegramBotBase.Form.Navigation;
namespace TelegramBotBaseTest.Tests.Navigation
{
public class Start : FormBase
{
Message msg = null;
public Start()
{
}
public override async Task Load(MessageResult message)
{
}
public override async Task Action(MessageResult message)
{
if (message.Handled)
return;
await message.ConfirmAction();
switch (message.RawData)
{
case "yes":
message.Handled = true;
//Create navigation controller and navigate to it, keep the current form as root form so we can get back to here later
var nc = new CustomController(this);
nc.ForceCleanupOnLastPop = true;
var f1 = new Form1();
await nc.PushAsync(f1);
await NavigateTo(nc);
if (msg == null)
return;
await Device.DeleteMessage(msg);
break;
case "no":
message.Handled = true;
var mn = new Menu();
await NavigateTo(mn);
if (msg == null)
return;
await Device.DeleteMessage(msg);
break;
}
}
public override async Task Render(MessageResult message)
{
var bf = new ButtonForm();
bf.AddButtonRow("Yes", "yes");
bf.AddButtonRow("No", "no");
msg = await Device.Send("Open controller?", bf);
}
}
}
@@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using TelegramBotBase.Base;
using TelegramBotBase.Form;
namespace TelegramBotBaseTest.Tests.Notifications
{
public class Start : AutoCleanForm
{
bool sent = false;
public Start()
{
this.DeleteMode = TelegramBotBase.Enums.eDeleteMode.OnLeavingForm;
}
public override async Task Action(MessageResult message)
{
if (message.Handled)
return;
switch (message.RawData)
{
case "alert":
await message.ConfirmAction("This is an alert.", true);
break;
case "back":
var mn = new Menu();
await NavigateTo(mn);
break;
default:
await message.ConfirmAction("This is feedback");
break;
}
}
public override async Task Render(MessageResult message)
{
if (sent)
return;
var bf = new ButtonForm();
bf.AddButtonRow("Normal feeback", "normal");
bf.AddButtonRow("Alert Box", "alert");
bf.AddButtonRow("Back", "back");
await Device.Send("Choose your test", bf);
sent = true;
}
}
}
@@ -5,6 +5,7 @@ using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using TelegramBotBase.Base; using TelegramBotBase.Base;
using TelegramBotBase.Controls.Inline;
using TelegramBotBase.Form; using TelegramBotBase.Form;
namespace TelegramBotBaseTest.Tests namespace TelegramBotBaseTest.Tests
@@ -35,41 +36,41 @@ namespace TelegramBotBaseTest.Tests
if (call == null) if (call == null)
return; return;
TelegramBotBase.Controls.ProgressBar Bar = null; ProgressBar Bar = null;
switch (call.Value) switch (call.Value)
{ {
case "standard": case "standard":
Bar = new TelegramBotBase.Controls.ProgressBar(0, 100, TelegramBotBase.Controls.ProgressBar.eProgressStyle.standard); Bar = new ProgressBar(0, 100, ProgressBar.eProgressStyle.standard);
Bar.Device = this.Device; Bar.Device = this.Device;
break; break;
case "squares": case "squares":
Bar = new TelegramBotBase.Controls.ProgressBar(0, 100, TelegramBotBase.Controls.ProgressBar.eProgressStyle.squares); Bar = new ProgressBar(0, 100, ProgressBar.eProgressStyle.squares);
Bar.Device = this.Device; Bar.Device = this.Device;
break; break;
case "circles": case "circles":
Bar = new TelegramBotBase.Controls.ProgressBar(0, 100, TelegramBotBase.Controls.ProgressBar.eProgressStyle.circles); Bar = new ProgressBar(0, 100, ProgressBar.eProgressStyle.circles);
Bar.Device = this.Device; Bar.Device = this.Device;
break; break;
case "lines": case "lines":
Bar = new TelegramBotBase.Controls.ProgressBar(0, 100, TelegramBotBase.Controls.ProgressBar.eProgressStyle.lines); Bar = new ProgressBar(0, 100, ProgressBar.eProgressStyle.lines);
Bar.Device = this.Device; Bar.Device = this.Device;
break; break;
case "squaredlines": case "squaredlines":
Bar = new TelegramBotBase.Controls.ProgressBar(0, 100, TelegramBotBase.Controls.ProgressBar.eProgressStyle.squaredLines); Bar = new ProgressBar(0, 100, ProgressBar.eProgressStyle.squaredLines);
Bar.Device = this.Device; Bar.Device = this.Device;
break; break;
@@ -39,7 +39,6 @@ namespace TelegramBotBaseTest.Tests
case "reply": case "reply":
break; break;
case "navigate": case "navigate":
@@ -52,10 +51,10 @@ namespace TelegramBotBaseTest.Tests
default: default:
if (message.RawMessageData == null) if (message.UpdateData == null)
return; return;
this.LastMessage = message.RawMessageData.Message.Text; this.LastMessage = message.Message.Text;
break; break;
} }
@@ -8,6 +8,7 @@ using System.Threading.Tasks;
using Telegram.Bot.Types; using Telegram.Bot.Types;
using Telegram.Bot.Types.ReplyMarkups; using Telegram.Bot.Types.ReplyMarkups;
using TelegramBotBase.Base; using TelegramBotBase.Base;
using TelegramBotBase.Extensions.Images;
using TelegramBotBase.Form; using TelegramBotBase.Form;
namespace TelegramBotBaseTest.Tests namespace TelegramBotBaseTest.Tests
@@ -118,7 +119,7 @@ namespace TelegramBotBaseTest.Tests
btn.AddButtonRow(new ButtonBase("Request Prompt", CallbackData.Create("navigate", "prompt"))); btn.AddButtonRow(new ButtonBase("Request Prompt", CallbackData.Create("navigate", "prompt")));
await this.Device.SendPhoto(bmp, "Test", btn); await this.Device.SendPhoto(bmp, "Test", "", btn);
} }
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net452" /> <package id="Newtonsoft.Json" version="13.0.1" targetFramework="net5" />
<package id="System.Net.Requests" version="4.3.0" targetFramework="net452" /> <package id="System.Net.Requests" version="4.3.0" targetFramework="net5" />
<package id="Telegram.Bot" version="14.12.0" targetFramework="net452" /> <package id="Telegram.Bot" version="14.12.0" targetFramework="net5" />
</packages> </packages>
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using TelegramBotBase.Controls.Hybrid;
using TelegramBotBase.Form; using TelegramBotBase.Form;
namespace TelegramBotBase.Args namespace TelegramBotBase.Args
@@ -14,6 +15,12 @@ namespace TelegramBotBase.Args
{ {
public ButtonBase Button { get; set; } public ButtonBase Button { get; set; }
public int Index { get; set; }
public object Tag { get; set; }
public ButtonRow Row { get; set; }
public ButtonClickedEventArgs() public ButtonClickedEventArgs()
{ {
@@ -23,7 +30,20 @@ namespace TelegramBotBase.Args
public ButtonClickedEventArgs(ButtonBase button) public ButtonClickedEventArgs(ButtonBase button)
{ {
this.Button = button; this.Button = button;
this.Index = -1;
} }
public ButtonClickedEventArgs(ButtonBase button, int Index)
{
this.Button = button;
this.Index = Index;
}
public ButtonClickedEventArgs(ButtonBase button, int Index, ButtonRow row)
{
this.Button = button;
this.Index = Index;
this.Row = row;
}
} }
} }
@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Text;
using TelegramBotBase.Controls.Hybrid;
using TelegramBotBase.Form;
namespace TelegramBotBase.Args
{
public class CheckedChangedEventArgs : EventArgs
{
/// <summary>
/// Contains the index of the row where the button is inside.
/// Contains -1 when it is a layout button or not found.
/// </summary>
public int Index { get; set; }
/// <summary>
/// Contains all buttons within this row, excluding the checkbox.
/// </summary>
public ButtonRow Row { get; set; }
/// <summary>
/// Contains the new checked status of the row.
/// </summary>
public bool Checked { get; set; }
public CheckedChangedEventArgs()
{
}
public CheckedChangedEventArgs(ButtonRow row, int Index, bool Checked)
{
this.Row = row;
this.Index = Index;
this.Checked = Checked;
}
}
}
@@ -54,5 +54,10 @@ namespace TelegramBotBase.Args
return false; return false;
} }
public object GetObject(String key)
{
return Values[key];
}
} }
} }
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Telegram.Bot.Types;
namespace TelegramBotBase.Args
{
public class MessageDeletedEventArgs
{
public int MessageId
{
get;set;
}
public MessageDeletedEventArgs(int messageId)
{
this.MessageId = messageId;
}
}
}
+9 -2
View File
@@ -7,7 +7,7 @@ using Telegram.Bot.Types;
namespace TelegramBotBase.Args namespace TelegramBotBase.Args
{ {
public class MessageSentEventArgs public class MessageSentEventArgs : EventArgs
{ {
public int MessageId public int MessageId
{ {
@@ -19,9 +19,16 @@ namespace TelegramBotBase.Args
public Message Message { get; set; } public Message Message { get; set; }
public MessageSentEventArgs(Message message) /// <summary>
/// Contains the element, which has called the method.
/// </summary>
public Type Origin { get; set; }
public MessageSentEventArgs(Message message, Type Origin)
{ {
this.Message = message; this.Message = message;
this.Origin = Origin;
} }
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace TelegramBotBase.Args
{
public class PromptDialogCompletedEventArgs
{
public object Tag { get; set; }
public String Value { get; set; }
}
}
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace TelegramBotBase.Args
{
public class RenderViewEventArgs : EventArgs
{
public int CurrentView { get; set; }
public RenderViewEventArgs(int ViewIndex)
{
CurrentView = ViewIndex;
}
}
}
@@ -32,6 +32,10 @@ namespace TelegramBotBase.Args
{ {
Values[key] = value; Values[key] = value;
} }
public void SetObject(String key, object value)
{
Values[key] = value;
}
} }
} }

Some files were not shown because too many files have changed in this diff Show More