Removed unneeded files and updated examples

This commit is contained in:
Rexy712 2019-07-16 14:45:06 -07:00
parent c2ff77aec0
commit e89d63e396
5 changed files with 42 additions and 473 deletions

View File

@ -1,5 +1,5 @@
/**
This file is a part of rexy's matrix bot
This file is a part of rexy's matrix client
Copyright (C) 2019 rexy712
This program is free software: you can redistribute it and/or modify
@ -22,28 +22,41 @@
#include "raii/static_string.hpp"
int main(){
//auth information needed to initiate a session
const char* username = "username";
const char* password = "password";
const char* useragent = "rexy712s info bot";
const char* homeserver = "matrix.org";
matrix::auth_data auth{username, password, homeserver};
matrix::bot matbot(auth, useragent);
auto sync_reply = matbot.sync(0); //initial sync
matrix::auth_data auth{username, password, homeserver, useragent};
bool should_quit = false;
matbot.set_message_callback([&](const matrix::bot& bot, const matrix::msg_info& msg)->void
//create an open connection to the homeserver
matrix::session ses(auth);
//access syncer instance to pull from server
matrix::syncer& syn = ses.get_syncer();
//access client instance to send events to the server or query specific data
matrix::client& cli = ses.get_client();
//initial sync to clear backlog
auto sync_reply = syn.sync(0);
//callback on recived message (also processes your own messages!)
//uses ref capture lambda to access client instance for message sending
syn.set_message_callback([&](const matrix::msg_info& msg)->void
{
if(msg.body == "!exit"_ss){
should_quit = true;
bot.send_message(msg.roomid, "[INFO] Shutting down..."_ss);
cli.send_message(msg.roomid, "[INFO] Shutting down..."_ss);
}else if(msg.body == "!info"_ss){
bot.send_message(msg.roomid, "This is an example of a bot which responds to commands!"_ss);
cli.send_message(msg.roomid, "This is an example of a bot which responds to commands!"_ss);
}
});
//continuously loop syncing operation to always keep up to date with the server state
while(!should_quit){
sync_reply = matbot.sync(30000);
sync_reply = syn.sync(30000);
}
}

View File

@ -1,5 +1,5 @@
/**
This file is a part of rexy's matrix bot
This file is a part of rexy's matrix client
Copyright (C) 2019 rexy712
This program is free software: you can redistribute it and/or modify
@ -21,21 +21,33 @@
#include "matrix.hpp"
int main(){
//auth information needed to initiate a session
const char* username = "username";
const char* password = "password";
const char* useragent = "rexy712s invite accepter";
const char* homeserver = "matrix.org";
matrix::auth_data auth{username, password, homeserver};
matrix::auth_data auth{username, password, homeserver, useragent};
//create on open connection to the homeserver
matrix::session ses(auth);
matrix::bot matbot(auth, useragent);
auto sync_reply = matbot.sync(0); //initial sync
//access syncer instance to pull from server
matrix::syncer& syn = ses.get_syncer();
matbot.set_invite_callback([&](const matrix::bot& bot, const matrix::invite_info& invite)->void{
bot.accept_invite(invite);
//access client instance to accept invites
matrix::client& client = ses.get_client();
//initial sync to clear backlog
auto sync_reply = syn.sync(0);
//callback on recieved membership events (invite, join, leave, ban, etc)
//uses ref capture lambda to access client instance for invite acceptance
syn.set_membership_callback([&](const matrix::membership_info& invite)->void{
client.accept_invite(invite);
});
//continuously loop syncing operation to always keep up to date with the server state
while(1){
sync_reply = matbot.sync(30000);
sync_reply = syn.sync(30000);
}
}

File diff suppressed because one or more lines are too long

View File

@ -1,2 +0,0 @@
curl -X POST -A "UserAgent: puller_bot" -d 'grant_type=password&username=rexy712&password=Mynameisrexy712' --user '1Bs38m2_jL9bow:dCQLZVFypHQcqqxBPAAe_kw609A' https://www.reddit.com/api/v1/access_token
curl -H "Authorization: bearer 81077812340-8u0foxY-a6mQ9B_W5wrhA1ZDZRQ" -A "UserAgent: puller_bot" "https://oauth.reddit.com/r/ProgrammerHumor/new?limit=1" | python -mjson.tool

View File

@ -1,2 +0,0 @@
curl -XGET http://www.youtube.com/get_video_info?video_id=<>