Skip to content

Commit a56f980

Browse files
committed
feat: Update README.md with installation instructions and environment variables, add topic group check to purge command, rename getbotinfo to botinfo, and add new commands shahin and aran to GeneralCommands.
1 parent 569dfd8 commit a56f980

4 files changed

Lines changed: 62 additions & 30 deletions

File tree

README.md

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,48 +20,46 @@ Code Module Cop is a powerful and flexible group management bot for Telegram and
2020

2121
### Installation
2222

23-
1. Clone the repository:
23+
1. Clone the repository:
2424

2525
```bash
2626
git clone https://github.com/CodeModule-ir/cop.git
2727
cd cmcop
2828
```
2929

30-
2. Install dependencies:
30+
2. Install dependencies:
3131

3232
```bash
3333
npm install
3434
```
3535

36-
3. **Set Up Environment Variables**
36+
3. **Set Up Environment Variables**
3737

38-
The bot requires specific environment variables to run correctly. These are stored in a `.env` file in the root directory of your project. This file should not be committed to version control, so ensure it is listed in your `.gitignore`.
38+
The bot requires specific environment variables to run correctly. These are stored in a `.env` file in the root directory of your project. This file should not be committed to version control, so ensure it is listed in your `.gitignore`.
3939

40-
Create a `.env` file in the root of your project directory with the following content:
40+
Create a `.env` file in the root of your project directory with the following content:
4141

42-
```env
43-
TELEGRAM_BOT_TOKEN=your_bot_token_here
44-
DB_HOST=db
45-
DB_PORT=3306
46-
DB_USERNAME=your_db_username
47-
DB_PASSWORD=your_db_password
48-
DB_NAME=your_db_name
42+
```env
43+
44+
TELEGRAM_BOT_TOKEN=your_bot_token
45+
DB_USER=
46+
DB_HOST=
47+
DB_NAME=
48+
DB_PASSWORD=
49+
DB_PORT=
50+
DB_URL=postgres://username:password@host:port/database_name
51+
DATABASE_URL='' // for production
4952
```
50-
- **TELEGRAM_BOT_TOKEN**: Your Telegram bot token. You can obtain this by creating a bot on Telegram and getting the token from BotFather.
51-
- **DB_HOST**: The hostname of your database server. If you are running the database locally, this is often `localhost`. In containerized setups, this might be a service name like `db`.
52-
- **DB_PORT**: The port on which your database server is listening. For MySQL, this is typically `3306`.
53-
- **DB_USERNAME**: The username used to access your database.
54-
- **DB_PASSWORD**: The password associated with the database username.
55-
- **DB_NAME**: The name of the database that the bot will use.
5653

57-
4. **Start the Bot**
54+
4. **Start the Bot**
5855

59-
With the environment variables set, you can start the bot:
56+
With the environment variables set, you can start the bot:
6057

61-
```bash
62-
npm start
63-
```
64-
For detailed installation instructions, see the [INSTALLATION.md](./docs/INSTALLATION.md) file.
58+
```bash
59+
npm start
60+
```
61+
62+
For detailed installation instructions, see the [INSTALLATION.md](./docs/INSTALLATION.md) file.
6563

6664
## Usage
6765

src/bot/commands/admin/AdminCommands.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,12 @@ export class AdminCommands {
244244
/** Purge Command */
245245
static async purge(ctx: Context) {
246246
const reply = new BotReply(ctx);
247+
const chatInfo = new ChatInfo(ctx);
248+
const topicChat = chatInfo.chatIsTopic();
249+
if (topicChat) {
250+
await reply.textReply('The /purge command cannot be used in a topic group.');
251+
return;
252+
}
247253
const chatId = ctx.chat?.id;
248254
const replyToMessageId = ctx.message?.reply_to_message?.message_id;
249255
if (!chatId || !replyToMessageId) {

src/bot/commands/genearl/GeneralCommands.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Please reach out to us for assistance.
107107
statusCode: 500,
108108
})
109109
/** getBotInfo */
110-
public static async getbotinfo(ctx: Context) {
110+
public static async botinfo(ctx: Context) {
111111
const reply = new BotReply(ctx);
112112

113113
// Extract detailed information from BotInfo.json
@@ -126,4 +126,35 @@ This bot is designed to deliver fast and secure responses to users.
126126
`;
127127
await reply.markdownReply(botInfoMessage);
128128
}
129+
public static async shahin(ctx: Context) {
130+
await ctx.reply('دوستان.');
131+
setTimeout(() => {
132+
return ctx.reply('بحث تخصصی.');
133+
}, 2000);
134+
}
135+
private static aranState: Map<number, number> = new Map();
136+
static async aran(ctx: Context) {
137+
const userId = ctx.from?.id;
138+
if (!userId) return;
139+
140+
const currentState = GeneralCommands.aranState.get(userId) || 0;
141+
142+
switch (currentState) {
143+
case 0:
144+
await ctx.reply('Aran mode: Activated.');
145+
GeneralCommands.aranState.set(userId, 1);
146+
break;
147+
case 1:
148+
await ctx.reply('رفرنس بده.');
149+
GeneralCommands.aranState.set(userId, 2);
150+
break;
151+
case 2:
152+
await ctx.reply('Aran mode: deActivated.');
153+
GeneralCommands.aranState.set(userId, 0);
154+
break;
155+
default:
156+
GeneralCommands.aranState.set(userId, 0);
157+
break;
158+
}
159+
}
129160
}

src/utils/index.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ export const COMMANDS: string[] = [
55
'commands',
66
'date',
77
'viewsupportcontact',
8-
'getbotinfo',
8+
'botinfo',
99
/** Users Commands */
1010
'rules',
1111
'codetime',
1212
'future',
13-
'news',
1413
'groupinfo',
1514
'report',
1615
'cancel',
@@ -32,14 +31,13 @@ export const COMMANDS: string[] = [
3231
/** Mute Commands */
3332
'mute',
3433
'unmute',
35-
'mutelist',
3634
/** Admin Command */
3735
'grant',
3836
'revoke',
3937
/** BlackList Command */
4038
'blacklist',
41-
'rmbl',
4239
'abl',
40+
'rmbl',
4341
'clrbl',
4442
/** Rules Commands */
4543
'rules',
@@ -51,7 +49,6 @@ export const COMMANDS: string[] = [
5149
/** Group Setting Command */
5250
'welcome',
5351
/** General Commands */
54-
'group_stats',
5552
'shahin',
5653
'aran',
5754
] as const;

0 commit comments

Comments
 (0)