Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
wh0o7 committed Sep 27, 2023
2 parents b50ed22 + 4a55fbd commit d7a0429
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 5 deletions.
86 changes: 86 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
[![Issues][issues-shield]][issues-url]

<h3 align="center">Teachers Timetable Bot</h3>

<p align="center">
Telegram bot for sending actual info about timetable for teachers.
<br>
<a href="https://github.com/litolax/TeachersTimetable/issues">Report Bug</a>
·
<a href="https://github.com/litolax/TeachersTimetable/issues">Request Feature</a>
</p>
</div>

<!-- About the project -->
## About the project

This telegram bot can notify teachers about their updated timetables.

### Built With

* [.NET 6.0](https://dotnet.microsoft.com/en-us/download)

### Database
* [mongoDB](https://www.mongodb.com/try/download/community)

<!-- GETTING STARTED -->
## Getting Started
### Installation

1. Fork the git repository.
2. Clone the repository.
3. Install .NET 6.0.
* [.NET 6.0](https://dotnet.microsoft.com/en-us/download)
4. Create a `config.json` file in the root program directory. Example:
```json
{
"DbName": "",
"Host": "",
"Port": 27017,
"AuthorizationName": "",
"AuthorizationPassword": "",
"Token": "",
"Administrators": [
...
],
"Teachers": [
...
]
}
```
- "Administrators: an array of Telegram IDs."
- "Teachers: an array of teacher records."
- "To retrieve this array, you can use the following C# code:
```c#
using System.Text.Json;

const string inputString = "";/teachers list via string with separator ,
var teacherArray = inputString.Split(new[] { "," }, StringSplitOptions.None);
var jsonData = JsonSerializer.Serialize(new { Teachers = teacherArray });
File.WriteAllText("Teachers.json", jsonData);
Console.WriteLine("Data has been written to Teachers.json");
```

6. Install mongoDB.
* [mongoDB](https://www.mongodb.com/try/download/community)
7. Install geckodriver (for week screenshots).
* [geckodriver](https://github.com/mozilla/geckodriver/releases)

### Build
#### Linux
```markdown
dotnet publish TeachersTimetable -c Release -r ubuntu.21.04-x64 -p:PublishSingleFile=true --self-contained true
```

<!-- CONTACT -->
## Contact
Feel free to create issues, features, or pull requests.
<br>
Discord: config.json#8501
<br>
Project Link: [https://github.com/litolax/TeachersTimetable](https://github.com/litolax/TeachersTimetable)

<!-- MARKDOWN LINKS & IMAGES -->
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
[issues-shield]: https://img.shields.io/github/issues/litolax/TeachersTimetable.svg?style=for-the-badge
[issues-url]: https://github.com/litolax/TeachersTimetable/issues
5 changes: 3 additions & 2 deletions TeachersTimetable/Services/ParseService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ public class ParseService : IParseService
private static string LastWeekHtmlContent { get; set; }

public ParseService(IMongoService mongoService, IBotService botService, IFirefoxService firefoxService,
IDistributionService distributionService, IConfig<TeachersConfig> config)
IDistributionService distributionService, IConfig<TeachersConfig> teachers)
{
this._mongoService = mongoService;
this._botService = botService;
this._firefoxService = firefoxService;
this._distributionService = distributionService;
this.Teachers = config.Entries.Teachers;
this.Teachers = teachers.Entries.Teachers;
Console.WriteLine("Teachers: " + teachers.Entries.Teachers.Length);
if (!Directory.Exists("./cachedImages")) Directory.CreateDirectory("./cachedImages");

var parseTimer = new Timer(1_000_000)
Expand Down
6 changes: 3 additions & 3 deletions TeachersTimetable/TeachersTimetable.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Selenium.Support" Version="4.12.4" />
<PackageReference Include="Selenium.WebDriver" Version="4.12.4" />
<PackageReference Include="Selenium.Support" Version="4.13.1" />
<PackageReference Include="Selenium.WebDriver" Version="4.13.1" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.2" />
<PackageReference Include="Telegram.BotAPI" Version="6.8.0" />
<PackageReference Include="Telegram.BotAPI" Version="6.9.0" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit d7a0429

Please sign in to comment.