France
Asked — Edited

Accessing To Some ARC Configuration Information Wjen Buiding A Plugin

Hi

I want in my plugin to get the Media Save Folder Path which is a parameter of Camera Control and to the twitter account name configured in ARC

Do you have ideas ?

Thanks


ARC Pro

Upgrade to ARC Pro

Stay at the forefront of robot programming innovation with ARC Pro, ensuring your robot is always equipped with the latest advancements.

PRO
USA
#1  

Get project control configuration properties:


var formCameraDevice = (FormCameraDevice)EZBManager.FormMain.GetControlByType(typeof(FormCameraDevice)).FirstOrDefault();
if (formCameraDevice == null)
{
    //current project does not have a Camera Device Control 
    return;
}

//Camera's MediaSaveFolder
var cameraMediaSaveFolder = formCameraDevice.GetConfiguration().CameraDevice.CameraMediaSaveFolder;


var formTwitterRecognition = (FormTwitterRecognition)EZBManager.FormMain.GetControlByType(typeof(FormTwitterRecognition)).FirstOrDefault();
if (formTwitterRecognition == null)
{
    //current project does not have a Twitter Recognition Control
    return;
}

//Get Twitter's username
var twitterUserName = formTwitterRecognition.GetConfiguration().TwitterRecognition.TwitterUsername;

PRO
USA
#2  

Twitter Integration:

If your objective is to tweet you can use the the EZ-Script executer: https://synthiam.com/Community/Tutorials/146/21

and send a Tweet command.

ez-script help:

Quote:

Tweet( message ) Send a Twitter message using the configured Twitter account. Configure your Twitter account under File->Twitter Settings. Example: Tweet("I Love EZ-Robot!") You may also use the ControlCommand to Tweet images with text from a Camera Control. Example: ControlCommand( "Camera", CameraTweet, "Our New Image" )

#3  

My objective fot twitter inegration is to be able to send and receive private messages

PRO
USA
#4  

@JLucben,

The existent ez-robot twitter integration does not support direct messages, only DJ knows the ARC priorities.

you can use tweetmoasharp (tweetsharpfork) a .net wrapper: https://github.com/Yortw/tweetmoasharp

you will need to create a twitter application to obtain an Oath consumer key and secret. https://developer.twitter.com/en/docs/basics/authentication/overview/application-permission-model

https://developer.twitter.com/en/docs/basics/authentication/overview/oauth

then something like this:


var service = new TwitterService(consumerKey, consumerSecret, accessToken, accessTokenSecret);
var user = service.VerifyCredentials();
var result = service.SendDirectMessage(recipient, message);

Don't forget the recipient's twitter account must follow your twitter account.

PRO
Synthiam
#5  

The ARC application includes Twitterize, which should support private messaging. Add the DLL to your project as reference, and be sure to set not to copy as you did with ARC.exe and ezb.dll.

PRO
USA
#6  

@JLucben,

Quote:

My objective fot twitter inegration is to be able to send and receive private messages

Another reason to create your twitter application:

User-inserted image

EDIT: I didn't see DJ's post

PRO
USA
#7  

@DJ

For future references, do you allow/recommend using the EZ-Robot application/User tokens ?

Or create a twitter applications and user token ?

PRO
Synthiam
#8  

That’s a good question... I’m guessing it’s not terrible, as it’s the user’s account anyway. So I think it’s probably easiest to use the ezrobot tokens.

PRO
USA
#9  

@JLucben,

My initial advise is to create a custom application and the user tokens, although i knew it was possible to obtain and reuse the EZ-Robot tokens.

I didn't do it before DJ's approval.

So the code below is the short and effective answer:


        public void TwitterTest1()
        {
            var tokens = new Twitterizer.OAuthTokens
            {
                AccessToken = EZ_Builder.Common.GetRegistryEntry(EZ_Builder.Constants.RegistryKeys.TwitterAccessToken, ""),
                AccessTokenSecret = EZ_Builder.Common.GetRegistryEntry(EZ_Builder.Constants.RegistryKeys.TwitterAccessTokenSecret, ""),
                ConsumerKey = EZ_Builder.Constants.TwitterConsumerKey,
                ConsumerSecret = EZ_Builder.Constants.TwitterConsumerSecret
            };

            //Tweet
            var twitterResponse = Twitterizer.TwitterStatus.Update(tokens, "This is a Tweet!");

            //Direct Message
            Twitterizer.TwitterDirectMessage.Send(tokens, 844385345234, "this is a direct msg!");
        }


although Twitterizer's API allows read direct messages, ez-robot application is not authorized to read the direct messages.

happy code!

#10  

My draft plugin is using user token with framemork tweetinvi , its working fine but it will be better just as cleaner integration to reuse the EZ-Robot tokens but they don't allow to day to access direct messages.

One limitation of tweetinvi to day is that you cannot send direct messages with file attachments. Do you know other one with this feature

Jean-Luc