Skip to content

Commit ac487e1

Browse files
committed
Initial Commit
1 parent 9763e43 commit ac487e1

11 files changed

+1689
-0
lines changed

README.md

+142
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,144 @@
11
# thebotbloglib
2+
23
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+
```

package.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "thebotbloglib",
3+
"description": "A library that can be used to create bots for social media such as Facebook.",
4+
"authors": [
5+
"Jacob Jensen"
6+
],
7+
"homepage": "https://github.com/TheBotBlog/",
8+
"license": "The MIT License (MIT)",
9+
"copyright": "Copyright © 2019 The Bot Blog",
10+
"targetType": "sourceLibrary",
11+
"sourcePaths": ["source"],
12+
"dependencies": {
13+
"vibe-d": {
14+
"version": "~>0.8.3"
15+
}
16+
}
17+
}

source/exceptions.d

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module thebotbloglib.exceptions;
2+
3+
final class WebException : Exception
4+
{
5+
public:
6+
/**
7+
* Creates a new web exception.
8+
* Params:
9+
* message = The message.
10+
* fn = The file.
11+
* ln = The line.
12+
*/
13+
this(string message, string fn = __FILE__, size_t ln = __LINE__) @safe
14+
{
15+
super(message, fn, ln);
16+
}
17+
}

0 commit comments

Comments
 (0)