Skip to content

Commit dec4c4f

Browse files
added rss functionality to milla, watchlists now allow you to give them a color so they can actually show you what they matched, bunch of other changes
1 parent fd65e95 commit dec4c4f

File tree

8 files changed

+398
-32
lines changed

8 files changed

+398
-32
lines changed

.golangci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ linters-settings:
2727
- github.com/yuin/gluare
2828
- gitlab.com/megalithic-llc/gluasocket
2929
- github.com/layeh/gopher-json
30+
- github.com/mmcdole/gofeed

README.md

+75-14
Original file line numberDiff line numberDiff line change
@@ -175,62 +175,74 @@ ircChannels = ["#channel1", "#channel2"]
175175

176176
Please note that the bot does not have to join a channel to be usable. One can simply query the bot directly as well.<br/>
177177

178-
### databaseUser
178+
#### databaseUser
179179

180180
Name of the database user.
181181

182-
### databasePassword
182+
#### databasePassword
183183

184184
Password for the database user.
185185

186-
### databaseAddress
186+
#### databaseAddress
187187

188188
Address of the database.
189189

190-
### databaseName
190+
#### databaseName
191191

192192
Name of the database.
193193

194-
### ircProxy
194+
#### scrapeChannels
195+
196+
List of channels that the bot will scrape into a database table. You can later on use these databases for the custom commands.<br/>
197+
198+
#### ircProxy
195199

196200
Determines which proxy to use to connect to the IRC network:
197201

198202
```
199203
ircProxy = "socks5://127.0.0.1:9050"
200204
```
201205

202-
### llmProxy
206+
#### llmProxy
203207

204208
Determines which proxy to use to connect to the LLM endpoint:
205209

206210
```
207211
llmProxy = "socks5://127.0.0.1:9050"
208212
```
209213

210-
### ircdName
214+
#### ircdName
211215

212216
Name of the milla instance, must be unique across all instances.
213217

214-
### adminOnly
218+
#### adminOnly
215219

216220
Milla will only answer if the nick is in the admin list.
217221

218-
### webIRCGateway
222+
#### webIRCGateway
219223

220224
webirc gateway to use.
221225

222-
### webIRCHostname
226+
#### webIRCHostname
223227

224228
webirc hostname to use.
225229

226-
### webIRCPassword
230+
#### webIRCPassword
227231

228232
webirc password to use.
229233

230-
### webIRCAddress
234+
#### webIRCAddress
231235

232236
webirc address to use.
233237

238+
#### rssFile
239+
240+
The file that contains the rss feeeds.
241+
242+
#### channel
243+
244+
The channel to send the rss feeds to.
245+
234246
### plugins
235247

236248
A list of plugins to load:`plugins = ["./plugins/rss.lua", "./plugins/test.lua"]`
@@ -277,6 +289,32 @@ fgColor = 0
277289
bgColor = 28
278290
```
279291

292+
## RSS
293+
294+
The rss file is self-explanatory. Here's an example:
295+
296+
```json
297+
{
298+
"feeds": [
299+
{
300+
"name": "one",
301+
"url": "http://feeds.feedburner.com/crunchyroll/rss",
302+
"proxy": "socks5://172.17.0.1:9007",
303+
"userAgent": "Mozilla/5.0 (X11; U; Linux i686; pl; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1 (Ubuntu-edgy)",
304+
"timeout": 10
305+
},
306+
{
307+
"name": "two",
308+
"url": "http://feeds.feedburner.com/crunchyroll/rss/anime",
309+
"proxy": "socks5://172.17.0.1:9007",
310+
"userAgent": "Mozilla/5.0 (X11; U; Linux i686; pl; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1 (Ubuntu-edgy)",
311+
"timeout": 10
312+
}
313+
],
314+
"period": 3600
315+
}
316+
```
317+
280318
### Example Config File
281319

282320
```toml
@@ -311,10 +349,24 @@ skipTLSVerify = false
311349
useTLS = true
312350
plugins = ["/plugins/plugin1.lua", "/plugins/plugin2.lua"]
313351
adminOnly = false
352+
plugins = ["/plugins/ip.lua", "/plugins/urban.lua", "/plugins/remind.lua"]
353+
[ircd.devinet.watchlist.security]
354+
watchList = ["#securityfeeds"]
355+
watchFiles = ["/watchfiles/voidbox.list"]
356+
alertChannel = "#milla_alerts"
357+
[ircd.devinet.rss.manga]
358+
rssFile = "/rssfeeds/manga.json"
359+
channel = "#manga"
360+
[ircd.devinet.rss.anime]
361+
rssFile = "/rssfeeds/anime.json"
362+
channel = "#anime"
314363
[ircd.devinet.watchlist.security]
315364
watchList = ["#securityfeeds"]
316365
watchFiles = ["/watchfiles/voidbox.list"]
317366
alertChannel = "#milla_alerts"
367+
eventTypes = ["PRIVMSG"]
368+
fgColor = 0
369+
bgColor = 28
318370

