article,

Code Like Poetry, Bot Like Song - A Newbie's Adventure Journey Sparked by Wechaty

老张学技术 老张学技术 Follow Jul 05, 2021 · 7 mins read
Code Like Poetry, Bot Like Song - A Newbie's Adventure Journey Sparked by Wechaty

Preface

Short, line breaks, like poetry. In this world, besides the stacking of Chinese characters I love, there exists such a wonderful thing. It’s not by chance. It’s an unexpected encounter in life. More so, a lifetime’s joy! So, whenever I have free time, I pick up my fingers and feel the rhythm of my heart in short, broken lines. Of course, I’m naturally lazy - how could I become a geek? Looking up at the high mountain, my heart yearns for it, moving forward with trepidation, this is a kind of comfort for myself.

Slow, winding, like a song. The journey doesn’t matter. The code doesn’t matter. When I first ran the desired result, the desk I slapped echoed…… This is the most moving, most pleasant sound among the countless sounds I’ve heard, though no one sings it, it echoes in my heart! This is that guy called bot, through my fingertips, it occasionally croaks, and occasionally melodious……

Origin

Seen Beijing at 4 AM….. Seen Chengdu at 5 AM….. This is Versailles-style writing, they say. I often must see, see you later, won’t leave without seeing - what kind of competition is this?

Awareness must be high, execution must be thorough. Clients often tell me this. I remain silent. Then I start to think, what kind of awareness is high awareness, what kind of execution is thorough?

The budding of this bot guy came from after several consecutive all-nighters, in a “cordial and friendly” atmosphere with the client, inspiration just burst out with a bang. The client patted my shoulder and said, Lao Zhang, TMD can you not bother me when there’s nothing wrong? I’ve been answering your midnight calls for so long, I’m almost customer service. I said, TMD I can not bother you, you tell me, when can I bother you? The client’s face bloomed into a flower, this is one of the most beautiful flowers I’ve seen. In our lifetime, some flowers really bloom beautifully.

Information collection, priority sorting, time setting, sending mechanism. Round after round, the plan was finally finalized. The client smiled again, well, awareness is still sufficient, hurry up.

Then in a friendly atmosphere, the subsequent journey really began.

Journey

One

I don’t have much affection for Baidu compared to Google. But I eventually gave in to Baidu. After all, she can also give me some of the tenderness I want (applause and parentheses should be here - don’t overthink it). GitHub is also often slow as a snail. Sometimes you have to endure - small impatience spoils great plans. I accept, I endure. I kept switching between Baidu and GitHub, exhausting: WeChat robot, wx robot, WeChat bot, wechat robot…… Then I widened my eyes, concentrated, and in the familiar Chinese characters, I found nothing…… That was August 2017.

Hard work pays off for the devoted. After licking for a long time, heaven may inadvertently give you a surprise considering your mindless yet diligent effort (of course, a licker is always a licker, lickers must not forget their original intention). With my poor English and the persistence of a licker, I finally discovered: Wechaty!

The most impressive sentence to me was: five lines of code can write a WeChat robot (it’s said to be six lines, but my impression has always been five lines, I naturally like five, look at my account and you’ll know, haha). You understand! That kind of ecstasy! You don’t understand? That kind of ecstasy! Anyway, I understand! There’s the heavy sound of desk-banging here, please don’t imitate, lest your wife give you an even heavier lion’s roar!

Frankly speaking, when I saw a screen full of English, my heart actually wanted to curse: This TMD is all in English?! (TMD is Chinese characters, but don’t misinterpret, it means: quite cute). Then I bought a Tencent VPS (this is another kind of obsession, because of WeChat, I fell in love with all things Tencent, except games, and then abandoned all things Alibaba). Then various Baidu searches, various environment and code errors. TMD. Yes, quite cute. Reporting a problem for this Wechaty thing has such complex rules. I wore out fanyi.baidu.com before finally submitting the error information according to requirements. That was Aug 26, 2017. Why so clear? Because I copied it from an already closed issue. Then waiting for the great god……

Then the code finally ran through. The robot’s first message: Hello World! Hello, Lao Zhang!

Two

The client and I began a very sweet time (everyone, don’t let your imagination run wild, be serious). But this friendly and cordial atmosphere was broken by two problems: Is it really okay to freeload from open source like this? Network security issues (data on internal network), need to close the port for transmitting data to Tencent VPS.

The first problem is okay, freeload first, doesn’t everyone do this? So for the first problem, freeloading is still the way to go. As for future matters, it seems manageable. The second problem has no solution, only the strategy of delay. Then when delay was no longer possible, the client regretfully told me, we must have awareness, what must be closed must be closed, what must be executed thoroughly must be executed thoroughly without reservation. In the 2017 Lunar New Year, we executed thoroughly and shut down the WeChat robot based on Wechaty that was running quite happily. Regret, yes. Loss, even more!

Then I used my spare time to start learning some knowledge related to WeChat bots. Time quickly came to 2019. The outbreak of the pandemic suddenly changed many things: the trajectory of the world, the trajectory of life. These were all incorporated into new operational rules. During the lockdown fighting the pandemic, I started thinking, can I make a bot myself?

Perhaps I never thought about how risky such an idea was? The ignorant are fearless. Rather than saying it’s praise for a newbie, it’s more like a true portrait of a newbie. From then on, I’ve always maintained a lofty respect for countless newbies like me in this world. No other reason, I am such a newbie, we need such successive newbies (sinister smile).

The adventure journey begins. Besides the courage of ignorance, I actually faced: Once you enter BOT it’s as deep as the sea, looking back you find baldness has grown. I started tinkering, Baidu, GitHub, newly discovered Bilibili, climbing over the wall to Google. Then, gradually, some things began to take their initial shape. That shape, I still can’t forget to this day.

Winding Path

The initial version copied a lot of code, and learned superficially, so I never dared to let this code see the light of day. But still got quite a bit of attention. So while learning and tinkering, I started code refactoring. Finally mustered the courage to put this code on GitHub. For me, I still have inexplicable feelings about that courage.

To this day, the situation is still winding, things are not yet achieved, progress is slow and the road is long, barely taking a small step. The path is like water, nothing more than this. And every sound about bot in moving forward is clear and loud, like a song, lasting for a long time. The journey is still long, the adventure continues, but my state of mind is surprisingly normal!

Acknowledgments

To all selfless people! The true gods of this world should be you! To all persevering people! Your tireless figures moving forward are the best beacon!

Author: cixingguangming55555, Lao Zhang Learning Technology


Chinese version of this post: code like poetry bot like song

bot
Join Newsletter
Get the latest news right in your inbox. We never spam!
Written by 老张学技术
good good study,day day up.