Coder Social home page Coder Social logo

shellshoccar-jpn / kotoriotoko Goto Github PK

View Code? Open in Web Editor NEW
92.0 9.0 18.0 1.09 MB

KOTORIOTOKO (little bird man) -- Extremely Compatible and Sustainable Twitter Application Written in Shell Script

License: The Unlicense

Shell 99.64% C 0.36%
twitter unix shellscript posix bourne-shell

kotoriotoko's Introduction

KOTORIOTOKO -- The Ultimate Shell Script Twitter Client App

Table of Contents

What is This?

Kotoriotoko, it means "Little Bird Man" in Japanese, is a command set to operate Twitter. This makes it possible to operate Twitter on CUI. It means that it gets easier to operate Twitter by other applications on UNIX.

And Kotoriotoko commands provide a lot of the following functions.

  • Posting
    • Tweet (you can also attach up to 4 image files or 1 video file and location info)
    • Retweet
    • Cancel a tweet
    • Like
    • Unlike
  • Tweets Viewing
    • View Somebody's timeline
    • Search tweets by keywords (you can also search with Streaming API)
  • User Controlling
    • Follow somebody
    • Unfollow somebody
    • List users who you following
    • List users who you are followed
    • View Somebody's info
  • Direct Message Managing
    • Send (up to 10,000 chrs, and you can also attach 1 image/video file or location info)
    • Receive
    • Delete
    • List
  • Other functions
    • View trend list
    • Gather tweets in bulk continuously (it also supports multi-byte character contained tweets, which is impossible by Streaming API)

Moreover, Kotoriotoko has more the following three strong points.

(1) Works Anywhere

Kotoriotoko works on various OSs. Even though it doesn't use OS-specialized codes basically, it works on Windows, Mac, of course, Un*x. I made sure of working on the following OSs.

  • Windows 10 (version 1607 and over, Windows Subsystem for Linux, which is available on developer mode)
  • Cygwin and gnupack
  • macOS (also Mac OS X, OS X)
  • Linux (CentOS5,6,7, Ubuntu12,14)
  • Raspbian (wheezy and jessie, which work on Raspberry Pi series)
  • FreeBSD (6,7,9,10,11)
  • NetBSD (7.0)
  • OpenBSD (6.0)
  • Solaris (11.3)
  • AIX (7.1)
  • HP-UX (11i v3)
  • OpenWrt (Barrier Breaker/14.07)

(2) Easy to Install

Kotoriotoko depends on only two extra commands besides POSIX commands. All of the other depending commands are already installed on all of the Unix-like systems. It requires no extra programming language (Perl, PHP, Ruby, Python, Java, Go, ...) and no enhancement shell (bash, ksh, zsh, ...). So there is almost nothing to have to do on installing Kotoriotoko. On almost of all system, what you have to do on installing is just to execute git command once because the majority of OS already have the two extra commands.

(3) Works for Good

I said Kototiotoko hardly depends on extra software. It means it is hardly involved in depending software troubles, for example, specification change due to version-up, becoming unusable due to vulnerable problems, end of support. There is little worry about depending POSIX stuff because there are a lot of compatible and exchangeable implementations by a lot of vendors. So you can use Kotoriotoko without maintenance for a long time.

How to Install

It consists of two (or three) steps.

Step 0. Make sure the requirements

You have to have the following stuff.

  1. A Twitter account
  2. A Unix host
  3. Two additional software
    1. OpenSSL or LibreSSL; if you have installed neither yet, you have to install one of them by source-compiling or package-management-system in advance. But you don't have to configure them anything at all.
    2. cURL or Wget; if you have installed neither yet, you have to install one of them by source-compiling or package-management-system in advance.

Most of all rental host service and/or Unix compatible OSs probably have the above software.

Step 1. Install Kotoriotoko

Type the following commands. That's all!

$ cd <AN_APPROPRIATE_DIRECTORY>
$ git clone https://github.com/ShellShoccar-jpn/kotoriotoko.git

If the git command isn't available, you can install the following way. But unzip command is required instead.

(The case you can use wget)