319371
[ircd.liberanet]
320372
ircServer = "irc.libera.chat"
@@ -343,12 +395,12 @@ out = true
343395
ircProxy = "socks5://127.0.0.1:9051"
344396
llmProxy = "http://127.0.0.1:8181"
345397
adminOnly = true
346-
[ircd.devinet_terra.customCommands.digest]
398+
[ircd.liberanet.customCommands.digest]
347399
sql = "select log from liberanet_milla_us_market_news order by log desc;"
348400
limit = 300
349401
context = ["you are a sentiment-analysis bot"]
350402
prompt= "i have provided to you news headlines in the form of previous conversations between you and me using the user role. please provide the digest of the news for me."
351-
[ircd.devinet_terra.customCommands.summarize]
403+
[ircd.liberanet.customCommands.summarize]
352404
sql= "select log from liberanet_milla_us_market_news order by log desc;"
353405
limit= 300
354406
context = ["you are a sentiment-analysis bot"]
@@ -393,6 +445,14 @@ Load a plugin: `/load /plugins/rss.lua`
393445

394446
Unload a plugin: `/unload /plugins/rss.lua`
395447

448+
#### remind
449+
450+
Pings the user after the given amount in seconds: `/remind 1200`
451+
452+
#### roll
453+
454+
Rolls a number between 1 and 6 if no arguments are given. With one argument it rolls a number between 1 and the given number. With two arguments it rolls a number between the two numbers: `/rool 10000 66666`
455+
396456
## Deploy
397457

398458
### Docker
@@ -768,6 +828,7 @@ isp: Cloudflare, Inc -- query: 1.1.1.1 -- status: success -- regionName: Queensl
768828

769829
- Each lua plugin gets its own lua state and will run in a goroutine.<br/>
770830
- Lua plugins will not go through a proxy if they are not instructed to do so. If you are using the provided http module, you can set the proxy value before loading the http module as provided in the examples under `plugins`. The module will read and set the following environment variables in the order given:
831+
771832
- `ALL_PROXY`
772833
- `HTTPS_PROXY`
773834
- `HTTP_PROXY`

go.mod

