Ejemplo n.º 1
0
        // Can't use constructors because we have to have a method which we explicitly control outside
        // in order to delegate to a new thread. We don't need control over instance members from Main anyway.

        public async Task Init()
        {
            // Initialize data instance
            _DataInstance = new SwitchScreenshot.Main.Data();

            // Retrieve API keys.
            string[] TokenLines = System.IO.File.ReadAllLines("/home/jay/Programming/SwitchScreenshot/SwitchScreenshot/TwitterTokens.txt");
            _ConsumerKey       = TokenLines[0];
            _ConsumerSecretKey = TokenLines[1];
            _AccessToken       = TokenLines[2];
            _AccessSecretToken = TokenLines[3];

            // "log in"
            Auth.SetUserCredentials(_ConsumerKey, _ConsumerSecretKey, _AccessToken, _AccessSecretToken);
            var AuthenticatedUser = User.GetAuthenticatedUser();

            Utils.TwitterLog($"Logged into Twitter as {AuthenticatedUser.Name}", "Info", "Init");;
            _Stream = Tweetinvi.Stream.CreateUserStream();

            // Stream events
            _Stream.StreamStopped += (sender, args) => {
                Utils.TwitterLog($"Stream halted: {args.DisconnectMessage} ({args.Exception}",
                                 "Error", "Source unknown");
            };

            _Stream.TweetCreatedByFriend += OnFollowerTweet;

            await _Stream.StartStreamAsync();
        }
Ejemplo n.º 2
0
 public CommandModule(SwitchScreenshot.Main.Data SQLService)
 {
     _SQLService = SQLService;
 }