-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from graniet/version-beta
Version beta
- Loading branch information
Showing
24 changed files
with
966 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
API_HOST=127.0.0.1 | ||
API_PORT=8888 | ||
API_VERBOSE=true | ||
API_VERBOSE=true | ||
|
||
DB_NAME="./opf.db" | ||
DB_DRIVER=sqlite3 | ||
DB_HOST= | ||
DB_USER= | ||
DB_PASS= | ||
|
||
OPERATIVE_HISTORY="/tmp/operative_framework.tmp" | ||
|
||
INSTAGRAM_LOGIN=Usern4m3 | ||
INSTAGRAM_PASSWORD=P4ssw0rd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package api | ||
|
||
import ( | ||
"encoding/json" | ||
"net/http" | ||
) | ||
|
||
type OneSession struct{ | ||
Id int `json:"id"` | ||
SessionName string `json:"session_id"` | ||
} | ||
|
||
func (OneSession) TableName() string{ | ||
return "sessions" | ||
} | ||
|
||
func (api *ARestFul) Sessions(w http.ResponseWriter, r *http.Request){ | ||
w.Header().Set("Content-Type", "application/json") | ||
w.Header().Set("Access-Control-Allow-Origin", "*") | ||
var sessions []OneSession | ||
api.sess.Connection.ORM.Find(&sessions) | ||
message := api.Core.PrintData("request executed", false, sessions) | ||
_= json.NewEncoder(w).Encode(message) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package config | ||
|
||
type Config struct{ | ||
Api ApiConfig | ||
Database DataBase | ||
Common Common | ||
Instagram Network | ||
} | ||
|
||
type Network struct{ | ||
Login string | ||
Password string | ||
Api ApiConfig | ||
} | ||
|
||
type DataBase struct{ | ||
Name string | ||
User string | ||
Pass string | ||
Host string | ||
Driver string | ||
Port string | ||
} | ||
|
||
type Common struct{ | ||
HistoryFile string | ||
} | ||
|
||
type ApiConfig struct{ | ||
Host string | ||
Port string | ||
Key string | ||
SKey string | ||
Verbose string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package config | ||
|
||
import ( | ||
"github.com/joho/godotenv" | ||
"github.com/pkg/errors" | ||
"os" | ||
) | ||
|
||
func ParseConfig() (Config, error){ | ||
conf := Config{} | ||
err := godotenv.Load(".env") | ||
if err != nil{ | ||
return Config{}, errors.New("Please rename/create .env file on root path.") | ||
} | ||
|
||
|
||
conf.Instagram.Login = os.Getenv("INSTAGRAM_LOGIN") | ||
conf.Instagram.Password = os.Getenv("INSTAGRAM_PASSWORD") | ||
|
||
conf.Api.Host = os.Getenv("API_HOST") | ||
conf.Api.Port = os.Getenv("API_PORT") | ||
conf.Api.Verbose = os.Getenv("API_VERBOSE") | ||
|
||
conf.Common.HistoryFile = os.Getenv("OPERATIVE_HISTORY") | ||
|
||
conf.Database.Driver = os.Getenv("DB_DRIVER") | ||
conf.Database.Name = os.Getenv("DB_NAME") | ||
conf.Database.Host = os.Getenv("DB_HOST") | ||
conf.Database.User = os.Getenv("DB_USER") | ||
conf.Database.Pass = os.Getenv("DB_PASS") | ||
|
||
return conf, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package filters | ||
|
||
import ( | ||
"github.com/graniet/operative-framework/filters/phone_to_instagram" | ||
"github.com/graniet/operative-framework/filters/say_hello" | ||
"github.com/graniet/operative-framework/session" | ||
) | ||
|
||
func LoadFilters(s *session.Session){ | ||
s.Filters = append(s.Filters, say_hello.PushSayHelloFilter(s)) | ||
s.Filters = append(s.Filters, phone_to_instagram.PushPhoneToInstagramFilter(s)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package phone_to_instagram | ||
|
||
import ( | ||
"fmt" | ||
"github.com/graniet/go-pretty/table" | ||
"github.com/graniet/operative-framework/session" | ||
"gopkg.in/ahmdrz/goinsta.v2" | ||
"os" | ||
) | ||
|
||
type PhoneToInstagram struct{ | ||
session.SessionFilter | ||
Sess *session.Session | ||
} | ||
|
||
func PushPhoneToInstagramFilter(s *session.Session) *PhoneToInstagram{ | ||
mod := PhoneToInstagram{ | ||
Sess: s, | ||
} | ||
mod.AddModule("phone_generator") | ||
return &mod | ||
} | ||
|
||
func (filter *PhoneToInstagram) Name() string{ | ||
return "phone_to_instagram" | ||
} | ||
|
||
func (filter *PhoneToInstagram) Description() string{ | ||
return "Find result of phone_generator module in instagram network." | ||
} | ||
|
||
func (filter *PhoneToInstagram) Author() string{ | ||
return "Tristan Granier" | ||
} | ||
|
||
func (filter *PhoneToInstagram) Start(mod session.Module){ | ||
insta := goinsta.New(filter.Sess.Config.Instagram.Login, filter.Sess.Config.Instagram.Password) | ||
|
||
if err := insta.Login(); err != nil { | ||
fmt.Println(err) | ||
return | ||
} | ||
|
||
var Contacts []goinsta.Contact | ||
Contacts = append(Contacts, goinsta.Contact{ | ||
Numbers: mod.GetResults(), | ||
}) | ||
syncAwser, err := insta.Contacts.SyncContacts(&Contacts) | ||
if err != nil{ | ||
fmt.Println(err.Error()) | ||
return | ||
} | ||
|
||
t := filter.Sess.Stream.GenerateTable() | ||
t.SetOutputMirror(os.Stdout) | ||
t.SetAllowedColumnLengths([]int{0,0,0,50}) | ||
t.AppendHeader(table.Row{ | ||
"Username", | ||
"isPrivate", | ||
"isVerified", | ||
"Picture", | ||
|
||
}) | ||
if len(syncAwser.Users) > 0{ | ||
for _,users := range syncAwser.Users{ | ||
t.AppendRow(table.Row{ | ||
users.Username, | ||
users.IsPrivate, | ||
users.IsVerified, | ||
users.ProfilePicURL, | ||
}) | ||
} | ||
} | ||
|
||
filter.Sess.Stream.Render(t) | ||
|
||
} |
Oops, something went wrong.