-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMyBot.java
811 lines (751 loc) · 24.6 KB
/
MyBot.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
import org.jibble.pircbot.*;
import java.util.*;
import java.io.*;
import java.math.*;
import java.net.*;
public class MyBot extends PircBot {
HashMap<String, String> factoids = new HashMap<String, String>();
boolean factExists = true;
long time;
long time2;
long time3;
int counter;
int toKick;
double factor = 0.0;
private static String CHAN_SUPEROPS;
private static String CHAN_OPS;
private static String ADMINS;
private static String COM_ADMINS;
private static String OTRS;
private static String DATA_ADMINS;
private static String VOY_ADMINS;
private static String FILEMOVER;
private static String ROAD;
private static String META_ADMINS;
private static String CHECK;
private static String DATA_OS;
private static String CU;
private static String OS;
private static String GS;
private static String AAROADS_ADMINS;
private static String POINT_KEY;
private static String POINT_VALUE;
private static String TEMPLATE;
public static ArrayList<Channel> channelList; //should really be private...
int hash = 0;
/*
Reloads from certain configuration files
*/
public void reload() {
BufferedReader rights = null;
try {
URL urlObject = new URL("https://raw.githubusercontent.com/wikimedia-roads/my-bot/master/rights.list");
HttpURLConnection connection = (HttpURLConnection) urlObject.openConnection();
InputStream in = connection.getInputStream();
rights = new BufferedReader(new InputStreamReader(in));
this.CHAN_SUPEROPS = rights.readLine();
this.CHAN_OPS = rights.readLine();
this.ADMINS = rights.readLine();
this.COM_ADMINS = rights.readLine();
this.OTRS = rights.readLine();
this.DATA_ADMINS = rights.readLine();
this.VOY_ADMINS = rights.readLine();
this.FILEMOVER = rights.readLine();
this.ROAD = rights.readLine();
this.META_ADMINS = rights.readLine();
this.DATA_OS = rights.readLine();
this.CU = rights.readLine();
this.OS = rights.readLine();
this.AAROADS_ADMINS = rights.readLine();
this.TEMPLATE = rights.readLine();
this.GS = rights.readLine();
rights.close();
BufferedReader checker = new BufferedReader(new FileReader("check.txt"));
this.CHECK = checker.readLine();
checker.close();
} catch (MalformedURLException murle) {
System.out.println("URL string is invalid");
System.exit(0);
} catch (IOException ioe) {
System.out.println("Error opening URL connection");
System.exit(0);
}
}
/*
Runs when the bot starts; put all initialization stuff here!
*/
public MyBot() {
reload();
time = time2 = time3 = System.nanoTime();
counter = 0;
channelList = new ArrayList<Channel>();
try {
BufferedReader reader;
//set the nick
reader = new BufferedReader(new FileReader("nick.txt"));
this.setName(reader.readLine());
reader.close();
//read in the fact file
reader = new BufferedReader(new FileReader("factsin.txt"));
String line = null;
while ((line=reader.readLine()) != null)
{
String key = line;
line = reader.readLine();
String fact = line;
factoids.put(key,fact);
}
factoids.put("help", "This bot supports help, (super)op, quit, admin(@commons/meta/data/enwikivoyage/simple), checkuser, oversight(@data), filemover@commons, road, and bell, as well as basic link expansion. Learning and forgetting of commands is supported using is as well as answer. Ops can control the bot with !add and !remove.");
reader.close();
//read in the points alias
reader = new BufferedReader(new FileReader("point.txt"));
POINT_KEY = reader.readLine();
POINT_VALUE = reader.readLine();
reader.close();
toKick = 0;
}
catch (IOException e) {
}
}
private void sendSenderMessage(String channel, String sender, String message) {
sendMessage(channel, sender + message);
//sendMessage(channel, channel);
}
public void checkReassess() {
BufferedReader result = null;
try {
URL urlObject = new URL("https://en.wikipedia.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:U.S._Roads_project_articles_needing_reassessment&format=xml&rawcontinue=yes");
HttpURLConnection connection = (HttpURLConnection) urlObject.openConnection();
InputStream in = connection.getInputStream();
result = new BufferedReader(new InputStreamReader(in));
String line = result.readLine();
System.out.println(line);
if (!line.equals("<?xml version=\"1.0\"?><api><query><categorymembers /></query></api>")) {
line = line.replace("<?xml version=\"1.0\"?><api><query><categorymembers>","");
line = line.replace("</categorymembers></query></api>","");
line = line.replace("<","");
String[] items = line.split("/>");
int newHash = 0;
for (int i = 0; i<items.length; i++) {
items[i] = items[i].replace("\"","");
items[i] = items[i].substring((items[i].indexOf(":")+1),items[i].length()-1);
items[i] = items[i].replace(" ","_");
newHash+=items[i].hashCode();
}
if (hash != newHash) {
if (items.length > 0) {
sendMessage("#wikipedia-en-roads","!bell");
sendMessage("#wikipedia-en-roads","An editor has requested the reassessment of an article:");
}
for (int i = 0; i<items.length; i++) {
sendMessage("#wikipedia-en-roads", "https://en.wikipedia.org/wiki/"+items[i]);
}
}
hash = newHash;
}
} catch (MalformedURLException murle) {
System.out.println("URL string is invalid");
} catch (IOException ioe) {
System.out.println("Error opening URL connection");
}
}
public void onServerPing(String response) {
super.onServerPing(response);
checkReassess();
}
public boolean checkTime(String channel) {
long now = System.nanoTime();
if (counter > 2) {
if (now-time <= 1.2e11) {
time = time2;
time2 = time3;
time3 = System.nanoTime();
sendAction(channel, "barfs");
sendMessage("Chanserv","OP "+ channel);
toKick++;
return true;
}
}
time = time2;
time2 = time3;
time3 = System.nanoTime();
return false;
}
public boolean isOp(String name, String channel) {
org.jibble.pircbot.User[] users = getUsers(channel);
for (org.jibble.pircbot.User user:users) {
if (user.equals(name)) {
if (user.isOp()) {
return true;
}
}
}
return false;
}
public boolean isOn(String name, String channel) {
System.err.println(name + " "+ channel);
org.jibble.pircbot.User[] users = getUsers(channel);
for (org.jibble.pircbot.User user:users) {
if (user.equals(name)) {
return true;
}
}
return false;
}
public void onPrivateMessage(String sender, String login, String hostname, String message ) {
if (message.startsWith("!op")) {
sendMessage(sender, sender+CHAN_OPS);
}
else if (message.equals("!check")) {
checkReassess();
}
else if (message.equals("!gag")) {
counter++;
factor++;
if (!checkTime("#wikipedia-en-roads"))
sendAction("#wikipedia-en-roads", "gags");
}
else if (message.startsWith("!reset")) {
sendMessage("Chanserv","OP #wikipedia-en-roads -USRD_bot");
sendMessage("Chanserv","OP ##rschen7754 -USRD_bot");
counter = 0;
reload();
}
else if (message.startsWith("!factor")) {
sendMessage(sender, "Factor is: "+factor);
}
else if (message.startsWith("!")) {
String key = message.replace("!","");
if (message.contains(" answer "))
{
sendMessage(sender, "Must do this in the channel.");
}
else if (message.contains(" is "))
{
sendMessage(sender, "Must do this in the channel.");
}
else if (factoids.containsKey(key.trim())==true)
sendMessage(sender, factoids.get(key));
else
sendMessage(sender, key + "? I don't know what you're going on about...");
}
}
public void onKick(String channel, String kickerNick, String kickerLogin, String kickerHostname, String recipientNick, String reason) {
sendMessage("MemoServ", "SEND rschen7754 "+kickerNick+" kicked "+recipientNick+" from the channel "+channel+" because "+reason);
sendMessage("MemoServ", "SEND imzadi1979 "+kickerNick+" kicked "+recipientNick+" from the channel "+channel+" because "+reason);
sendMessage("MemoServ", "SEND Fredddie "+kickerNick+" kicked "+recipientNick+" from the channel "+channel+" because "+reason);
sendMessage("MemoServ", "SEND viridiscalculus "+kickerNick+" kicked "+recipientNick+" from the channel "+channel+" because "+reason);
sendMessage("MemoServ", "SEND Floydian "+kickerNick+" kicked "+recipientNick+" from the channel "+channel+" because "+reason);
sendMessage("MemoServ", "SEND Juliancolton "+kickerNick+" kicked "+recipientNick+" from the channel "+channel+" because "+reason);
sendMessage("MemoServ", "SEND TCN7JM "+kickerNick+" kicked "+recipientNick+" from the channel "+channel+" because "+reason);
}
public void onDisconnect() {
System.exit (-1);
}
/*
Write channel list to disk
*/
public void writeChannels() {
try {
BufferedWriter writer = new BufferedWriter(new FileWriter("channels.txt"));
writer.write("%channels;" + channelList.size()+"\n");
for (int i=0; i < channelList.size(); i++) {
Channel channel = channelList.get(i);
writer.write (channel.getName() + ";" + channel.isMaster() + "\n");
}
writer.close();
}
catch (Exception e) {
}
}
/*
Find a channel in the data structure by name
*/
public Channel findChannel(String name) {
for (int i=0; i < channelList.size(); i++) {
if (channelList.get(i).getName().equals(name))
return channelList.get(i);
}
return null;
}
/*
Stub function that treats it as a message
*/
public void onAction(String sender, String login, String hostname, String target, String action) {
onMessage(target, sender, login, hostname, action);
}
public void onMessage(String channel, String sender,
String login, String hostname, String message) {
if (sender.contains("bot") || sender.contains("collector") ) {
return;
}
if (message.toLowerCase().contains("stalk") || message.toLowerCase().contains("ignore") ||
message.toLowerCase().contains("unstalk") || message.toLowerCase().contains("unignore") ||
message.toLowerCase().contains("!list") || message.toLowerCase().contains("!3list") || message.toLowerCase().contains("join") ||
message.toLowerCase().contains("part")) {
return;
}
if (message.startsWith("!")) {
if (message.equals("!")) {
return;
}
else if (message.equalsIgnoreCase("!time")) {
String time = new java.util.Date().toString();
sendSenderMessage(channel, sender, ": The time is now " + time);
}
else if (message.startsWith("!quit")) {
if (isOp(sender, channel))
{
quitServer("User request to terminate");
System.exit(0);
}
else
{
sendSenderMessage(channel, sender, ": You must become an op to quit the bot");
}
}
else if (message.startsWith("!add")) {
if (isOp(sender, channel))
{
if (message.startsWith("!add channel")) {
//TODO - create a channel object first, and add it to the list
String channelName = message.replace("!add channel ","");
Channel chanObject = new Channel(channelName, false);
joinChannel(chanObject);
channelList.add(chanObject);
writeChannels();
}
else if (message.startsWith("!add trigger")) {
sendSenderMessage(channel, sender, ": That does not work yet!");
}
else if (message.startsWith("!add category")) {
sendSenderMessage(channel, sender, ": That does not work yet!");
}
else if (message.startsWith("!add point")) {
sendSenderMessage(channel, sender, ": That does not work yet!");
}
else {
sendSenderMessage(channel, sender, ": Valid terms: channel, trigger, category, point");
}
}
else
{
sendSenderMessage(channel, sender, ": You must become an op to add a channel, trigger, category, or point!");
}
}
else if (message.startsWith("!remove")) {
if (isOp(sender, channel))
{
if (message.startsWith("!remove channel")) {
//if !remove channel, check to see if master, if it is, reject
//if it is NOT a master, then remove the channel
Channel thisChannel = findChannel(channel);
if (thisChannel.isMaster() && message.equals("!remove channel")) {
sendSenderMessage(channel, sender, ": You cannot remove a master channel!");
}
else if (message.equals("!remove channel")) {
partChannel(channel, "Requested by "+sender);
channelList.remove(thisChannel);
writeChannels();
}
//if !remove channel #channel, see if it is a master, if NOT, reject
//else, remove the channel
//what if the channel is invalid?
else if (!thisChannel.isMaster()) {
sendSenderMessage(channel, sender, ": You must be in the master channel to do that!");
return;
}
else {
Channel partingChannel = findChannel(message.replace("!remove channel ",""));
if (partingChannel == null)
sendSenderMessage(channel, sender, ": The bot is not in that channel!");
else {
partChannel(partingChannel.getName(), "Requested by "+sender);
channelList.remove(partingChannel);
writeChannels();
}
}
}
else if (message.startsWith("!remove trigger")) {
sendSenderMessage(channel, sender, ": That does not work yet!");
}
else if (message.startsWith("!remove category")) {
sendSenderMessage(channel, sender, ": That does not work yet!");
}
else if (message.startsWith("!remove point")) {
sendSenderMessage(channel, sender, ": That does not work yet!");
}
else {
sendSenderMessage(channel, sender, ": Valid terms: channel, trigger, category, point");
}
}
else
{
sendSenderMessage(channel, sender, ": You must become an op to remove a channel, trigger, category, or point!");
}
}
else if (message.startsWith("!lmgtfy")) {
String key = message.replace("!lmgtfy ","http://www.lmgtfy.com/?q=");
key = key.replace(" ","+");
sendMessage(channel, key);
factor+=10;
return;
}
else if (message.startsWith("!forget")) {
String key = message.replace("!forget ","");
if (factoids.remove(key) == null) {
sendMessage(channel, "There is no "+key+"!");
return;
}
sendMessage(channel, "Ok, "+key+" is forgotten");
try {
BufferedWriter writer = new BufferedWriter(new FileWriter("factsin.txt"));
Set<String> keys = factoids.keySet();
for (String test: keys)
{
writer.write(test);
writer.newLine();
writer.write(factoids.get(test));
writer.newLine();
}
writer.close();
}
catch (IOException e) {
}
}
else if (message.startsWith("!admin")) {
if (message.startsWith("!admin@commons")) {
sendSenderMessage(channel, sender, COM_ADMINS);
}
else if (message.startsWith("!admin@wikidata") || message.startsWith("!admin@data")) {
sendSenderMessage(channel, sender, DATA_ADMINS);
}
else if (message.startsWith("!admin@meta")) {
sendSenderMessage(channel, sender, META_ADMINS);
}
else if (message.startsWith("!admin@voyage") || message.startsWith("!admin@wikivoyage") ||message.startsWith("!admin@enwikivoyage")) {
sendSenderMessage(channel, sender, VOY_ADMINS);
}
else if (message.startsWith("!admin@aaroads") ) {
sendSenderMessage(channel, sender, AAROADS_ADMINS);
}
else {
sendSenderMessage(channel, sender, ADMINS);
}
}
else if (message.equals("!tmi")) {
factor+=4;
sendMessage(channel, "ewwww");
return;
}
else if (message.toLowerCase().startsWith("!oversight@wikidata") || message.toLowerCase().startsWith("!oversight@data")) {
sendSenderMessage(channel, sender, DATA_OS);
}
else if (message.startsWith("!checkuser")) {
sendSenderMessage(channel, sender, CU);
}
else if (message.startsWith("!oversight")) {
sendSenderMessage(channel, sender, OS);
}
else if (message.startsWith("!template")) {
sendSenderMessage(channel, sender, TEMPLATE);
}
else if (message.toLowerCase().startsWith("!otrs")) {
sendSenderMessage(channel, sender, OTRS);
}
else if (message.startsWith("!bell")) {
sendSenderMessage("#wikipedia-en-roads", sender, " requests the reassessment of an article.");
}
else if (message.startsWith("!fotn")) {
sendMessage(channel, "Tonight's nomination for fail: *drumroll*");
}
else if (message.startsWith("!road")) {
sendSenderMessage(channel, sender, ROAD);
}
else if (message.startsWith("!gs")) {
sendSenderMessage(channel, sender, GS);
}
else if (message.startsWith("!"+POINT_KEY)) {
sendMessage(channel, POINT_VALUE.replace("%d", ((int)(Math.max( (Math.random() * 1000), 101)+100*factor)+"")));
factor = 0;
}
else if (message.startsWith("!superop")) {
sendSenderMessage(channel, sender, CHAN_SUPEROPS);
}
else if (message.startsWith("!op")) {
sendSenderMessage(channel, sender, CHAN_OPS);
}
else if (message.startsWith("!filemover@commons")) {
sendSenderMessage(channel, sender, FILEMOVER);
}
else {
//must be a fact then
String key = message.substring(1);
if (message.contains(" answer "))
{
String[] pieces = key.split(" answer ");
//sendMessage(channel, pieces[0]);
//sendMessage(channel, pieces[1]);
factoids.put(pieces[0],pieces[1]);
sendMessage(channel, "I'll remember that.");
try {
//sendMessage(channel, pieces[0]);
//sendMessage(channel, pieces[1]);
BufferedWriter writer = new BufferedWriter(new FileWriter("factsin.txt"));
Set<String> keys = factoids.keySet();
for (String test: keys)
{
writer.write(test);
writer.newLine();
writer.write(factoids.get(test));
writer.newLine();
}
writer.close();
}
catch (IOException e) {
}
}
else if (message.contains(" is "))
{
String[] pieces = key.split(" is ");
//sendMessage(channel, pieces[0]);
//sendMessage(channel, pieces[1]);
factoids.put(pieces[0],key);
sendMessage(channel, "I'll remember that.");
try {
//sendMessage(channel, pieces[0]);
//sendMessage(channel, pieces[1]);
BufferedWriter writer = new BufferedWriter(new FileWriter("factsin.txt"));
Set<String> keys = factoids.keySet();
for (String test: keys)
{
writer.write(test);
writer.newLine();
writer.write(factoids.get(test));
writer.newLine();
}
writer.close();
}
catch (IOException e) {
}
}
else if (factoids.containsKey(key.trim())==true)
sendMessage(channel, factoids.get(key));
else
sendMessage(channel, key + "? I don't know what you're going on about...");
}
}
else if (message.toLowerCase().contains("pink underwear")) {
counter++;
factor+=15;
if (!checkTime(channel))
sendAction(channel, "gags");
}
else if (message.toLowerCase().contains("underwear")) {
counter++;
factor+=10;
if (!checkTime(channel))
sendAction(channel, "gags");
}
else if (message.toLowerCase().contains("pink ") || message.toLowerCase().contains(" pink ") || message.toLowerCase().equals("pink")) {
counter++;
factor+=5;
if (!checkTime(channel))
sendAction(channel, "gags");
}
else if (message.toLowerCase().contains("holister")) {
counter++;
factor++;
if (!checkTime(channel))
sendAction(channel, "gags");
}
else if (message.toLowerCase().contains("tilly")) {
counter++;
factor++;
if (!checkTime(channel))
sendAction(channel, "gags");
}
else if (message.toLowerCase().contains("crombie")) {
counter++;
factor++;
if (!checkTime(channel))
sendAction(channel, "gags");
}
else if (message.toLowerCase().contains("hollister") || message.toLowerCase().contains("h0llister") || message.toLowerCase().contains("ho1lister") || message.toLowerCase().contains("hol1ister") ||message.toLowerCase().contains("ho11ister") || message.toLowerCase().contains("h01lister") || message.toLowerCase().contains("h0l1ister") || message.toLowerCase().contains("h0llister")) {
counter++;
factor++;
if (!checkTime(channel))
sendAction(channel, "gags");
}
else if (message.toLowerCase().contains("gift card")) {
counter++;
factor++;
sendAction(channel, "rolls eyes");
}
else if (message.toLowerCase().contains("hco ") || message.toLowerCase().contains(" hco") ||message.toLowerCase().contains("hco.") || message.equalsIgnoreCase("hco")) {
counter++;
factor++;
if (!checkTime(channel))
sendAction(channel, "gags");
}
else if (message.contains("abuse") && message.contains("bot")) {
sendAction(channel, "frowns");
factor+=2;
}
else if (message.contains("route_bot")) {
sendAction(channel, "frowns");
factor+=2;
}
else if (message.contains("kick")) {
factor++;
}
else if ((message.startsWith("cant ") || message.contains(" cant")) && isOn(CHECK, channel)) {
factor+=0.1;
sendMessage(channel, "*can't");
}
else if (message.contains("isnt") && isOn(CHECK, channel)) {
factor+=0.1;
sendMessage(channel, "*isn't");
}
else if (message.startsWith("ive")&& isOn(CHECK, channel)) {
factor+=0.1;
sendMessage(channel, "*I've");
}
else if (message.contains("wont")&& isOn(CHECK, channel)) {
factor+=0.1;
sendMessage(channel, "*won't");
}
else if (message.contains("dont")&& isOn(CHECK, channel)) {
factor+=0.1;
sendMessage(channel, "*don't");
}
else if (message.contains("didnt")&& isOn(CHECK, channel)) {
factor+=0.1;
sendMessage(channel, "*didn't");
}
else if (message.contains("havent")&& isOn(CHECK, channel)) {
factor+=0.1;
sendMessage(channel, "*haven't");
}
else if (message.contains("thats")&& isOn(CHECK, channel)) {
factor+=0.1;
sendMessage(channel, "*that's");
}
else if (message.startsWith("im ")&& isOn(CHECK, channel)) {
factor+=0.1;
sendMessage(channel, "*I'm");
}
if (((message.contains("[[commons:") || message.contains("[[c:"))) && message.contains("]]")) {
int i=0;
int k=0;
String output="https://commons.wikimedia.org/wiki/";
for (boolean j=true;j==true;i++)
{
if (message.charAt(i)=='[' && message.charAt(i+1)=='[')
{j=false;}
}
k=i+1;
for (boolean j=true;j==true;k++)
{
if (message.charAt(k)==']' && message.charAt(k+1)==']')
{j=false;}
}
output = output+message.substring(i+1,k-1);
output = output.replace(" ","_");
output = output.replace("c:","");
output = output.replace("commons:","");
sendMessage(channel, output);
}
else if ((message.contains("[[m:") || message.contains("[[meta:")) && message.contains("]]")) {
int i=0;
int k=0;
String output="https://meta.wikimedia.org/wiki/";
for (boolean j=true;j==true;i++)
{
if (message.charAt(i)=='[' && message.charAt(i+1)=='[')
{j=false;}
}
k=i+1;
for (boolean j=true;j==true;k++)
{
if (message.charAt(k)==']' && message.charAt(k+1)==']')
{j=false;}
}
output = output+message.substring(i+1,k-1);
output = output.replace(" ","_");
output = output.replace("m:","");
output = output.replace("meta:","");
sendMessage(channel, output);
}
else if ((message.contains("[[d:") || message.contains("[[data:")) && message.contains("]]")) {
int i=0;
int k=0;
String output="https://www.wikidata.org/wiki/";
for (boolean j=true;j==true;i++)
{
if (message.charAt(i)=='[' && message.charAt(i+1)=='[')
{j=false;}
}
k=i+1;
for (boolean j=true;j==true;k++)
{
if (message.charAt(k)==']' && message.charAt(k+1)==']')
{j=false;}
}
output = output+message.substring(i+1,k-1);
output = output.replace(" ","_");
output = output.replace("d:","");
output = output.replace("data:","");
sendMessage(channel, output);
}
else if (message.contains("[[") && message.contains("]]")) {
if (message.contains("|")) {
return;
}
int i=0;
int k=0;
String output="https://en.wikipedia.org/wiki/";
for (boolean j=true;j==true;i++)
{
if (message.charAt(i)=='[')
{j=false;}
}
k=i+1;
for (boolean j=true;j==true;k++)
{
if (message.charAt(k)==']')
{j=false;}
}
output = output+message.substring(i+1,k-1);
output = output.replace(" ","_");
sendMessage(channel, output);
}
if (message.contains("{{{") && message.contains("}}}")) {
}
else if (message.contains("|")) {
}
else if (message.contains("{{") && message.contains("}}")) {
int i=0;
int k=0;
String output="https://en.wikipedia.org/wiki/Template:";
for (boolean j=true;j==true;i++)
{
if (message.charAt(i)=='{')
{j=false;}
}
k=i+1;
for (boolean j=true;j==true;k++)
{
if (message.charAt(k)=='}')
{j=false;}
}
output = output+message.substring(i+1,k-1);
output = output.replace(" ","_");
sendMessage(channel, output);
}
}
//wrapper function
public void joinChannel(Channel channel) {
joinChannel(channel.getName());
}
}