+7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ require (
1212
github.com/kohkimakimoto/gluayaml v0.0.0-20160815032708-6fe413d49d73
1313
github.com/layeh/gopher-json v0.0.0-20201124131017-552bb3c4c3bf
1414
github.com/lrstanley/girc v0.0.0-20240125042120-9add3166e52e
15+
github.com/mmcdole/gofeed v1.3.0
1516
github.com/sashabaranov/go-openai v1.19.3
1617
github.com/yuin/gluare v0.0.0-20170607022532-d7c94f1a80ed
1718
github.com/yuin/gopher-lua v1.1.1
@@ -27,6 +28,8 @@ require (
2728
cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect
2829
cloud.google.com/go/compute/metadata v0.3.0 // indirect
2930
cloud.google.com/go/longrunning v0.5.6 // indirect
31+
github.com/PuerkitoBio/goquery v1.8.0 // indirect
32+
github.com/andybalholm/cascadia v1.3.1 // indirect
3033
github.com/dlclark/regexp2 v1.10.0 // indirect
3134
github.com/felixge/httpsnoop v1.0.4 // indirect
3235
github.com/go-logr/logr v1.4.1 // indirect
@@ -40,7 +43,11 @@ require (
4043
github.com/jackc/pgpassfile v1.0.0 // indirect
4144
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
4245
github.com/jackc/puddle/v2 v2.2.1 // indirect
46+
github.com/json-iterator/go v1.1.12 // indirect
4347
github.com/kr/text v0.2.0 // indirect
48+
github.com/mmcdole/goxpp v1.1.1-0.20240225020742-a0c311522b23 // indirect
49+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
50+
github.com/modern-go/reflect2 v1.0.2 // indirect
4451
github.com/rogpeppe/go-internal v1.12.0 // indirect
4552
go.opencensus.io v0.24.0 // indirect
4653
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect

go.sum

+21
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ cloud.google.com/go/longrunning v0.5.6 h1:xAe8+0YaWoCKr9t1+aWe+OeQgN/iJK1fEgZSXm
1313
cloud.google.com/go/longrunning v0.5.6/go.mod h1:vUaDrWYOMKRuhiv6JBnn49YxCPz2Ayn9GqyjaBT8/mA=
1414
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
1515
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
16+
github.com/PuerkitoBio/goquery v1.8.0 h1:PJTF7AmFCFKk1N6V6jmKfrNH9tV5pNE6lZMkG0gta/U=
17+
github.com/PuerkitoBio/goquery v1.8.0/go.mod h1:ypIiRMtY7COPGk+I/YbZLbxsxn9g5ejnI2HSMtkjZvI=
1618
github.com/ailncode/gluaxmlpath v0.0.0-20161126153117-6ce478ecb4a6 h1:FM0WudTZ+xeiXPJcs+X1Zg8JXe4vlb9P2GZYqCYjZkk=
1719
github.com/ailncode/gluaxmlpath v0.0.0-20161126153117-6ce478ecb4a6/go.mod h1:Ti1AvV2KUYtHEBX7eYbdAGEfFyKz9+lHrJPcr79Vkng=
1820
github.com/alecthomas/assert/v2 v2.2.1 h1:XivOgYcduV98QCahG8T5XTezV5bylXe+lBxLG2K2ink=
@@ -21,6 +23,8 @@ github.com/alecthomas/chroma/v2 v2.12.0 h1:Wh8qLEgMMsN7mgyG8/qIpegky2Hvzr4By6gEF
2123
github.com/alecthomas/chroma/v2 v2.12.0/go.mod h1:4TQu7gdfuPjSh76j78ietmqh9LiurGF0EpseFXdKMBw=
2224
github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk=
2325
github.com/alecthomas/repr v0.2.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
26+
github.com/andybalholm/cascadia v1.3.1 h1:nhxRkql1kdYCc8Snf7D5/D3spOX+dBgjA6u8x004T2c=
27+
github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA=
2428
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
2529
github.com/cjoudrey/gluahttp v0.0.0-20201111170219-25003d9adfa9 h1:rdWOzitWlNYeUsXmz+IQfa9NkGEq3gA/qQ3mOEqBU6o=
2630
github.com/cjoudrey/gluahttp v0.0.0-20201111170219-25003d9adfa9/go.mod h1:X97UjDTXp+7bayQSFZk2hPvCTmTZIicUjZQRtkwgAKY=
@@ -69,6 +73,7 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
6973
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
7074
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
7175
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
76+
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
7277
github.com/google/s2a-go v0.1.7 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o=
7378
github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw=
7479
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
@@ -88,6 +93,8 @@ github.com/jackc/pgx/v5 v5.5.5 h1:amBjrZVmksIdNjxGW/IiIMzxMKZFelXbUoPNb+8sjQw=
8893
github.com/jackc/pgx/v5 v5.5.5/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A=
8994
github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk=
9095
github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
96+
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
97+
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
9198
github.com/kohkimakimoto/gluayaml v0.0.0-20160815032708-6fe413d49d73 h1:e2UU76WBjv6W0QUuPHe2QfSAXLR1kouek1fcSUtnSrk=
9299
github.com/kohkimakimoto/gluayaml v0.0.0-20160815032708-6fe413d49d73/go.mod h1:I+YgUp/uc0hF+H4RuQjR+uzDJNjUz7Sm21e63UCLWWQ=
93100
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
@@ -98,6 +105,15 @@ github.com/layeh/gopher-json v0.0.0-20201124131017-552bb3c4c3bf h1:bg6J/5S/AeTz7
98105
github.com/layeh/gopher-json v0.0.0-20201124131017-552bb3c4c3bf/go.mod h1:E/q28EyUVBgBQnONAVPIdwvEsv4Ve0vaCA9JWim4+3I=
99106
github.com/lrstanley/girc v0.0.0-20240125042120-9add3166e52e h1:Y86mAFtJjS4P0atZ6QAKH88TV0ASQYJdIGWiOmJKoNY=
100107
github.com/lrstanley/girc v0.0.0-20240125042120-9add3166e52e/go.mod h1:lgrnhcF8bg/Bd5HA5DOb4Z+uGqUqGnp4skr+J2GwVgI=
108+
github.com/mmcdole/gofeed v1.3.0 h1:5yn+HeqlcvjMeAI4gu6T+crm7d0anY85+M+v6fIFNG4=
109+
github.com/mmcdole/gofeed v1.3.0/go.mod h1:9TGv2LcJhdXePDzxiuMnukhV2/zb6VtnZt1mS+SjkLE=
110+
github.com/mmcdole/goxpp v1.1.1-0.20240225020742-a0c311522b23 h1:Zr92CAlFhy2gL+V1F+EyIuzbQNbSgP4xhTODZtrXUtk=
111+
github.com/mmcdole/goxpp v1.1.1-0.20240225020742-a0c311522b23/go.mod h1:v+25+lT2ViuQ7mVxcncQ8ch1URund48oH+jhjiwEgS8=
112+
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
113+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
114+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
115+
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
116+
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
101117
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
102118
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
103119
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -147,6 +163,7 @@ golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73r
147163
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
148164
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
149165
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
166+
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
150167
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
151168
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
152169
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
@@ -161,10 +178,14 @@ golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5h
161178
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
162179
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
163180
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
181+
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
182+
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
164183
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
165184
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
185+
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
166186
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
167187
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
188+
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
168189
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
169190
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
170191
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=

main.go

+74
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"fmt"
1111
"index/suffixarray"
1212
"log"
13+
"math/rand"
1314
"net"
1415
"net/http"
1516
"net/url"
@@ -222,6 +223,8 @@ func getHelpString() string {
222223
helpString += "memstats - returns the memory status currently being used\n"
223224
helpString += "load - loads a lua script\n"
224225
helpString += "unload - unloads a lua script\n"
226+
helpString += "remind - reminds you in a given amount of seconds\n"
227+
helpString += "roll - rolls a dice. the number is between 1 and 6. One arg sets the upper limit. Two args sets the lower and upper limit in that order\n"
225228

226229
return helpString
227230
}
@@ -546,6 +549,71 @@ func runCommand(
546549
}
547550

548551
appConfig.deleteLstate(args[1])
552+
case "remind":
553+
if len(args) < 2 {
554+
client.Cmd.Reply(event, errNotEnoughArgs.Error())
555+
556+
break
557+
}
558+
559+
seconds, err := strconv.Atoi(args[1])
560+
if err != nil {
561+
client.Cmd.Reply(event, errNotEnoughArgs.Error())
562+
563+
break
564+
}
565+
566+
client.Cmd.Reply(event, "Ok, I'll remind you in "+args[1]+" seconds.")
567+
time.Sleep(time.Duration(seconds) * time.Second)
568+
569+
client.Cmd.ReplyTo(event, " Ping!")
570+
case "forget":
571+
572+
client.Cmd.Reply(event, "I no longer even know whether you're supposed to wear or drink a camel.'")
573+
case "roll":
574+
lowerLimit := 1
575+
upperLimit := 6
576+
577+
if len(args) == 1 {
578+
} else if len(args) == 2 {
579+
argOne, err := strconv.Atoi(args[1])
580+
581+
if err != nil {
582+
client.Cmd.Reply(event, errNotEnoughArgs.Error())
583+
584+
break
585+
}
586+
587+
upperLimit = argOne
588+
} else if len(args) == 3 {
589+
argOne, err := strconv.Atoi(args[1])
590+
591+
if err != nil {
592+
client.Cmd.Reply(event, errNotEnoughArgs.Error())
593+
594+
break
595+
}
596+
597+
lowerLimit = argOne
598+
599+
argTwo, err := strconv.Atoi(args[2])
600+
601+
if err != nil {
602+
client.Cmd.Reply(event, errNotEnoughArgs.Error())
603+
604+
break
605+
}
606+
607+
upperLimit = argTwo
608+
} else {
609+
client.Cmd.Reply(event, errors.New("too many args").Error())
610+
611+
break
612+
}
613+
614+
randomNumber := lowerLimit + rand.Intn(upperLimit-lowerLimit+1)
615+
616+
client.Cmd.ReplyTo(event, fmt.Sprint(randomNumber))
549617
default:
550618
_, ok := appConfig.LuaCommands[args[0]]
551619
if !ok {
@@ -1262,6 +1330,12 @@ func runIRC(appConfig TomlConfig) {
12621330
go WatchListHandler(irc, appConfig)
12631331
}
12641332

1333+
if len(appConfig.Rss) > 0 {
1334+
irc.Handlers.AddBg(girc.CONNECTED, func(client *girc.Client, _ girc.Event) {
1335+
go runRSS(&appConfig, irc)
1336+
})
1337+
}
1338+
12651339
for {
12661340
var dialer proxy.Dialer
12671341

0 commit comments

Comments
 (0)