Skip to content

Commit 1828e02

Browse files
authored
Update README.md
1 parent 94063b3 commit 1828e02

File tree

1 file changed

+84
-1
lines changed

1 file changed

+84
-1
lines changed

README.md

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,85 @@
1+
![](http://tgwerewolf.com/logo.png)
12
# CSChatBot
2-
A fully modular chat bot in C#
3+
4+
CSChatBot is a bot framework for .NET devs looking to build a Telegram Bot
5+
6+
- Fully Modular - Build your modules quickly and simply
7+
- Dynamic Database - Modules can easily modify / change the database schema
8+
- Simple to use - even comes with a module template that you can install into Visual Studio
9+
10+
## Requirements
11+
12+
- This solution is built in VS2017, though modules can be built in any version of VS
13+
- This is a native .NET application, not dotnet core, so must run on Windows
14+
15+
> My overall goal with CSChatBot was
16+
> to provide a fast, simple solution
17+
> for other developers who didn't
18+
> completely understand how Telegram
19+
> Bot API works.
20+
> - Para
21+
22+
### Setup
23+
You can either download a release build, or clone the repo locally and compile yourself. When you start the bot, it will guide you through some basic setup, like getting your bot token ([from BotFather](https://t.me/BotFather)) and asking for any needed API keys.
24+
25+
### Building your own module
26+
There is a module template available in the releases. You can import than into VS, or just use the ModuleTemplate project included in the source.
27+
28+
#### Basic setup
29+
If you choose to create your own project, rather than using the template, you will need to install the Telegram.Bot library from Nuget
30+
```
31+
Install-Package Telegram.Bot -Pre
32+
```
33+
In addition to this, you will also need to reference some of the libraries from the source:
34+
- DB
35+
- Logger
36+
- ModuleFramework
37+
38+
You primary module class must have the `Module` attribute, as well as a few basic information variables:
39+
```cs
40+
[Module(Author = "My Name", Name = "MyModule", Version = "1.0")]
41+
```
42+
43+
The constructor for this class must also accept the arguments as shown below:
44+
```cs
45+
public MyModule(Instance db, Setting settings, TelegramBotClient bot)
46+
```
47+
48+
There are a couple attributes available to register your commands with the bot - `CallbackCommand` and `ChatCommand`. You can check the TestModule in CSChatBot project for examples. The `Triggers` variable will bot what the bot watches for - you can have multiple triggers for one command.
49+
50+
Again, Please look at the sample modules included.
51+
52+
#### Group Settings
53+
This is a new feature, and allows for dynamically adding / setting group configuration. You'll need to use the DB extensions to get the group, then you can get / set the setting you want. It also allows for `int`, `bool`, and `string` types. The last argument is the default value. If the field does not exist in the `chatgroup` table, it will be created with the default value.
54+
```cs
55+
var g = myDbInstance.GetGroupById(<groupid>)
56+
var someBool = g.GetSetting<bool>("SomeBool", myDbInstance, false);
57+
var someInt = g.GetSetting<int>("SomeInt", myDbInstance, 0);
58+
var someString = g.GetSetting<string>("SomeString", myDbInstance, "");
59+
```
60+
61+
Setting a group setting is very similar:
62+
```cs
63+
var someBool = true;
64+
var someInt = 5;
65+
g.SetSetting<bool>("SomeBool", myDbInstance, false, someBool);
66+
var success = g.SetSetting<int>("SomeInt", myDbInstance, 0, someInt);
67+
```
68+
69+
70+
### Modules
71+
72+
There are a few modules included with CSChatBot
73+
74+
| Module | Description | Project |
75+
| ------ | ------ | ------ |
76+
| Admin | Basic admin commands | CSChatBot |
77+
| Base | Basic commands, like !modules | CSChatBot |
78+
| Basic | Simple commands, like !lmgtfy | CSChatBot |
79+
| User Functions | Basic user commands, like !points | CSChatBot |
80+
| Mitsuku | A chat bot users can chat with | Cleverbot |
81+
| Misc | Random stuff, like NSFW image detection and other things | Misc |
82+
| Weather | A sample module that gets the weather for the user | WeatherModule |
83+
| XKCD | A module for searching XKCD of course :) | XKCD |
84+
85+

0 commit comments

Comments
 (0)