Skip to content

Commit

Permalink
Update README.md, move default sqlite to database folder (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
ckreisl committed Jul 6, 2024
1 parent fb15920 commit f3dcb26
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ pytest.xml
coverage.xml

backups/
database/

*.db
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ The data is crawled from the official steam web api (https://steamcommunity.com/
## Features

* Get the latest news & updates about Counter Strike 2
* General Spam protection (chat based)
* Option command to retrieve only news or updates posts
* Data is crawled from the official website and checked every 15 minutes
* General spam protection (chat based)
* Option command to retrieve only interested posts about news, updates or external news
* Data is crawled from the official steam api and checked every few minutes (default: 15 minutes)


## Usage
Expand All @@ -45,7 +45,7 @@ To use [@CS2PostsBot](https://t.me/CS2PostsBot), simply start a chat with the bo

### Adding the Bot to a Group

Adding the bot to a group is possible. The person adding the bot to the group will be the admin of the bot. Which means only the admin can use the `/options` command to enable / disable news, updates or external news posts for the group chat.
Adding the bot to a group is possible. The person who adds the bot to the group will be the admin of the bot. Which means only the admin can use the `/options` command to enable / disable news, updates or external news posts for the group chat.

To prevent spamming a spam protection is implemented. After 3 (default) strikes the chat will be banned and receives a timeout. This affects the whole chat not only the user who spammed.

Expand Down Expand Up @@ -73,11 +73,13 @@ Possible environment variables:
for detailed information see `cs2posts/bot/settings.py`.


Create a docker image and run the bot. From the root folder exeucte the following commands:
Create a docker image and run the bot. From the root folder execute the following commands:

```bash
docker build -t cs2-posts-bot .
docker run -d -v cs2posts/data:/app/cs2posts/data --env-file .env --name cs2-posts-bot cs2-posts-bot
mkdir backups
mkdir database
docker build -t cs2-news-bot .
docker run -d -v backups:/app/backups/ -v database:/app/database --env-file .env --name cs2-news-bot cs2-news-bot
```

To start the cron job checking for news & updates write `/start` in the chat of your bot.
Expand Down
2 changes: 1 addition & 1 deletion cs2posts/bot/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
TELEGRAM_TOKEN = os.getenv('TELEGRAM_TOKEN')
CS2_UPDATE_CHECK_INTERVAL = int(os.getenv('CS2_UPDATE_CHECK_INTERVAL', 900))

# Database filepaths (default: sqlite.db for both if None)
# Database filepaths (default: database/sqlite.db for both if None)
CHAT_DB_FILEPATH = os.getenv('CHAT_DB_FILEPATH', None)
POST_DB_FILEPATH = os.getenv('POST_DB_FILEPATH', None)

Expand Down
4 changes: 3 additions & 1 deletion cs2posts/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ class SQLite(Database):

def __init__(self, filepath: Path | None) -> None:
if filepath is None:
filepath = Path(__file__).parent.parent / "sqlite.db"
filepath = Path(__file__).parent.parent / "database"
filepath.mkdir(parents=True, exist_ok=True)
filepath /= "sqlite.db"

super().__init__(filepath)

Expand Down

1 comment on commit f3dcb26

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
__init__.py00100% 
crawler.py300100% 
cs2.py831087%30, 37, 42, 50, 68, 89, 105, 118–120
db.py2092389%52–54, 75–78, 157, 159–160, 163–168, 354, 356–357, 360–361, 363–364
post.py79297%21, 61
bot
   __init__.py00100% 
   chats.py210100% 
   constants.py40100% 
   content.py76692%28, 49, 62, 90, 100, 106
   cs2.py3009568%37–42, 44–46, 97–100, 102–105, 107–109, 111–112, 114–116, 118–119, 121, 124, 126–130, 132–135, 137, 146, 150–153, 202, 316–319, 322–323, 325–326, 328, 330, 333–335, 338–339, 341–342, 344, 346, 349–351, 354–355, 357, 359–360, 362, 364, 367–369, 379, 381–383, 385–387, 389, 432, 434–436, 442, 444–446, 449, 452
   decorators.py330%1, 3, 5
   message.py1633379%83–86, 99, 120, 122, 132, 134–135, 137, 139–141, 150–153, 155, 167–170, 210, 213, 220, 222, 225–226, 241, 248–249, 266
   options.py982079%34, 41–43, 48–50, 52, 69, 73–74, 78, 80, 82, 85–87, 89, 159–160
   settings.py170100% 
   spam.py710100% 
   utils.py240100% 
parser
   __init__.py00100% 
   parser.py14192%21
   steam2telegram_html.py260100% 
   steam_list.py520100% 
   steam_news_image.py160100% 
   steam_news_youtube.py120100% 
   steam_update_heading.py210100% 
TOTAL131919385% 

Tests Skipped Failures Errors Time
137 0 💤 0 ❌ 0 🔥 3.943s ⏱️

Please sign in to comment.