[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
phython
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /wsr/ - Worksafe Requests

Thread replies: 4
Thread images: 1
File: IMG_3030.jpg (95 KB, 500x500) Image search: [Google]
IMG_3030.jpg
95 KB, 500x500
I'm trying to write a python for a bot.
Keeps saying syntax error on line 20, I delete the ":" and then like 22, 24, etc. PLEASE SOMEONE FIX IT AND PASTE IT ON HERE OR PASTEBIN
Here's the code::http://pastebin.com/akTPPasf
>>
shouldn't lines 21+22 (and the other like them) be indented?
>>
>>21442
onConnect(self, room):
room.message("Connected.")
Print("Connected")

onReronnect(self, room):
print("Reconnected")

onDisconnect(self, room):
Print("Disconnected")
like this?? I tried and it didn't work because it said the same for the next line and when i did it it said it didn't need the indention
>>
>>21433
>>21448
Lines 20, 24 and 27 are missing "def ". Look at lines 64 and 70, those are proper function declarations.

Also, are you sure you want those three functions there? I'm pretty sure you're supposed to declare them within your bot class, so that they replace the built-in functions in the ch.RoomManager class with the same names (I found https://github.com/Nullspeaker/ch.py/blob/master/ch.py which I assume to be the "ch" library you're importing).

I deduce this for two reasons: one, those functions aren't called anywhere in your code, and two, they take "self" as first argument, which is mandatory for functions within a class but quite weird outside. I guess you read somewhere that you had to write those custom functions but weren't sure where they were supposed to go.

Move them into your bot class, for example after the onInit function, starting at current line 69.

Aside from this, I see some indentation problems. On top of what >>21442 pointed out, I see a few elifs that are not on the same depth as their matching if: lines 25, 87, 94.

I speak as a small-time amateur programmer, so take this with a grain of salt. Also, I apologise for any possible terminology errors and would welcome corrections from a better-educated programmer.
Thread replies: 4
Thread images: 1

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.