Skip to content

Commit e5f7449

Browse files
authored
Merge pull request #154 from n3d1117/feature/allow-disable-transcription-and-image-generation
Allow disabling image generation and transcriptions
2 parents 5062280 + 7cba39d commit e5f7449

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ Customize the configuration by copying `.env.example` and renaming it to `.env`,
5252
### Optional configuration
5353
| Parameter | Description | Default value |
5454
|------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------|
55+
| `ENABLE_IMAGE_GENERATION` | Whether to enable image generation via the `/image` command | true |
56+
| `ENABLE_TRANSCRIPTION` | Whether to enable transcriptions of audio and video messages | true |
5557
| `MONTHLY_USER_BUDGETS` | A comma-separated list of $-amounts per user from list `ALLOWED_TELEGRAM_USER_IDS` to set custom usage limit of OpenAI API costs for each. **Note**: by default, *no limits* for anyone (`*`) | `*` |
5658
| `MONTHLY_GUEST_BUDGET` | $-amount as usage limit for all guest users. Guest users are users in group chats that are not in the `ALLOWED_TELEGRAM_USER_IDS` list. Value is ignored if no usage limits are set in user budgets (`MONTHLY_USER_BUDGETS`="*") | `100.0` |
5759
| `PROXY` | Proxy to be used for OpenAI and Telegram bot (e.g. `http://localhost:8080`) | - |

bot/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ def main():
4848
'token': os.environ['TELEGRAM_BOT_TOKEN'],
4949
'admin_user_ids': os.environ.get('ADMIN_USER_IDS', '-'),
5050
'allowed_user_ids': os.environ.get('ALLOWED_TELEGRAM_USER_IDS', '*'),
51+
'enable_image_generation': os.environ.get('ENABLE_IMAGE_GENERATION', 'true').lower() == 'true',
52+
'enable_transcription': os.environ.get('ENABLE_TRANSCRIPTION', 'true').lower() == 'true',
5153
'monthly_user_budgets': os.environ.get('MONTHLY_USER_BUDGETS', '*'),
5254
'monthly_guest_budget': float(os.environ.get('MONTHLY_GUEST_BUDGET', '100.0')),
5355
'stream': os.environ.get('STREAM', 'true').lower() == 'true',

bot/telegram_bot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ async def image(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
173173
"""
174174
Generates an image for the given prompt using DALL·E APIs
175175
"""
176-
if not await self.check_allowed_and_within_budget(update, context):
176+
if not self.config['enable_image_generation'] or not await self.check_allowed_and_within_budget(update, context):
177177
return
178178

179179
chat_id = update.effective_chat.id
@@ -215,7 +215,7 @@ async def transcribe(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
215215
"""
216216
Transcribe audio messages.
217217
"""
218-
if not await self.check_allowed_and_within_budget(update, context):
218+
if not self.config['enable_transcription'] or not await self.check_allowed_and_within_budget(update, context):
219219
return
220220

221221
if self.is_group_chat(update) and self.config['ignore_group_transcriptions']:

0 commit comments

Comments
 (0)