Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // A simple hug bot in D.
- // @author RainbowDashDC
- // @version 1.1A
- // Shoutout too @suhosinpony who got me into D.
- // Import needed libs.
- import std.stdio;
- import std.datetime;
- import std.getopt;
- ulong get_time() {
- // Return Current Time.
- return Clock.currTime().toUnixTime();
- }
- void start_timer(string message, int timer) {
- // Declare variables and base init them.
- ulong time_now = get_time();
- ulong time_until = time_now+(timer);
- while(time_until != time_now) {
- time_now = get_time();
- }
- writeln(message);
- }
- int main(string[] args) {
- // Init Values
- ulong time = get_time();
- string message = "*hugs*";
- int timer = 60*60;
- bool help;
- // Get CMD Args
- getopt(
- args,
- "message", &message,
- "timer", &timer,
- "help", &help
- );
- // Check for help
- if(help) {
- writeln("(C)2013-Present RDashINC");
- writeln("Version 1.1A, GNUGPLv3");
- writeln("\nSYNOPSIS: hb [OPTIONS]...");
- writeln("DESC: Print out [message] each [timer].");
- writeln("\nOPTIONS:");
- writeln(" --help Show this page.");
- writeln(" --mesage=[msg] Use this instead of '*hugs*'");
- writeln(" --timer=[second] Use this for timer.");
- writeln("\nEmail bug reports and suggestions too <allardj64@gmail.com>");
- return 0;
- }
- // Get initial time.
- writeln("Started: ", time);
- // Write Settings.
- writeln("Using '", message, "' as the message.");
- writeln("Operating at '", timer, "' timer");
- while(true) {
- start_timer(message, timer);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement