12
12
13
13
namespace Beef {
14
14
class Application : ProfileInfoProvider , MmrListener , TwitchLiveListener {
15
- private readonly String _version = "2.0 .0" ;
15
+ private readonly String _version = "2.1 .0" ;
16
16
private BeefConfig _config ;
17
17
private String _botPrefix ;
18
18
private String _beefCommand ;
19
19
private BeefUserConfigManager _userManager ;
20
- private PresentationManager _presentationManager ;
20
+ private LadderManager _ladderManager ;
21
21
private String [ ] _leaderRoles ;
22
22
private String [ ] _dynamicChannels ; // Names of channels that should be cloned to maintain 1 empty at all times
23
23
private bool _dynamicVoiceChannelsEnabled = false ;
@@ -48,12 +48,7 @@ public Application(BeefConfig config, String exePath) {
48
48
_leaderRoles = config . LeaderRoles ;
49
49
_dynamicChannels = config . DynamicChannels ;
50
50
51
- _presentationManager = new PresentationManager (
52
- _config . GoogleApiPresentationId ,
53
- _config . GoogleApiCredentialFile ,
54
- _config . GoogleApiApplicationName ,
55
- _exePath + "/Backups" ) ;
56
- _presentationManager . Initialize ( ) ;
51
+ _ladderManager = new LadderManager ( _exePath + "/Backups" ) ;
57
52
_userManager = new BeefUserConfigManager ( _exePath + "/Users" ) ;
58
53
59
54
if ( SynchronizationContext . Current == null || ! ( SynchronizationContext . Current is DispatcherSynchronizationContext ) ) {
@@ -73,7 +68,7 @@ public Application(BeefConfig config, String exePath) {
73
68
}
74
69
75
70
// Start the API
76
- _apiServer = new ApiServer ( _exePath + "/BeefApiConfig.json" , SynchronizationContext . Current , _presentationManager , _userManager ) ;
71
+ _apiServer = new ApiServer ( _exePath + "/BeefApiConfig.json" , SynchronizationContext . Current , _ladderManager , _userManager ) ;
77
72
_apiServer . Start ( ) ;
78
73
}
79
74
@@ -212,11 +207,6 @@ private void HandleCommand(SocketMessage userInput) {
212
207
ISocketMessageChannel channel = userInput . Channel ;
213
208
ErrorCode code = ErrorCode . CommandNotRecognized ;
214
209
215
- if ( ! _presentationManager . Authenticate ( ) . Ok ( ) ) {
216
- Console . WriteLine ( "Could not authenticate." ) ;
217
- return ;
218
- }
219
-
220
210
if ( arguments . Length == 1 ) {
221
211
// Just print the ladder link
222
212
code = ErrorCode . Success ;
@@ -502,11 +492,11 @@ private void HandleCommand(SocketMessage userInput) {
502
492
if ( ! int . TryParse ( losingPlayer , out losingRank ) ) losingRank = - 1 ;
503
493
504
494
if ( winningRank != - 1 && losingRank != - 1 ) {
505
- code = _presentationManager . ReportWin ( winningRank , losingRank ) ;
495
+ code = _ladderManager . ReportWin ( winningRank , losingRank ) ;
506
496
} else if ( winningRank == - 1 && losingRank != - 1 ) {
507
- code = _presentationManager . ReportWin ( winningPlayer , losingRank ) ;
497
+ code = _ladderManager . ReportWin ( winningPlayer , losingRank ) ;
508
498
} else {
509
- code = _presentationManager . ReportWin ( winningPlayer , losingPlayer ) ;
499
+ code = _ladderManager . ReportWin ( winningPlayer , losingPlayer ) ;
510
500
}
511
501
512
502
if ( code . Ok ( ) )
@@ -524,7 +514,7 @@ private void HandleCommand(SocketMessage userInput) {
524
514
525
515
if ( rank != - 1 ) {
526
516
BeefEntry existingPlayer ;
527
- code = _presentationManager . RenamePlayer ( rank - 1 , newName , out existingPlayer ) ;
517
+ code = _ladderManager . RenamePlayer ( rank - 1 , newName , out existingPlayer ) ;
528
518
529
519
if ( existingPlayer != null ) {
530
520
playerOrRankToRename = existingPlayer . PlayerName ;
@@ -533,7 +523,7 @@ private void HandleCommand(SocketMessage userInput) {
533
523
}
534
524
}
535
525
} else {
536
- code = _presentationManager . RenamePlayer ( playerOrRankToRename , newName ) ;
526
+ code = _ladderManager . RenamePlayer ( playerOrRankToRename , newName ) ;
537
527
}
538
528
539
529
if ( code . Ok ( ) ) {
@@ -556,7 +546,7 @@ private void HandleCommand(SocketMessage userInput) {
556
546
557
547
BeefEntry player1 = null ;
558
548
BeefEntry player2 = null ;
559
- code = _presentationManager . SwitchPlayers ( playerOrRank1 , playerOrRank2 , out player1 , out player2 ) ;
549
+ code = _ladderManager . SwitchPlayers ( playerOrRank1 , playerOrRank2 , out player1 , out player2 ) ;
560
550
561
551
if ( code . Ok ( ) ) {
562
552
MessageChannel ( channel , "**" + player1 . PlayerName + "** has been switched with **" + player2 . PlayerName + "**" ) . GetAwaiter ( ) . GetResult ( ) ;
@@ -592,19 +582,19 @@ private void HandleCommand(SocketMessage userInput) {
592
582
593
583
if ( rank != - 1 ) {
594
584
BeefEntry removedPlayerEntry ;
595
- code = _presentationManager . RemovePlayer ( rank - 1 , out removedPlayerEntry ) ;
585
+ code = _ladderManager . RemovePlayer ( rank - 1 , out removedPlayerEntry ) ;
596
586
597
587
if ( code . Ok ( ) )
598
588
playerToRemove = removedPlayerEntry . PlayerName ;
599
589
} else {
600
- code = _presentationManager . RemovePlayer ( playerToRemove ) ;
590
+ code = _ladderManager . RemovePlayer ( playerToRemove ) ;
601
591
}
602
592
603
593
if ( code . Ok ( ) ) {
604
594
MessageChannel ( channel , "Removed **" + playerToRemove + "** from the ladder." ) . GetAwaiter ( ) . GetResult ( ) ;
605
595
}
606
596
} else if ( arguments [ 1 ] == "bracket" || arguments [ 1 ] == "list" || arguments [ 1 ] == "ladder" ) {
607
- List < BeefEntry > entries = _presentationManager . ReadBracket ( ) ;
597
+ List < BeefEntry > entries = _ladderManager . ReadBracket ( ) ;
608
598
609
599
if ( entries . Count == 0 )
610
600
code = ErrorCode . CouldNotReadTheLadder ;
@@ -643,7 +633,7 @@ private void HandleCommand(SocketMessage userInput) {
643
633
return ;
644
634
}
645
635
646
- code = _presentationManager . Undo ( ) ;
636
+ code = _ladderManager . Undo ( ) ;
647
637
if ( code . Ok ( ) ) {
648
638
MessageChannel ( channel , "Undid what you should have done undid 10 minutes ago." ) . GetAwaiter ( ) . GetResult ( ) ;
649
639
}
@@ -658,7 +648,7 @@ private void HandleCommand(SocketMessage userInput) {
658
648
code = ErrorCode . Success ;
659
649
660
650
String help = "" ;
661
- help += "The Beef ladder is maintained on Google Docs as a Slide presentation. This bot makes it more convenient to update it . Each Beef command is prefixed with \" %beef%\" .\n " ;
651
+ help += "This bot maintains the current Beef Ladder and provides commands to update it. It also can monitor twitch streams and notify when they go live and read MMR of players that are linked automatically . Each Beef command is prefixed with \" %beef%\" .\n " ;
662
652
help += "Note, commands that have parameters in them surrounded in [] means that parameter is optional. As an example \" all\" is a common suffix you can add to make a command print to the chat instead of whispering the response to you.\n " ;
663
653
help += "The following commands are available:\n " ;
664
654
help += "\t **%beef%** - Prints the link to the ladder.\n " ;
@@ -879,11 +869,6 @@ public List<ProfileInfo> GetLadderUsers() {
879
869
880
870
public void OnMmrRead ( List < Tuple < ProfileInfo , LadderInfo > > mmrList ) {
881
871
_mainContext . Post ( ( _ ) => {
882
- if ( ! _presentationManager . Authenticate ( ) . Ok ( ) ) {
883
- Console . WriteLine ( "Could not authenticate when reading MMR." ) ;
884
- return ;
885
- }
886
-
887
872
// Make the list a dictionary so we can quickly lookup MMR
888
873
var profileIdToMaxMmrDict = new Dictionary < String , Tuple < ProfileInfo , LadderInfo > > ( ) ;
889
874
foreach ( Tuple < ProfileInfo , LadderInfo > entry in mmrList ) {
@@ -919,7 +904,7 @@ public void OnMmrRead(List<Tuple<ProfileInfo, LadderInfo>> mmrList) {
919
904
Console . WriteLine ( "Warning: User " + user . BeefName + " already exists in the profileIdToMaxMmrDict!" ) ;
920
905
}
921
906
922
- _presentationManager . UpdateMmrDictionary ( profileIdToMaxMmrDict ) ;
907
+ _ladderManager . UpdateMmrDictionary ( profileIdToMaxMmrDict ) ;
923
908
924
909
Console . WriteLine ( $ "Read MMR. Users:") ;
925
910
foreach ( Tuple < ProfileInfo , LadderInfo > entry in mmrList ) {
0 commit comments