$ cd <AN_APPROPRIATE_DIRECTORY>
$ wget https://github.com/ShellShoccar-jpn/kotoriotoko/archive/master.zip
$ unzip master.zip
$ chmod +x kotoriotoko/BIN/* kotoriotoko/TOOL/* kotoriotoko/UTL/* kotoriotoko/APPS/*.sh

(The case you can use curl)

$ cd <AN_APPROPRIATE_DIRECTORY>
$ curl -O https://github.com/ShellShoccar-jpn/kotoriotoko/archive/master.zip
$ unzip master.zip
$ chmod +x kotoriotoko/BIN/* kotoriotoko/TOOL/* kotoriotoko/UTL/* kotoriotoko/APPS/*.sh

Step 2. Get four Twitter authentication keys and write them into a config file

You have to choose one way to get Twitter authentication keys.

(A) Quick setup for normal using

This first way is for people who want to use kotoriotoko just simply or want to finish to get and write auth-keys quickly. If so, execute the following commands. And what you have to do after that is just follow messages by this command and Twitter web page which this command guides you.

$ <KOTORIOTOKO_DIRECTORY_YOU_INSTALLED>/BIN/getstarted.sh

(B) Not quick setup for data analysis

The second way is for people who want to execute kotoriotoko commands at frequent intervals to collect massive tweets for data analyzing. "BIN/b*.sh" and "APPS/gathertw.sh" commands are provided for that purpose. If you want to do that, do the following substeps.

1) Register your cell phone number onto Twitter service for identification

Twitter service requires your cell phone number as a collateral for giving you application keys. To register it, you have to open the web page "Phone" with your web browser. You can arrive there by "Home" -> "Settings and privacy"/"Your account" -> "Account information" -> "Phone".

After registering your phone number, a PIN code will come to your phone by SMS. You have to input it onto the page finally.

2) Get four authentication keys on Twitter Apps page

At first, open Twitter Developers' site. Then, sign up to create a developer account (Maybe needed a few days to be accepted your applying), and sign in.

Next, open "Create App". You can arrive there by -> "Developer Portal" -> "Overview" under "Projects & Apps". Then, write your new app name into "App name" field and press "Complete" button.

And then, you should also press "App setting" button on the next page to move to its configuration page. On the page, you have to change "App permissions" from "Read only" to "Read, Write, and Direct Messages," which are all required by kotoriotoko. And, you should also write its explanation into the "DESCRIPTION" field in "App Details." It will help your app users.

Finally, move to "Keys and Tokens" tab. You can get the following four auth-keys by pressing "Regenerate" buttons on this page.

  • API key
  • API key secret
  • Access token
  • Access token secret

Don't forget to copy or memorize them for the next step.

3) Write the keys into CONFIG.SHLIB

Go back to your console, and type the following commands to make your own configuration file "CONFIG.SHLIB".

$ cd <KOTORIOTOKO_DIRECTORY_YOU_INSTALLED>/CONFIG
$ cp COMMON.SHLIB.SAMPLE COMMON.SHLIB
$ vi COMMON.SHLIB

And write the four auth-keys into the bottom with the following format.

            :
            :
######################################################################
# My account info
######################################################################

readonly MY_scname='YOUR_TWITTER_ID_(SCREEN_NAME)'
readonly MY_apikey='SET_YOUR_CONSUMER_KEY_HERE'
readonly MY_apisec='SET_YOUR_CONSUMER_SECRET_HERE'
readonly MY_atoken='SET_YOUR_ACCESS_TOKEN_HERE'
readonly MY_atksec='SET_YOUR_ACCESS_SECRET_HERE'
            :
            :

Usage

To know the usage, you should the following file/directory list. The files in "BIN" directory are Twitter operating commands. And you can see all of the command usages with executing with "--help" option.

.
|-- README.md ................ This file
|
|-- BIN/ ..................... Directory for Twitter operating commands
|   |                          (You have to learn only them basically)
|   |
|   |-- getstarted.sh ........ Get auth-keys (Only execute before starting to use kotoriotoko)
|   |
|   |-- tweet.sh ............. Post a Tweet
|   |-- ltweet.sh ............ Post One-Line-Tweets Line by Line
|   |-- retweet.sh ........... Retweet a Tweet
|   |-- deltweet.sh .......... Delete a Tweet
|   |-- twmediup.sh .......... Upload an Image or Video File to Twitter
|   |                          (The subcontract command of "tweet.sh")
|   |-- twvideoup.sh ......... Upload a Video File To Twitter
|   |                          (The sub-sub contract command which will be called by "twmediup.sh")
|   |
|   |-- twview.sh ............ View Tweets Which Are Request by Tweet-IDs
|   |-- twtl.sh .............. View The Twitter Timeline of A User
|   |-- twsrch.sh ............ Search Twitters Which Match With Given Keywords
|   |-- retwers.sh ........... View Users List Who Retweet the Specified Tweet
|   |
|   |-- twfav.sh ............. Like a Tweet (Mark Favorite)
|   |-- twunfav.sh ........... Cancel "Like" (Favorite) for the Specified Tweet
|   |-- favtws.sh ............ View the Favorite Tweets of a User
|   |
|   |-- twfollow.sh .......... Follow a User
|   |-- twunfollow.sh ........ Finish Following a User
|   |-- twfer.sh ............. List Followers of a Person
|   |-- twfing.sh ............ List Following Users of a Person
|   |-- twusers.sh ........... List Users Which Are Request by IDs
|   |
|   |-- getbtwid.sh .......... Get Your Bearer Token (it's required by b*.sh commands)
|   |-- btwsrch.sh ........... Search Twitters Which Match With Given Keywords (on Bearer Token Mode *1)
|   |-- btwtl.sh ............. View The Twitter Timeline of A User (on Bearer Token Mode *2)
|   |-- bretwer.sh ........... View Users List Who Retweet the Specified Tweet (on Bearer Token Mode *3)
|   |                          *1 Access limit will be mitigated once during 5sec -> 2sec
|   |                          *2 Access limit will be mitigated once during 5sec -> 3sec
|   |                          *3 Access limit will be mitigated once during 1min -> 15sec
|   |
|   |-- stwsrch.sh ........... Search Twitters Which Match With Given Keywords (on Streaming API Mode *4)
|   |                          *4 No access limit but for only English tweets
|   |
|   |-- twplsrch.sh .......... Search Place Information with Given Keywords
|   |-- twtrends.sh .......... View Trend Lists in The Specified Area
|   |
|   |-- dmtweet.sh ........... Post a Direct Message
|   |-- ldmtweet.sh .......... Post One-Line Direct Messages Line by Line
|   |-- deldmtw.sh ........... Delete a Direct Message
|   |-- dmtwview.sh .......... View a Direct Message Which Is Inquired by Tweet-IDs
|   `-- dmtwlist.sh .......... List Direct Messages Which Have Been Both Sent And Received
|
|
|-- CONFIG/ .................. Directory for Configuration File
|   |
|   |-- COMMON.SHLIB ......... Common Config-file
|   |                          * Use to set Twitter auth-keys
|   |                          * This file should be made by copying the following file
|   `-- COMMON.SHLIB.SAMPLE .. Common Config-file (template)
|
|
|-- TOOL/ .................... Directory for The Library shell script commands "Open usp Tukubai"
|   |                          * These commands are called by the commands in BIN/ directory
|   |
|   |-- calclock ............. Converting Command Between YYYYMMDDhhmmss and UNIX-time
|   `-- self ................. Extract text fields (SELect Fields)
|                              * "self 1 3 5" is equivalent to "awk '{print $1,$3,$5}'"
|                              * This command makes shell scripts more readable
|
|-- UTL/ ..................... Directory for Other Library shell script commands of our own making
|   |
|   |-- urlencode ............ URL encoder
|   |                          * This is used to generate OAuth string
|   |-- parsrj.sh ............ JSON Parser
|   |                          * This is used to read JSON data Twitter API returns
|   |-- unescj.sh ............ Unescape command for JSON data
|   |                          * This is used to decode Unicode Escaped characters
|   |                          * Twitter API returns escaped UTF-8 string
|   `-- mime-make ............ MIME Multipart Data Maker
|                              * This is used to upload image and video files when using Wget command
|
`-- APPS/ .................... Directory for Sample Applications Using Some Commands in BIN/
    |
    `-- gathertw.sh .......... Gather Tweets Which Match the Searching Keywords
                               * Gather tweets in bulk continuously
                               * Support real-time searching in a pseudo manner
                               * Also support languages other than English
                               * See APPS/gathertw.md for more information

License

Complete Public-Domain Software (CC0)

It means that all of the people can use this for any purposes with no restrictions at all. By the way, We are fed up with the side effects which are brought about by the major licenses.

kotoriotoko's People

Contributors

321516 avatar colrichie avatar tpaefawzen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kotoriotoko's Issues

interval_ok is unbound at 310: APPS/gathertw.sh

日本語で失礼します。
MacOSでgathertw.shを実行すると、310行目でinterval_ok: unbound variableになりました。
当座の処置として、315行目を310の直前に移動させて実行させています。
Mac OS固有の問題でしょうか?

TwetterPremiumAPIの使用について

gathertw.shを使用する際、StandardAPIではなく、PremiumAPIを使用する場合どこか変更する必要はありますでしょうか?
ご存じでしたら教えていただければ幸いです。
よろしくお願いします。

Suggestion: Ability to list twitter trends

Your script is very useful for me but it's lacking one thing, that is to be able to list twitter trends. It would be great if you could add that function to your script. Thanks

until_date in gathertw.sh

Thanks for great job, which enable us to collect twitter so easily.

In that script, there are two options until_date and since_date.
Why does not until_date allow to specify time, though since_date does?
Is there any technical difficulties?

Suggestion: Ability to filter out replied users.

Quick note, love kotoriotoko, been using it for months now.

But i came across a little problem, i want to make an auto-shoutout system, that if someone tags me they get a retweet on that specific tweet.

However everytime i use "twsrch.sh @myUser" it returns any tweets that contains @myUser, which includes any and all replies users do on any tweet or retweet i've made, and of course i can't just retweet all of them.

So an option to remove the replied users as part of the message would be great.

Termuxでは日本語ツイートができなかったが、BIN/urlencodeでenv -i awkするとできるようになる

元々のものでは「statusが空文字列になってしまう」ことがBIN/tweet.shやBIN/twsrch.shなどで確認されていました(ASCII文字はそのまま)。
そこで-vxオプションによりバグの解析を行った際にurlencodeを行ったあとにstatusに該当する部分が消滅することが確認されました。
これに対しUTL/urlencodeの、最初のawkについて、env -i awkと編集することにより、urlencodeが意図通りに動き、日本語でのツイートができるようになります。

同様に、BIN/twtl.shでは日本語など、(おそらくASCII文字列ではない)ツイートについては文字化けされた状態で表示されますが、UTL/unescj.shのawkをenv -i awkで実行させることにより正しく表示されるようになります。

ロケールの変更を行ってもTermux上ではロケールの固定によりawkに0から255まで全てのバイトを出力させることができない こと、そして全ての環境変数を無効にした状態でならできることが原因なのではないかと思われます。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.