
Hello, dear users of Habrahabr.
In this article I want to tell you about a very simple and useful bot for Twitter, which will help monitor the status of the Windows server (occupied space on disks, percentage of CPU, RAM).
Foreword
I work as a system administrator at a cannery. Since the company is not profile, you have to be an administrator and a programmer in one person.
The reason for creating this bot is a fast-ending place on the server's hard disk due to daily backups of 1C databases.
I have been thinking about possible options for such a control for a long time and came to the conclusion that Twitter is the most convenient solution for this. So, from the word to the case.
Training
Since we will write the bot in C #, we need:
- Microsoft Visual Studio 2008-2010 any edition (or SharpDevelop 3.2 - 4.x)
- Twitterizer library for working with Twitter in the .NET Framework
- A little patience
Development
We download the library from the developer’s site and unpack its contents into the directory with our project. We need only two files -
Twitterizer2.dll and
Newtonsoft.Json.dll . Add a Twitterizer library to our project. Right mouse button on the project -> Add Reference Select the “Browse” tab and specify the path to
Twitterizer2.dll .
')

Add to the main form code
using Twitterizer;
Now you can go directly to work with Twitter.
Register our application.
Thevar1able has written about this well in
his article on the Python bot.
We will need 4 keys:
Consumer key ,
Consumer secret ,
Access token and
Access token secret .
All actions are reduced to sending the information we need in the form of a tweet.
private bool SendTwit(string Twit) { OAuthTokens tokens = new OAuthTokens();
Information about the processor and RAM can be obtained using the PerformanceCounter class, which is in the System.Diagnostics namespace.
private PerformanceCounter cpuCounter;
As a result, we got something like this:
OriginalIn the settings window, you can select the status update interval (1, 10, 15, 30, 60 minutes). The ticked data will be sent to Twitter, the list below displays the date and time of sending the tweet, the status of sending and the number of characters in the message.
Conclusion
In the future we plan to implement the following features:
- Sending more details via Direct Message
- Bot control with Direct Message and Mentinos
- Saving settings
- Logging
Here are the features that will be implemented in the next version of the bot.
Thank you all for your attention, I hope everyone was interested. I wish you creative success!
Links
Sources of the programTwitterizer Developer SiteDeveloper’s Twitterizer documentation