|
1 | 1 | # thebotbloglib
|
| 2 | + |
2 | 3 | A library that can be used to create bots for social media such as Facebook.
|
| 4 | + |
| 5 | +To use the ImageManager class you must have ImageCmd compiled in the root folder of your project. |
| 6 | + |
| 7 | +ImageCmd: https://github.com/TheBotBlog/ImageCmd |
| 8 | + |
| 9 | +## Examples |
| 10 | + |
| 11 | +### Createing a service. |
| 12 | + |
| 13 | +``` |
| 14 | +auto service = new FacebookService("PAGE_ID", "TOKEN"); |
| 15 | +``` |
| 16 | + |
| 17 | +### Creating a post |
| 18 | + |
| 19 | +``` |
| 20 | +auto post = service.createPost("MESSAGE"); |
| 21 | +``` |
| 22 | + |
| 23 | +### Creating a post with an image |
| 24 | + |
| 25 | +``` |
| 26 | +auto post = service.createPost("MESSAGE", "IMAGE_URL"); |
| 27 | +``` |
| 28 | + |
| 29 | +### Retrieving a post |
| 30 | + |
| 31 | +``` |
| 32 | +auto post = service.retrievePost("POST_ID", true); |
| 33 | +``` |
| 34 | + |
| 35 | +### Updating the link and photo of a retrieved post. |
| 36 | + |
| 37 | +``` |
| 38 | +post.updateLinkAndPhoto(); |
| 39 | +``` |
| 40 | + |
| 41 | +### Reading comments from a post. |
| 42 | + |
| 43 | +``` |
| 44 | +auto comments = post.readComments(); |
| 45 | +
|
| 46 | +while (post.hasMoreComments) |
| 47 | +{ |
| 48 | + comments ~= post.readNextComments(); |
| 49 | +} |
| 50 | +``` |
| 51 | + |
| 52 | +### Getting post reactions |
| 53 | + |
| 54 | +For comments just switch the post out with the comment object. |
| 55 | + |
| 56 | +``` |
| 57 | +post.updateReacts(); |
| 58 | +
|
| 59 | +foreach (loveReact; post.loveReacts) |
| 60 | +{ |
| 61 | + // ... |
| 62 | +} |
| 63 | +``` |
| 64 | + |
| 65 | +### Getting comment reactions |
| 66 | + |
| 67 | +For comments just switch the post out with the comment object. |
| 68 | + |
| 69 | +``` |
| 70 | +foreach (comment; comments) |
| 71 | +{ |
| 72 | + comment.updateReacts(); |
| 73 | +
|
| 74 | + foreach (loveReact; comment.loveReacts) |
| 75 | + { |
| 76 | + // ... |
| 77 | + } |
| 78 | +} |
| 79 | +``` |
| 80 | + |
| 81 | +**The below examples require ImageCmd** |
| 82 | + |
| 83 | +### Initializing an image |
| 84 | + |
| 85 | +``` |
| 86 | +auto imageManager = new ImageManager("SOURCE_IMAGE_PATH", "finalized%s.png"); |
| 87 | +
|
| 88 | +//The final image will be named "finalized.png" |
| 89 | +``` |
| 90 | + |
| 91 | +### Rotating an image 180 degrees |
| 92 | + |
| 93 | +``` |
| 94 | +imageManager.rotate180(); |
| 95 | +``` |
| 96 | + |
| 97 | +### Draw an image |
| 98 | + |
| 99 | +``` |
| 100 | +imageManager.drawImage("IMAGE_PATH", X, Y, WIDTH, HEIGHT); |
| 101 | +``` |
| 102 | + |
| 103 | +### Draw a rectangle |
| 104 | + |
| 105 | +``` |
| 106 | +imageManager.drawRectangle(X, Y, WIDTH, HEIGHT, Color.rgb(0,0,0), true); |
| 107 | +``` |
| 108 | + |
| 109 | +### Drawing text |
| 110 | + |
| 111 | +``` |
| 112 | +{ |
| 113 | + auto textOptions = new TextOptions; |
| 114 | + textOptions.fontName = "Verdana"; |
| 115 | + textOptions.fontSize = 42.0; |
| 116 | + textOptions.color = Color.rgb(255, 255, 255); |
| 117 | + textOptions.rect = new Rectangle; |
| 118 | + textOptions.rect.x = 0; |
| 119 | + textOptions.rect.y = 0; |
| 120 | + textOptions.rect.fixedWidth = true; |
| 121 | + textOptions.rect.fixedHeight = true; |
| 122 | + textOptions.centerText = true; |
| 123 | +
|
| 124 | + imageManager.drawText("The text to draw", textOptions); |
| 125 | +} |
| 126 | +``` |
| 127 | + |
| 128 | +### Inversing colors |
| 129 | + |
| 130 | +``` |
| 131 | +imageManager.inverseColors(); |
| 132 | +``` |
| 133 | + |
| 134 | +### Making the image black and white |
| 135 | + |
| 136 | +``` |
| 137 | +imageManager.turnBlackAndWhite(); |
| 138 | +``` |
| 139 | + |
| 140 | +### Finalizing the image |
| 141 | + |
| 142 | +``` |
| 143 | +imageManager.finalize(); |
| 144 | +``` |
0 commit comments