Search in sources :

Example 1 with Account

use of irc.account.Account in project Botnak by Gocnak.

the class GUIAuthorizeAccount method doneButtonActionPerformed.

private void doneButtonActionPerformed(ActionEvent e) {
    String oauth = new String(oauthField.getPassword());
    if (!oauth.startsWith("oauth:"))
        oauth = "oauth:" + oauth;
    String name = accountNameField.getText().trim().toLowerCase();
    if (!name.isEmpty() && oauth.length() == 36) {
        if (isForBotAccount) {
            if (getAccount(true) == null) {
                Settings.accountManager.setBotAccount(new Account(name, new Oauth(oauth, false, false, false, false)));
                Settings.accountManager.addTask(new Task(null, Task.Type.CREATE_BOT_ACCOUNT, null));
                if (GUIMain.settings != null) {
                    GUISettings.botUser.setText(name);
                    GUISettings.botPass.setText(oauth);
                }
            }
        } else {
            if (getAccount(false) == null) {
                Settings.accountManager.setUserAccount(new Account(name, new Oauth(oauth, boxEditStatus.isSelected(), boxCommercial.isSelected(), boxReadSubs.isSelected(), boxFollowed.isSelected())));
                Settings.accountManager.addTask(new Task(null, Task.Type.CREATE_VIEWER_ACCOUNT, null));
                if (GUIMain.settings != null) {
                    GUISettings.normUser.setText(name);
                    GUISettings.normPass.setText(oauth);
                }
            }
        }
    }
    dispose();
}
Also used : Oauth(irc.account.Oauth) Account(irc.account.Account) Task(irc.account.Task)

Example 2 with Account

use of irc.account.Account in project Botnak by Gocnak.

the class Settings method savePropData.

public static void savePropData(int type) {
    Properties p = new Properties();
    File writerFile = null;
    String detail = "";
    switch(type) {
        case 0:
            Account user = accountManager.getUserAccount();
            Account bot = accountManager.getBotAccount();
            if (user != null) {
                Oauth key = user.getKey();
                p.put("UserNorm", user.getName());
                p.put("UserNormPass", key.getKey());
                p.put("CanStatus", String.valueOf(key.canSetTitle()));
                p.put("CanCommercial", String.valueOf(key.canPlayAd()));
                p.put("CanParseSubscribers", String.valueOf(key.canReadSubscribers()));
                p.put("CanParseFollowedStreams", String.valueOf(key.canReadFollowed()));
            }
            if (bot != null) {
                Oauth key = bot.getKey();
                p.put("UserBot", bot.getName());
                p.put("UserBotPass", key.getKey());
            }
            writerFile = accountsFile;
            detail = "Account Info";
            break;
        case 1:
            settings.forEach(s -> s.save(p));
            writerFile = defaultsFile;
            detail = "Defaults/Other Settings";
            break;
        default:
            break;
    }
    if (writerFile != null) {
        try {
            p.store(new FileWriter(writerFile), detail);
        } catch (Exception e) {
            GUIMain.log(e);
        }
    } else {
        GUIMain.log("Failed to store settings due to some unforseen exception!");
    }
}
Also used : Oauth(irc.account.Oauth) Account(irc.account.Account)

Example 3 with Account

use of irc.account.Account in project Botnak by Gocnak.

the class Settings method loadPropData.

/**
     * *********VOIDS*************
     */
public static void loadPropData(int type) {
    Properties p = new Properties();
    if (type == 0) {
        //accounts
        try {
            p.load(new FileInputStream(accountsFile));
            String userNorm = p.getProperty("UserNorm", "").toLowerCase();
            String userNormPass = p.getProperty("UserNormPass", "");
            String status = p.getProperty("CanStatus", "false");
            String commercial = p.getProperty("CanCommercial", "false");
            if (!userNorm.equals("") && !userNormPass.equals("") && userNormPass.contains("oauth")) {
                boolean stat = Boolean.parseBoolean(status);
                if (!stat) {
                    GUIMain.instance.updateStatusOption.setEnabled(false);
                    GUIMain.instance.updateStatusOption.setToolTipText("Enable \"Edit Title and Game\" in the Authorize GUI to use this feature.");
                }
                boolean ad = Boolean.parseBoolean(commercial);
                if (!ad) {
                    GUIMain.instance.runAdMenu.setEnabled(false);
                    GUIMain.instance.runAdMenu.setToolTipText("Enable \"Play Commercials\" in the Authorize GUI to use this feature.");
                }
                boolean subs = Boolean.parseBoolean(p.getProperty("CanParseSubscribers", "false"));
                boolean followed = Boolean.parseBoolean(p.getProperty("CanParseFollowedStreams", "false"));
                if (followed)
                    trackFollowers.setValue(true);
                accountManager.setUserAccount(new Account(userNorm, new Oauth(userNormPass, stat, ad, subs, followed)));
            }
            String userBot = p.getProperty("UserBot", "").toLowerCase();
            String userBotPass = p.getProperty("UserBotPass", "");
            if (!userBot.equals("") && !userBotPass.equals("") && userBotPass.contains("oauth")) {
                accountManager.setBotAccount(new Account(userBot, new Oauth(userBotPass, false, false, false, false)));
            }
            if (accountManager.getUserAccount() != null) {
                accountManager.addTask(new Task(null, Task.Type.CREATE_VIEWER_ACCOUNT, null));
            }
            if (accountManager.getBotAccount() != null) {
                accountManager.addTask(new Task(null, Task.Type.CREATE_BOT_ACCOUNT, null));
            }
        } catch (Exception e) {
            GUIMain.log(e);
        }
    }
    if (type == 1) {
        //defaults
        try {
            p.load(new FileInputStream(defaultsFile));
            settings.forEach(s -> s.load(p));
            if (logChat.getValue())
                logDir.mkdirs();
            GUIMain.log("Loaded defaults!");
        } catch (Exception e) {
            GUIMain.log(e);
        }
    }
}
Also used : Oauth(irc.account.Oauth) Account(irc.account.Account) Task(irc.account.Task)

Aggregations

Account (irc.account.Account)3 Oauth (irc.account.Oauth)3 Task (irc.account.Task)2